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 9677120b..1817416b 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 @@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.office.scenarios; import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.hs.office.scenarios.contact.AmendContactData; +import net.hostsharing.hsadminng.hs.office.scenarios.contact.ReplaceContactData; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateExternalDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSelfDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandateForDebitor; @@ -44,19 +45,19 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1010) - @Produces(explicitly = "Partner: Test AG", implicitly = {"Person: Test AG", "Contact: Test AG - Board of Directors"}) + @Produces(explicitly = "Partner: Test AG", implicitly = {"Person: Test AG", "Contact: Test AG - Hamburg"}) void shouldCreateLegalPersonAsPartner() { new CreatePartner(this) .given("partnerNumber", 31010) .given("personType", "LEGAL_PERSON") .given("tradeName", "Test AG") - .given("contactCaption", "Test AG - Board of Directors") + .given("contactCaption", "Test AG - Hamburg") .given("postalAddress", """ Shanghai-Allee 1 20123 Hamburg """) .given("officePhoneNumber", "+49 40 654321-0") - .given("emailAddress", "board-of-directors@test-ag.example.org") + .given("emailAddress", "hamburg@test-ag.example.org") .doRun() .keep(); } @@ -144,9 +145,17 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(1101) + @Requires("Partner: Test AG") void shouldReplaceContactData() { - new UseCaseNotImplementedYet(this) - .given("partnerNumber", 31020) + new ReplaceContactData(this) + .given("partnerName", "Test AG") + .given("newContactCaption", "Test AG - Norden") + .given("newPostalAddress", """ + Am Hafen 11 + 26506 Norden + """) + .given("newOfficePhoneNumber", "+49 4931 654321-0") + .given("newEmailAddress", "norden@test-ag.example.org") .doRun(); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AmendContactData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AmendContactData.java index 49e611bb..0b265789 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AmendContactData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AmendContactData.java @@ -16,19 +16,19 @@ public class AmendContactData extends UseCase { @Override protected HttpResponse run() { - obtain("partnerPersonUuid", () -> + obtain("partnerContactuid", () -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) .expecting(OK).expecting(JSON), response -> response.expectArrayElements(1).getFromBody("[0].contact.uuid"), "In production data this query could result in multiple outputs. In that case, you have to find out which is the right one." ); - httpPatch("/api/hs/office/contacts/%{partnerPersonUuid}", usingJsonBody(""" + httpPatch("/api/hs/office/contacts/%{partnerContactuid}", usingJsonBody(""" { - "caption": ${contactCaption???}, - "postalAddress": ${postalAddress???}, + "caption": ${newContactCaption???}, + "postalAddress": ${newPostalAddress???}, "phoneNumbers": { - "office": ${officePhoneNumber???} + "office": ${newOfficePhoneNumber???} }, "emailAddresses": { "main": ${newEmailAddress???} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java new file mode 100644 index 00000000..4bfe91eb --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java @@ -0,0 +1,52 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.contact; + +import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; +import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; + +import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.OK; + +public class ReplaceContactData extends UseCase { + + public ReplaceContactData(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + + obtain("partnerRelationUuid", () -> + httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) + .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." + ); + + obtain("Contact: %{newContactCaption}", () -> + httpPost("/api/hs/office/contacts", usingJsonBody(""" + { + "caption": ${newContactCaption}, + "postalAddress": ${newPostalAddress???}, + "phoneNumbers": { + "phone": ${newOfficePhoneNumber???} + }, + "emailAddresses": { + "main": ${newEmailAddress???} + } + } + """)) + .expecting(CREATED).expecting(JSON), + "Please check first if that contact already exists, if so, use it's UUID below." + ); + + httpPatch("/api/hs/office/relations/%{partnerRelationUuid}", usingJsonBody(""" + { + "contactUuid": ${Contact: %{newContactCaption}} + } + """)) + .expecting(OK); + + return null; + } +}