From 781fcef1d32c610bd6bc9145ecfdff853f9f47be Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 6 Dec 2024 15:56:07 +0100 Subject: [PATCH] create new PARTNER relation for community of heirs --- .../scenarios/HsOfficeScenarioTests.java | 30 +++++++ ...ceDeceasedPartnerWithCommunityOfHeirs.java | 84 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 9f957472..41a1e4fe 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -29,6 +29,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContac import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddRepresentativeToPartner; import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner; import net.hostsharing.hsadminng.hs.office.scenarios.partner.DeletePartner; +import net.hostsharing.hsadminng.hs.office.scenarios.partner.ReplaceDeceasedPartnerWithCommunityOfHeirs; import net.hostsharing.hsadminng.hs.office.scenarios.person.ShouldUpdatePersonData; import net.hostsharing.hsadminng.hs.office.scenarios.subscription.RemoveOperationsContactFromPartner; import net.hostsharing.hsadminng.hs.office.scenarios.subscription.SubscribeToMailinglist; @@ -585,4 +586,33 @@ class HsOfficeScenarioTests extends ScenarioTest { .doRun(); } } + + @Nested + @Order(60) + @TestMethodOrder(MethodOrderer.OrderAnnotation.class) + class PartnerDeceasedScenarios { + + @Test + @Order(6010) + @Requires("Partner: P-31011 - Michelle Matthieu") + @Produces("Partner-Relation: Erbengemeinschaft Michelle Matthieu") + void shouldReplaceDeceasedPartnerByCommunityOfHeirs() { + new ReplaceDeceasedPartnerWithCommunityOfHeirs(scenarioTest) + .given("partnerNumber", "P-31011") + .given("nameOfDeceasedPerson", "Michelle Matthieu") // FIXME: redundant + .given( + "communityOfHeirsPostalAddress", """ + "name": "Erbengemeinschaft Michelle Matthieu", // FIXME: automatic? + "co": "Lena Stadland", + "street": "Im Wischer", + "zipcode": "22987", + "city": "Hamburg", + "country": "Germany" + """) + .given("communityOfHeirsOfficePhoneNumber", "+49 40 666666") + .given("communityOfHeirsEmailAddress", "lena.stadland@example.org") + .doRun() + .keep(); + } + } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java new file mode 100644 index 00000000..de5b45b0 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/ReplaceDeceasedPartnerWithCommunityOfHeirs.java @@ -0,0 +1,84 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.partner; + +import io.restassured.http.ContentType; +import net.hostsharing.hsadminng.hs.scenarios.ScenarioTest; +import net.hostsharing.hsadminng.hs.scenarios.UseCase; +import org.springframework.http.HttpStatus; + +import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.OK; + +public class ReplaceDeceasedPartnerWithCommunityOfHeirs extends UseCase { + + public ReplaceDeceasedPartnerWithCommunityOfHeirs(final ScenarioTest testSuite) { + super(testSuite); + + } + + @Override + protected HttpResponse run() { + + obtain("Person: Hostsharing eG", () -> + httpGet("/api/hs/office/persons?name=Hostsharing+eG") + .expecting(OK).expecting(JSON), + response -> response.expectArrayElements(1).getFromBody("[0].uuid"), + "Even in production data we expect this query to return just a single result." // TODO.impl: add constraint? + ); + + obtain("Partner: deceased", () -> + httpGet("/api/hs/office/partners/%{partnerNumber}") + .expecting(OK).expecting(JSON), + response -> response.getFromBody("uuid"), + "Even in production data we expect this query to return just a single result." // TODO.impl: add constraint? + ); + + obtain("Person: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> + httpPost("/api/hs/office/persons", usingJsonBody(""" + { + "personType": "UNINCORPORATED_FIRM", + "tradeName": "Erbengemeinschaft %{nameOfDeceasedPerson}", + "givenName": ${givenName???}, + "familyName": ${familyName???} + } + """)) + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON) + ); + + obtain("Contact: Erbengemeinschaft %{nameOfDeceasedPerson}", () -> + httpPost("/api/hs/office/contacts", usingJsonBody(""" + { + "caption": "Erbengemeinschaft %{nameOfDeceasedPerson}", + "postalAddress": { + %{communityOfHeirsPostalAddress} + }, + "phoneNumbers": { + "office": ${communityOfHeirsOfficePhoneNumber} + }, + "emailAddresses": { + "main": ${communityOfHeirsEmailAddress} + } + } + """)) + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON) + ); + + return httpPost("/api/hs/office/relations", usingJsonBody(""" + { + "type": "PARTNER", + "anchor.uuid": ${Person: Hostsharing eG}, + "holder.uuid": ${Person: Erbengemeinschaft %{nameOfDeceasedPerson}}, + "contact.uuid": ${Contact: Erbengemeinschaft %{nameOfDeceasedPerson}} + } + """)) + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON); + } + + @Override + protected void verify(final UseCase.HttpResponse response) { + verify( + "Verify the New Partner Relation", + () -> httpGet("/api/hs/office/relations?relationType=PARTNER&contactData=Erbengemeinschaft%20&{nameOfDeceasedPerson}") + .expecting(OK).expecting(JSON).expectArrayElements(1) + ); + } +}