From 627ad68dfb790d81aaa36a369355506363711c4e Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 5 Aug 2024 11:09:16 +0200 Subject: [PATCH] fix JUnit tests --- .../hs/office/relation/HsOfficeRelationController.java | 6 +++--- .../office/partner/HsOfficePartnerControllerRestTest.java | 4 ++-- .../HsOfficeRelationControllerAcceptanceTest.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index 77e5d7a6..da2e11a0 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java @@ -72,13 +72,13 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { entityToSave.setType(HsOfficeRelationType.valueOf(body.getType())); entityToSave.setMark(body.getMark()); entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow( - () -> new NoSuchElementException("cannot find anchorUuid " + body.getAnchorUuid()) + () -> new NoSuchElementException("cannot find Person by anchorUuid: " + body.getAnchorUuid()) )); entityToSave.setHolder(holderRepo.findByUuid(body.getHolderUuid()).orElseThrow( - () -> new NoSuchElementException("cannot find holderUuid " + body.getHolderUuid()) + () -> new NoSuchElementException("cannot find Person by holderUuid: " + body.getHolderUuid()) )); entityToSave.setContact(contactBareRepo.findByUuid(body.getContactUuid()).orElseThrow( - () -> new NoSuchElementException("cannot find contactUuid " + body.getContactUuid()) + () -> new NoSuchElementException("cannot find Contact by contactUuid: " + body.getContactUuid()) )); final var saved = relationRbacRepo.save(entityToSave); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java index 2359f20c..e8ce3dfb 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java @@ -124,7 +124,7 @@ class HsOfficePartnerControllerRestTest { .andExpect(status().is4xxClientError()) .andExpect(jsonPath("statusCode", is(400))) .andExpect(jsonPath("statusPhrase", is("Bad Request"))) - .andExpect(jsonPath("message", startsWith("Cannot resolve HsOfficePersonEntity with uuid "))); + .andExpect(jsonPath("message", startsWith("ERROR: [400] Cannot resolve HsOfficePersonEntity with uuid "))); } @Test @@ -161,7 +161,7 @@ class HsOfficePartnerControllerRestTest { .andExpect(status().is4xxClientError()) .andExpect(jsonPath("statusCode", is(400))) .andExpect(jsonPath("statusPhrase", is("Bad Request"))) - .andExpect(jsonPath("message", startsWith("Cannot resolve HsOfficeContactBareEntity with uuid "))); + .andExpect(jsonPath("message", startsWith("ERROR: [400] Cannot resolve HsOfficeContactBareEntity with uuid "))); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 5f52c1cf..54989f0e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -195,7 +195,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .post("http://localhost/api/hs/office/relations") .then().log().all().assertThat() .statusCode(404) - .body("message", is("cannot find anchorUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID)); + .body("message", is("ERROR: [404] cannot find Person by anchorUuid: " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID)); // @formatter:on } @@ -227,7 +227,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .post("http://localhost/api/hs/office/relations") .then().log().all().assertThat() .statusCode(404) - .body("message", is("cannot find holderUuid " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID)); + .body("message", is("ERROR: [404] cannot find Person by holderUuid: " + GIVEN_NON_EXISTING_HOLDER_PERSON_UUID)); // @formatter:on } @@ -250,7 +250,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean "holderUuid": "%s", "contactUuid": "%s" } - """.formatted( + """.formatted( HsOfficeRelationTypeResource.DEBITOR, givenAnchorPerson.getUuid(), givenHolderPerson.getUuid(), @@ -260,7 +260,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .post("http://localhost/api/hs/office/relations") .then().log().all().assertThat() .statusCode(404) - .body("message", is("cannot find contactUuid 00000000-0000-0000-0000-000000000000")); + .body("message", is("ERROR: [404] cannot find Contact by contactUuid: 00000000-0000-0000-0000-000000000000")); // @formatter:on } }