add scenario shouldCreateMembershipForPartner

This commit is contained in:
Michael Hoennig 2024-11-06 12:10:39 +01:00
parent 346912f1e6
commit 2a2b706e6d
13 changed files with 98 additions and 23 deletions

View File

@ -34,8 +34,8 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
public ResponseEntity<List<HsOfficeMembershipResource>> listMemberships(
final String currentSubject,
final String assumedRoles,
UUID partnerUuid,
Integer memberNumber) {
final UUID partnerUuid,
final Integer memberNumber) {
context.define(currentSubject, assumedRoles);
final var entities = ( memberNumber != null)

View File

@ -11,6 +11,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandateFo
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.FinallyDeleteSepaMandateForDebitor;
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor;
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.InvalidateSepaMandateForDebitor;
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CancelMembership;
import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership;
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner;
import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner;
@ -313,12 +314,26 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Test
@Order(4000)
@Requires("Partner: Test AG")
@Produces("Membership: Test AG 00")
void shouldCreateMembershipForPartner() {
new CreateMembership(this)
.given("partnerName", "Test AG")
.given("memberNumberSuffix", "00")
.given("validFrom", "2024-10-15")
.given("newStatus", "ACTIVE")
.given("membershipFeeBillable", "true")
.doRun()
.keep();
}
@Test
@Order(4900)
@Requires("Membership: Test AG 00")
void shouldCancelMembershipOfPartner() {
new CancelMembership(this)
.given("memberNumber", "3101000")
.given("validTo", "2025-12-30")
.given("newStatus", "CANCELLED")
.doRun();
}

View File

@ -86,13 +86,13 @@ public abstract class UseCase<T extends UseCase<?>> {
})
);
final var response = run();
verify();
verify(response);
return response;
}
protected abstract HttpResponse run();
protected void verify() {
protected void verify(final HttpResponse response) {
}
public final UseCase<T> given(final String propName, final Object propValue) {
@ -233,6 +233,7 @@ public abstract class UseCase<T extends UseCase<?>> {
@Getter
private final HttpStatus status;
@Getter
private UUID locationUuid;
@SneakyThrows

View File

@ -40,7 +40,7 @@ public class AddPhoneNumberToContactData extends UseCase<AddPhoneNumberToContact
}
@Override
protected void verify() {
protected void verify(final UseCase<AddPhoneNumberToContactData>.HttpResponse response) {
verify(
"Verify if the New Phone Number Got Added",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))

View File

@ -39,7 +39,7 @@ public class RemovePhoneNumberFromContactData extends UseCase<RemovePhoneNumberF
}
@Override
protected void verify() {
protected void verify(final UseCase<RemovePhoneNumberFromContactData>.HttpResponse response) {
verify(
"Verify if the New Phone Number Got Added",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))

View File

@ -57,7 +57,7 @@ public class ReplaceContactData extends UseCase<ReplaceContactData> {
}
@Override
protected void verify() {
protected void verify(final UseCase<ReplaceContactData>.HttpResponse response) {
verify(
"Verify if the Contact-Relation Got Replaced in the Partner-Relation",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))

View File

@ -0,0 +1,47 @@
package net.hostsharing.hsadminng.hs.office.scenarios.membership;
import io.restassured.http.ContentType;
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 CancelMembership extends UseCase<CancelMembership> {
public CancelMembership(final ScenarioTest testSuite) {
super(testSuite);
}
@Override
protected HttpResponse run() {
obtain("Membership: %{memberNumber}", () ->
httpGet("/api/hs/office/memberships?memberNumber=%{memberNumber}")
.expectArrayElements(1),
response -> response.expectArrayElements(1).getFromBody("[0].uuid")
);
return withTitle("Patch the New Status Into the Membership", () ->
httpPatch("/api/hs/office/memberships/%{Membership: %{memberNumber}}", usingJsonBody("""
{
"validTo": ${validTo},
"status": ${newStatus}
}
"""))
.expecting(HttpStatus.OK).expecting(ContentType.JSON)
);
}
@Override
protected void verify(final UseCase<CancelMembership>.HttpResponse response) {
verify(
"Verify That the Membership Got Created",
() -> httpGet("/api/hs/office/memberships/%{Membership: %{memberNumber}}")
.expecting(OK).expecting(JSON),
path("validTo").contains("%{validTo}"),
path("status").contains("CANCELLED")
);
}
}

View File

@ -5,6 +5,9 @@ import net.hostsharing.hsadminng.hs.office.scenarios.UseCase;
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
import org.springframework.http.HttpStatus;
import static io.restassured.http.ContentType.JSON;
import static org.springframework.http.HttpStatus.OK;
public class CreateMembership extends UseCase<CreateMembership> {
public CreateMembership(final ScenarioTest testSuite) {
@ -13,17 +16,26 @@ public class CreateMembership extends UseCase<CreateMembership> {
@Override
protected HttpResponse run() {
obtain("Membership: %{partnerName} 00", () ->
httpPost("/api/hs/office/memberships", usingJsonBody("""
return httpPost("/api/hs/office/memberships", usingJsonBody("""
{
"partnerUuid": ${Partner: Test AG},
"memberNumberSuffix": ${memberNumberSuffix},
"status": "ACTIVE",
"validFrom": ${validFrom},
"membershipFeeBillable": ${membershipFeeBillable}
}
"""))
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON)
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON);
}
@Override
protected void verify(final UseCase<CreateMembership>.HttpResponse response) {
verify(
"Verify That the Membership Got Created",
() -> httpGet("/api/hs/office/memberships/" + response.getLocationUuid())
.expecting(OK).expecting(JSON),
path("validFrom").contains("%{validFrom}"),
path("status").contains("ACTIVE")
);
return null;
}
}

View File

@ -66,7 +66,7 @@ public class AddOperationsContactToPartner extends UseCase<AddOperationsContactT
}
@Override
protected void verify() {
protected void verify(final UseCase<AddOperationsContactToPartner>.HttpResponse response) {
verify(
"Verify the New OPERATIONS Relation",
() -> httpGet("/api/hs/office/relations?relationType=OPERATIONS&personData=" + uriEncoded(

View File

@ -69,7 +69,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
}
@Override
protected void verify() {
protected void verify(final UseCase<AddRepresentativeToPartner>.HttpResponse response) {
verify(
"Verify the REPRESENTATIVE Relation Got Removed",
() -> httpGet("/api/hs/office/relations?relationType=REPRESENTATIVE&personData=" + uriEncoded("%{representativeFamilyName}"))

View File

@ -76,7 +76,7 @@ public class CreatePartner extends UseCase<CreatePartner> {
}
@Override
protected void verify() {
protected void verify(final UseCase<CreatePartner>.HttpResponse response) {
verify(
"Verify the New Partner Relation",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&contactData=&{contactCaption}")

View File

@ -37,7 +37,7 @@ public class ShouldUpdatePersonData extends UseCase<ShouldUpdatePersonData> {
}
@Override
protected void verify() {
protected void verify(final UseCase<ShouldUpdatePersonData>.HttpResponse response) {
verify(
"Verify that the Family Name Got Amended",
() -> httpGet("/api/hs/office/persons/%{personUuid}")

View File

@ -33,7 +33,7 @@ public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperations
}
@Override
protected void verify() {
protected void verify(final UseCase<RemoveOperationsContactFromPartner>.HttpResponse response) {
verify(
"Verify the New OPERATIONS Relation",
() -> httpGet("/api/hs/office/relations/&{Operations-Contact: %{operationsContactPerson}}")