add shouldAddOperationsContactToPartner

This commit is contained in:
Michael Hoennig 2024-10-24 11:04:04 +02:00
parent 49b2aec884
commit 6a28968521
3 changed files with 80 additions and 6 deletions

View File

@ -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.DeleteSepaMandataForDebitor;
import net.hostsharing.hsadminng.hs.office.usecases.debitor.InvalidateSepaMandateForDebitor; 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.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.partner.CreatePartner;
import net.hostsharing.hsadminng.hs.office.usecases.debitor.DeleteDebitor; 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.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.SubscribeToMailinglist;
import net.hostsharing.hsadminng.hs.office.usecases.subscription.UnsubscribeFromMailinglist; import net.hostsharing.hsadminng.hs.office.usecases.subscription.UnsubscribeFromMailinglist;
import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
@ -31,7 +32,7 @@ class HsOfficeUseCasesTest extends UseCaseTest {
@Test @Test
@Order(1010) @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() { void shouldCreatePartner() {
new CreatePartner(this) new CreatePartner(this)
.given("partnerNumber", 31010) .given("partnerNumber", 31010)
@ -50,8 +51,8 @@ class HsOfficeUseCasesTest extends UseCaseTest {
void shouldAddRepresentativeToPartner() { void shouldAddRepresentativeToPartner() {
new AddRepresentativeToPartner(this) new AddRepresentativeToPartner(this)
.given("partnerPersonUuid", "%{Person: Test AG}") .given("partnerPersonUuid", "%{Person: Test AG}")
.given("representativeFamilyName", "Tracy") .given("representativeFamilyName", "Trust")
.given("representativeGivenName", "Trust") .given("representativeGivenName", "Tracy")
.given("representativePostalAddress", """ .given("representativePostalAddress", """
An der Alster 100 An der Alster 100
20000 Hamburg 20000 Hamburg
@ -62,6 +63,21 @@ class HsOfficeUseCasesTest extends UseCaseTest {
.keep(); .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 @Test
@Order(1090) @Order(1090)
void shouldDeletePartner() { void shouldDeletePartner() {

View File

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

View File

@ -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 io.restassured.http.ContentType;
import net.hostsharing.hsadminng.hs.office.usecases.UseCase; import net.hostsharing.hsadminng.hs.office.usecases.UseCase;
@ -27,7 +27,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON) .expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
); );
printPara("Please check first if that person already exists, if so, use it's UUID below."); printPara("Please check first if that person already exists, if so, use it's UUID below.");
print("**HINT**: A representative is always a natural person and represents a non-natural-person."); printPara("**HINT**: A representative is always a natural person and represents a non-natural-person.");
keep("Contact: %{representativeGivenName} %{representativeFamilyName}", () -> keep("Contact: %{representativeGivenName} %{representativeFamilyName}", () ->
httpPost("/api/hs/office/contacts", usingJsonBody(""" httpPost("/api/hs/office/contacts", usingJsonBody("""