create new PARTNER relation for community of heirs

This commit is contained in:
Michael Hoennig 2024-12-06 15:56:07 +01:00
parent fc47cb0fce
commit 781fcef1d3
2 changed files with 114 additions and 0 deletions

View File

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

View File

@ -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<ReplaceDeceasedPartnerWithCommunityOfHeirs> {
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<ReplaceDeceasedPartnerWithCommunityOfHeirs>.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)
);
}
}