fetch nameOfDeceasedPerson from partnerrel.holder-person

This commit is contained in:
Michael Hoennig 2024-12-18 10:26:19 +01:00
parent 091454b6ab
commit 966ac662cd
2 changed files with 17 additions and 15 deletions

View File

@ -621,7 +621,6 @@ class HsOfficeScenarioTests extends ScenarioTest {
void shouldReplaceDeceasedPartnerByCommunityOfHeirs() { void shouldReplaceDeceasedPartnerByCommunityOfHeirs() {
new ReplaceDeceasedPartnerWithCommunityOfHeirs(scenarioTest) new ReplaceDeceasedPartnerWithCommunityOfHeirs(scenarioTest)
.given("partnerNumber", "P-31011") .given("partnerNumber", "P-31011")
.given("nameOfDeceasedPerson", "Michelle Matthieu") // FIXME: redundant
.given("dateOfDeath", "2024-11-15") .given("dateOfDeath", "2024-11-15")
.given("representativeGivenName", "Lena") .given("representativeGivenName", "Lena")
.given("representativeFamilyName", "Stadland") .given("representativeFamilyName", "Stadland")

View File

@ -30,21 +30,24 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
.reportWithResponse().expecting(OK).expecting(JSON), .reportWithResponse().expecting(OK).expecting(JSON),
response -> response.getFromBody("uuid"), response -> response.getFromBody("uuid"),
"Even in production data we expect this query to return just a single result." // TODO.impl: add constraint? "Even in production data we expect this query to return just a single result." // TODO.impl: add constraint?
).extractValue("partnerRel.holder.uuid", "Person: %{nameOfDeceasedPerson}"); )
.extractValue("partnerRel.holder.familyName", "familyNameOfDeceasedPerson")
.extractValue("partnerRel.holder.givenName", "givenNameOfDeceasedPerson")
.extractUuidAlias("partnerRel.holder.uuid", "Person: %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}");
obtain("Partner-Relation: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> obtain("Partner-Relation: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}", () ->
httpPost("/api/hs/office/relations", usingJsonBody(""" httpPost("/api/hs/office/relations", usingJsonBody("""
{ {
"type": "PARTNER", "type": "PARTNER",
"anchor.uuid": ${Person: Hostsharing eG}, "anchor.uuid": ${Person: Hostsharing eG},
"holder": { "holder": {
"personType": "UNINCORPORATED_FIRM", "personType": "UNINCORPORATED_FIRM",
"tradeName": "Erbengemeinschaft %{nameOfDeceasedPerson}", "tradeName": "Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}",
}, },
"contact": { "contact": {
"caption": "Erbengemeinschaft %{nameOfDeceasedPerson}", "caption": "Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}",
"postalAddress": { "postalAddress": {
"name": "Erbengemeinschaft %{nameOfDeceasedPerson}", "name": "Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}",
"co": "%{representativeGivenName} %{representativeFamilyName}", "co": "%{representativeGivenName} %{representativeFamilyName}",
%{communityOfHeirsPostalAddress} %{communityOfHeirsPostalAddress}
}, },
@ -59,29 +62,29 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
""")) """))
.reportWithResponse().expecting(CREATED).expecting(JSON) .reportWithResponse().expecting(CREATED).expecting(JSON)
) )
.extractUuidAlias("contact.uuid", "Contact: Erbengemeinschaft %{nameOfDeceasedPerson}") .extractUuidAlias("contact.uuid", "Contact: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}")
.extractUuidAlias("holder.uuid", "Person: Erbengemeinschaft %{nameOfDeceasedPerson}"); .extractUuidAlias("holder.uuid", "Person: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}");
obtain("Representative-Relation: %{representativeGivenName} %{representativeFamilyName} for Erbengemeinschaft %{nameOfDeceasedPerson}", () -> obtain("Representative-Relation: %{representativeGivenName} %{representativeFamilyName} for Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}", () ->
httpPost("/api/hs/office/relations", usingJsonBody(""" httpPost("/api/hs/office/relations", usingJsonBody("""
{ {
"type": "REPRESENTATIVE", "type": "REPRESENTATIVE",
"anchor.uuid": ${Person: Erbengemeinschaft %{nameOfDeceasedPerson}}, "anchor.uuid": ${Person: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}},
"holder": { "holder": {
"personType": "NATURAL_PERSON", "personType": "NATURAL_PERSON",
"givenName": ${representativeGivenName}, "givenName": ${representativeGivenName},
"familyName": ${representativeFamilyName} "familyName": ${representativeFamilyName}
}, },
"contact.uuid": ${Contact: Erbengemeinschaft %{nameOfDeceasedPerson}} "contact.uuid": ${Contact: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}}
} }
""")) """))
.reportWithResponse().expecting(CREATED).expecting(JSON) .reportWithResponse().expecting(CREATED).expecting(JSON)
).extractUuidAlias("holder.uuid", "Person: %{representativeGivenName} %{representativeFamilyName}"); ).extractUuidAlias("holder.uuid", "Person: %{representativeGivenName} %{representativeFamilyName}");
obtain("Partner: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> obtain("Partner: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}", () ->
httpPatch("/api/hs/office/partners/%{Partner: %{partnerNumber}}", usingJsonBody(""" httpPatch("/api/hs/office/partners/%{Partner: %{partnerNumber}}", usingJsonBody("""
{ {
"partnerRel.uuid": ${Partner-Relation: Erbengemeinschaft %{nameOfDeceasedPerson}} "partnerRel.uuid": ${Partner-Relation: Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}}
} }
""")) """))
.expecting(HttpStatus.OK) .expecting(HttpStatus.OK)
@ -117,7 +120,7 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
"Verify the Updated Partner", "Verify the Updated Partner",
() -> httpGet("/api/hs/office/partners/%{partnerNumber}") () -> httpGet("/api/hs/office/partners/%{partnerNumber}")
.expecting(OK).expecting(JSON).expectObject(), .expecting(OK).expecting(JSON).expectObject(),
path("partnerRel.holder.tradeName").contains("Erbengemeinschaft %{nameOfDeceasedPerson}") path("partnerRel.holder.tradeName").contains("Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}")
); );
// TODO.test: Verify the EX_PARTNER-Relation, once we fixed the anchor problem, see HsOfficePartnerController // TODO.test: Verify the EX_PARTNER-Relation, once we fixed the anchor problem, see HsOfficePartnerController
@ -127,7 +130,7 @@ public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase<ReplaceD
"Verify the Representative-Relation", "Verify the Representative-Relation",
() -> httpGet("/api/hs/office/relations?relationType=REPRESENTATIVE&personUuid=%{Person: %{representativeGivenName} %{representativeFamilyName}}") () -> httpGet("/api/hs/office/relations?relationType=REPRESENTATIVE&personUuid=%{Person: %{representativeGivenName} %{representativeFamilyName}}")
.expecting(OK).expecting(JSON).expectArrayElements(1), .expecting(OK).expecting(JSON).expectArrayElements(1),
path("[0].anchor.tradeName").contains("Erbengemeinschaft %{nameOfDeceasedPerson}"), path("[0].anchor.tradeName").contains("Erbengemeinschaft %{givenNameOfDeceasedPerson} %{familyNameOfDeceasedPerson}"),
path("[0].holder.familyName").contains("%{representativeFamilyName}") path("[0].holder.familyName").contains("%{representativeFamilyName}")
); );