Compare commits

..

2 Commits

Author SHA1 Message Date
Michael Hoennig
f7661b25dd add shouldRemoveOperationsContactFromPartner 2024-10-24 13:34:20 +02:00
Michael Hoennig
6a28968521 add shouldAddOperationsContactToPartner 2024-10-24 11:04:04 +02:00
4 changed files with 110 additions and 6 deletions

View File

@ -7,10 +7,12 @@ 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.RemoveOperationsContactFromPartner;
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 +33,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 +52,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 +64,30 @@ 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(1039)
@Requires("Operations-Contact: Dennis Krause for Test AG")
void shouldRemoveOperationsContactFromPartner() {
new RemoveOperationsContactFromPartner(this)
.given("operationContactRelationUuid", "%{Operations-Contact: Dennis Krause for Test AG}")
.doRun();
}
@Test
@Order(1090)
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 net.hostsharing.hsadminng.hs.office.usecases.UseCase;
@ -27,7 +27,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
);
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}", () ->
httpPost("/api/hs/office/contacts", usingJsonBody("""

View File

@ -0,0 +1,20 @@
package net.hostsharing.hsadminng.hs.office.usecases.subscription;
import net.hostsharing.hsadminng.hs.office.usecases.UseCase;
import net.hostsharing.hsadminng.hs.office.usecases.UseCaseTest;
import static org.springframework.http.HttpStatus.NO_CONTENT;
public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperationsContactFromPartner> {
public RemoveOperationsContactFromPartner(final UseCaseTest testSuite) {
super(testSuite);
}
@Override
protected HttpResponse run() {
return httpDelete("/api/hs/office/relations/" + uuid("operationContactRelationUuid"))
.expecting(NO_CONTENT);
}
}