From 16538e2524c71494e25dad5ec89f31bd3ff1e22b Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 6 Nov 2024 10:10:56 +0100 Subject: [PATCH] add shouldUpdatePersonData --- .../scenarios/HsOfficeScenarioTests.java | 11 +++++ .../person/ShouldUpdatePersonData.java | 48 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/person/ShouldUpdatePersonData.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 0288ab9f..8d1fabb1 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 @@ -17,6 +17,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.partner.DeletePartner; import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddRepresentativeToPartner; +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; import net.hostsharing.hsadminng.hs.office.scenarios.subscription.UnsubscribeFromMailinglist; @@ -197,6 +198,16 @@ class HsOfficeScenarioTests extends ScenarioTest { .doRun(); } + @Test + @Order(1201) + @Requires("Partner: Michelle Matthieu") + void shouldUpdatePersonData() { + new ShouldUpdatePersonData(this) + .given("oldFamilyName", "Matthieu") + .given("newFamilyName", "Matthieu-Zhang") + .doRun(); + } + @Test @Order(2010) @Requires("Partner: Test AG") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/person/ShouldUpdatePersonData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/person/ShouldUpdatePersonData.java new file mode 100644 index 00000000..23fbf726 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/person/ShouldUpdatePersonData.java @@ -0,0 +1,48 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.person; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; +import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; +import org.springframework.http.HttpStatus; + +import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.OK; + +public class ShouldUpdatePersonData extends UseCase { + + public ShouldUpdatePersonData(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + + obtain( + "personUuid", + () -> httpGet("/api/hs/office/persons?name=" + uriEncoded("%{oldFamilyName}")) + .expecting(OK).expecting(JSON), + response -> response.expectArrayElements(1).getFromBody("[0].uuid"), + "In production, data this query could result in multiple outputs. In that case, you have to find out which is the right one." + ); + + withTitle("Patch the Additional Phone-Number into the Person", () -> + httpPatch("/api/hs/office/persons/%{personUuid}", usingJsonBody(""" + { + "familyName": ${newFamilyName} + } + """)) + .expecting(HttpStatus.OK) + ); + + return null; + } + + @Override + protected void verify() { + verify( + "Verify if the New Phone Number Got Added", + () -> httpGet("/api/hs/office/persons/%{personUuid}") + .expecting(OK).expecting(JSON), + path("familyName").contains("%{newFamilyName}") + ); + } +}