From 6a289685218d0eb4b70b72229093b0844e6229a4 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 24 Oct 2024 11:04:04 +0200 Subject: [PATCH] add shouldAddOperationsContactToPartner --- .../office/usecases/HsOfficeUseCasesTest.java | 24 ++++++-- .../AddOperationsContactToPartner.java | 58 +++++++++++++++++++ .../AddRepresentativeToPartner.java | 4 +- 3 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddOperationsContactToPartner.java rename src/test/java/net/hostsharing/hsadminng/hs/office/usecases/{subscription => partner}/AddRepresentativeToPartner.java (93%) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/HsOfficeUseCasesTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/HsOfficeUseCasesTest.java index 54532fe3..19943514 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/HsOfficeUseCasesTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/HsOfficeUseCasesTest.java @@ -7,10 +7,11 @@ import net.hostsharing.hsadminng.hs.office.usecases.debitor.CreateSepaMandataFor import net.hostsharing.hsadminng.hs.office.usecases.debitor.DeleteSepaMandataForDebitor; import net.hostsharing.hsadminng.hs.office.usecases.debitor.InvalidateSepaMandateForDebitor; import net.hostsharing.hsadminng.hs.office.usecases.membership.CreateMembership; +import net.hostsharing.hsadminng.hs.office.usecases.partner.AddOperationsContactToPartner; import net.hostsharing.hsadminng.hs.office.usecases.partner.CreatePartner; import net.hostsharing.hsadminng.hs.office.usecases.debitor.DeleteDebitor; import net.hostsharing.hsadminng.hs.office.usecases.partner.DeletePartner; -import net.hostsharing.hsadminng.hs.office.usecases.subscription.AddRepresentativeToPartner; +import net.hostsharing.hsadminng.hs.office.usecases.partner.AddRepresentativeToPartner; import net.hostsharing.hsadminng.hs.office.usecases.subscription.SubscribeToMailinglist; import net.hostsharing.hsadminng.hs.office.usecases.subscription.UnsubscribeFromMailinglist; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; @@ -31,7 +32,7 @@ class HsOfficeUseCasesTest extends UseCaseTest { @Test @Order(1010) - @Produces(explicitly = "Partner: Test AG", implicitly = "Person: Test AG") + @Produces(explicitly = "Partner: Test AG", implicitly = {"Person: Test AG", "Contact: Test AG - Board of Directors"}) void shouldCreatePartner() { new CreatePartner(this) .given("partnerNumber", 31010) @@ -50,8 +51,8 @@ class HsOfficeUseCasesTest extends UseCaseTest { void shouldAddRepresentativeToPartner() { new AddRepresentativeToPartner(this) .given("partnerPersonUuid", "%{Person: Test AG}") - .given("representativeFamilyName", "Tracy") - .given("representativeGivenName", "Trust") + .given("representativeFamilyName", "Trust") + .given("representativeGivenName", "Tracy") .given("representativePostalAddress", """ An der Alster 100 20000 Hamburg @@ -62,6 +63,21 @@ class HsOfficeUseCasesTest extends UseCaseTest { .keep(); } + @Test + @Order(1030) + @Requires("Person: Test AG") + @Produces("Operations-Contact: Dennis Krause for Test AG") + void shouldAddOperationsContactToPartner() { + new AddOperationsContactToPartner(this) + .given("partnerPersonUuid", "%{Person: Test AG}") + .given("operationsContactFamilyName", "Krause") + .given("operationsContactGivenName", "Dennis") + .given("operationsContactPhoneNumber", "+49 9932 587741") + .given("operationsContactEMailAddress", "dennis.krause@example.org") + .doRun() + .keep(); + } + @Test @Order(1090) void shouldDeletePartner() { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddOperationsContactToPartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddOperationsContactToPartner.java new file mode 100644 index 00000000..0b436027 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddOperationsContactToPartner.java @@ -0,0 +1,58 @@ +package net.hostsharing.hsadminng.hs.office.usecases.partner; + +import io.restassured.http.ContentType; +import net.hostsharing.hsadminng.hs.office.usecases.UseCase; +import net.hostsharing.hsadminng.hs.office.usecases.UseCaseTest; +import org.springframework.http.HttpStatus; + +import static io.restassured.http.ContentType.JSON; +import static org.springframework.http.HttpStatus.CREATED; + +public class AddOperationsContactToPartner extends UseCase { + + public AddOperationsContactToPartner(final UseCaseTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + keep("Person: %{operationsContactGivenName} %{operationsContactFamilyName}", () -> + httpPost("/api/hs/office/persons", usingJsonBody(""" + { + "personType": "NATURAL_PERSON", + "familyName": ${operationsContactFamilyName}, + "givenName": ${operationsContactGivenName} + } + """)) + .expecting(HttpStatus.CREATED).expecting(ContentType.JSON) + ); + printPara("Please check first if that person already exists, if so, use it's UUID below."); + printPara("**HINT**: operations contacts are always connected to a partner-person, thus a person which is a holder of a partner-relation."); + + keep("Contact: %{operationsContactGivenName} %{operationsContactFamilyName}", () -> + httpPost("/api/hs/office/contacts", usingJsonBody(""" + { + "caption": "%{operationsContactGivenName} %{operationsContactFamilyName}", + "phoneNumbers": { + "main": ${operationsContactPhoneNumber} + }, + "emailAddresses": { + "main": ${operationsContactEMailAddress} + } + } + """)) + .expecting(CREATED).expecting(JSON) + ); + printPara("Please check first if that contact already exists, if so, use it's UUID below."); + + return httpPost("/api/hs/office/relations", usingJsonBody(""" + { + "type": "OPERATIONS", + "anchorUuid": ${partnerPersonUuid}, + "holderUuid": ${Person: %{operationsContactGivenName} %{operationsContactFamilyName}}, + "contactUuid": ${Contact: %{operationsContactGivenName} %{operationsContactFamilyName}} + } + """)) + .expecting(CREATED).expecting(JSON); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/subscription/AddRepresentativeToPartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddRepresentativeToPartner.java similarity index 93% rename from src/test/java/net/hostsharing/hsadminng/hs/office/usecases/subscription/AddRepresentativeToPartner.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddRepresentativeToPartner.java index f09d55c4..2002f418 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/subscription/AddRepresentativeToPartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/usecases/partner/AddRepresentativeToPartner.java @@ -1,4 +1,4 @@ -package net.hostsharing.hsadminng.hs.office.usecases.subscription; +package net.hostsharing.hsadminng.hs.office.usecases.partner; import io.restassured.http.ContentType; import net.hostsharing.hsadminng.hs.office.usecases.UseCase; @@ -27,7 +27,7 @@ public class AddRepresentativeToPartner extends UseCase httpPost("/api/hs/office/contacts", usingJsonBody("""