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 a7923128..e1f80148 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 @@ -70,6 +70,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { final var entityToSave = new HsOfficeRelationEntity(); entityToSave.setType(HsOfficeRelationType.valueOf(body.getType())); + entityToSave.setMark(body.getMark()); entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow( () -> new NoSuchElementException("cannot find anchorUuid " + body.getAnchorUuid()) )); diff --git a/src/main/resources/api-definition/hs-office/hs-office-relations-schemas.yaml b/src/main/resources/api-definition/hs-office/hs-office-relations-schemas.yaml index b092cd0a..7b316b40 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-relations-schemas.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-relations-schemas.yaml @@ -55,6 +55,7 @@ components: nullable: true mark: type: string + nullable: true contactUuid: type: string format: uuid @@ -62,4 +63,4 @@ components: - anchorUuid - holderUuid - type - - relContactUuid + - contactUuid 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 fd978e1d..c4654bd3 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 @@ -137,12 +137,14 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .body(""" { "type": "%s", + "mark": "%s", "anchorUuid": "%s", "holderUuid": "%s", "contactUuid": "%s" } """.formatted( - HsOfficeRelationTypeResource.DEBITOR, + HsOfficeRelationTypeResource.SUBSCRIBER, + "operations-discuss", givenAnchorPerson.getUuid(), givenHolderPerson.getUuid(), givenContact.getUuid())) @@ -153,7 +155,8 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .statusCode(201) .contentType(ContentType.JSON) .body("uuid", isUuidValid()) - .body("type", is("DEBITOR")) + .body("type", is("SUBSCRIBER")) + .body("mark", is("operations-discuss")) .body("anchor.tradeName", is("Third OHG")) .body("holder.givenName", is("Paul")) .body("contact.label", is("second contact")) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java index 545e7b03..5c10af88 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java @@ -72,7 +72,8 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea final var newRelation = HsOfficeRelationEntity.builder() .anchor(givenAnchorPerson) .holder(givenHolderPerson) - .type(HsOfficeRelationType.REPRESENTATIVE) + .type(HsOfficeRelationType.SUBSCRIBER) + .mark("operations-announce") .contact(givenContact) .build(); return toCleanup(relationRepo.save(newRelation)); @@ -83,6 +84,9 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelationEntity::getUuid).isNotNull(); assertThatRelationIsPersisted(result.returnedValue()); assertThat(relationRepo.count()).isEqualTo(count + 1); + final var stored = relationRepo.findByUuid(result.returnedValue().getUuid()); + assertThat(stored).isNotEmpty().map(HsOfficeRelationEntity::toString).get() + .isEqualTo("rel(anchor='NP Bessler, Anita', type='SUBSCRIBER', mark='operations-announce', holder='NP Bessler, Anita', contact='fourth contact')"); } @Test