fix setting relation mark via API #24
@ -70,6 +70,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
|
|||||||
|
|
||||||
final var entityToSave = new HsOfficeRelationEntity();
|
final var entityToSave = new HsOfficeRelationEntity();
|
||||||
entityToSave.setType(HsOfficeRelationType.valueOf(body.getType()));
|
entityToSave.setType(HsOfficeRelationType.valueOf(body.getType()));
|
||||||
|
entityToSave.setMark(body.getMark());
|
||||||
entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow(
|
entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow(
|
||||||
() -> new NoSuchElementException("cannot find anchorUuid " + body.getAnchorUuid())
|
() -> new NoSuchElementException("cannot find anchorUuid " + body.getAnchorUuid())
|
||||||
));
|
));
|
||||||
|
@ -55,6 +55,7 @@ components:
|
|||||||
nullable: true
|
nullable: true
|
||||||
mark:
|
mark:
|
||||||
type: string
|
type: string
|
||||||
|
nullable: true
|
||||||
contactUuid:
|
contactUuid:
|
||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
@ -62,4 +63,4 @@ components:
|
|||||||
- anchorUuid
|
- anchorUuid
|
||||||
- holderUuid
|
- holderUuid
|
||||||
- type
|
- type
|
||||||
- relContactUuid
|
- contactUuid
|
||||||
|
@ -137,12 +137,14 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
|||||||
.body("""
|
.body("""
|
||||||
{
|
{
|
||||||
"type": "%s",
|
"type": "%s",
|
||||||
|
"mark": "%s",
|
||||||
"anchorUuid": "%s",
|
"anchorUuid": "%s",
|
||||||
"holderUuid": "%s",
|
"holderUuid": "%s",
|
||||||
"contactUuid": "%s"
|
"contactUuid": "%s"
|
||||||
}
|
}
|
||||||
""".formatted(
|
""".formatted(
|
||||||
HsOfficeRelationTypeResource.DEBITOR,
|
HsOfficeRelationTypeResource.SUBSCRIBER,
|
||||||
|
"operations-discuss",
|
||||||
givenAnchorPerson.getUuid(),
|
givenAnchorPerson.getUuid(),
|
||||||
givenHolderPerson.getUuid(),
|
givenHolderPerson.getUuid(),
|
||||||
givenContact.getUuid()))
|
givenContact.getUuid()))
|
||||||
@ -153,7 +155,8 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
|
|||||||
.statusCode(201)
|
.statusCode(201)
|
||||||
.contentType(ContentType.JSON)
|
.contentType(ContentType.JSON)
|
||||||
.body("uuid", isUuidValid())
|
.body("uuid", isUuidValid())
|
||||||
.body("type", is("DEBITOR"))
|
.body("type", is("SUBSCRIBER"))
|
||||||
|
.body("mark", is("operations-discuss"))
|
||||||
.body("anchor.tradeName", is("Third OHG"))
|
.body("anchor.tradeName", is("Third OHG"))
|
||||||
.body("holder.givenName", is("Paul"))
|
.body("holder.givenName", is("Paul"))
|
||||||
.body("contact.label", is("second contact"))
|
.body("contact.label", is("second contact"))
|
||||||
|
@ -72,7 +72,8 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
final var newRelation = HsOfficeRelationEntity.builder()
|
final var newRelation = HsOfficeRelationEntity.builder()
|
||||||
.anchor(givenAnchorPerson)
|
.anchor(givenAnchorPerson)
|
||||||
.holder(givenHolderPerson)
|
.holder(givenHolderPerson)
|
||||||
.type(HsOfficeRelationType.REPRESENTATIVE)
|
.type(HsOfficeRelationType.SUBSCRIBER)
|
||||||
|
.mark("operations-announce")
|
||||||
.contact(givenContact)
|
.contact(givenContact)
|
||||||
.build();
|
.build();
|
||||||
return toCleanup(relationRepo.save(newRelation));
|
return toCleanup(relationRepo.save(newRelation));
|
||||||
@ -83,6 +84,9 @@ class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelationEntity::getUuid).isNotNull();
|
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeRelationEntity::getUuid).isNotNull();
|
||||||
assertThatRelationIsPersisted(result.returnedValue());
|
assertThatRelationIsPersisted(result.returnedValue());
|
||||||
assertThat(relationRepo.count()).isEqualTo(count + 1);
|
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
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user