fix setting relation mark via API #24

Merged
hsh-michaelhoennig merged 1 commits from fix-saving-mark into master 2024-03-14 12:52:25 +01:00
4 changed files with 13 additions and 4 deletions
Showing only changes of commit 6bac02380b - Show all commits

View File

@ -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())
));

View File

@ -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

View File

@ -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"))

View File

@ -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