feature/use-case-acceptance-tests-3 (#119)
Co-authored-by: Michael Hoennig <michael@hoennig.de> Reviewed-on: #119 Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
This commit is contained in:
parent
6191bf16e0
commit
e97b177a92
@ -34,8 +34,8 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi {
|
|||||||
public ResponseEntity<List<HsOfficeMembershipResource>> listMemberships(
|
public ResponseEntity<List<HsOfficeMembershipResource>> listMemberships(
|
||||||
final String currentSubject,
|
final String currentSubject,
|
||||||
final String assumedRoles,
|
final String assumedRoles,
|
||||||
UUID partnerUuid,
|
final UUID partnerUuid,
|
||||||
Integer memberNumber) {
|
final Integer memberNumber) {
|
||||||
context.define(currentSubject, assumedRoles);
|
context.define(currentSubject, assumedRoles);
|
||||||
|
|
||||||
final var entities = ( memberNumber != null)
|
final var entities = ( memberNumber != null)
|
||||||
|
@ -11,12 +11,14 @@ 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.FinallyDeleteSepaMandateForDebitor;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor;
|
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.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.membership.CreateMembership;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddOperationsContactToPartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.partner.CreatePartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteDebitor;
|
import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteDebitor;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.partner.DeletePartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.partner.DeletePartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddRepresentativeToPartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.partner.AddRepresentativeToPartner;
|
||||||
|
import net.hostsharing.hsadminng.hs.office.scenarios.person.ShouldUpdatePersonData;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.subscription.RemoveOperationsContactFromPartner;
|
import net.hostsharing.hsadminng.hs.office.scenarios.subscription.RemoveOperationsContactFromPartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.subscription.SubscribeToMailinglist;
|
import net.hostsharing.hsadminng.hs.office.scenarios.subscription.SubscribeToMailinglist;
|
||||||
import net.hostsharing.hsadminng.hs.office.scenarios.subscription.UnsubscribeFromMailinglist;
|
import net.hostsharing.hsadminng.hs.office.scenarios.subscription.UnsubscribeFromMailinglist;
|
||||||
@ -197,6 +199,16 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
.doRun();
|
.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Order(1201)
|
||||||
|
@Requires("Partner: Michelle Matthieu")
|
||||||
|
void shouldUpdatePersonData() {
|
||||||
|
new ShouldUpdatePersonData(this)
|
||||||
|
.given("oldFamilyName", "Matthieu")
|
||||||
|
.given("newFamilyName", "Matthieu-Zhang")
|
||||||
|
.doRun();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2010)
|
@Order(2010)
|
||||||
@Requires("Partner: Test AG")
|
@Requires("Partner: Test AG")
|
||||||
@ -302,12 +314,26 @@ class HsOfficeScenarioTests extends ScenarioTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(4000)
|
@Order(4000)
|
||||||
@Requires("Partner: Test AG")
|
@Requires("Partner: Test AG")
|
||||||
|
@Produces("Membership: Test AG 00")
|
||||||
void shouldCreateMembershipForPartner() {
|
void shouldCreateMembershipForPartner() {
|
||||||
new CreateMembership(this)
|
new CreateMembership(this)
|
||||||
.given("partnerName", "Test AG")
|
.given("partnerName", "Test AG")
|
||||||
.given("memberNumberSuffix", "00")
|
.given("memberNumberSuffix", "00")
|
||||||
.given("validFrom", "2024-10-15")
|
.given("validFrom", "2024-10-15")
|
||||||
|
.given("newStatus", "ACTIVE")
|
||||||
.given("membershipFeeBillable", "true")
|
.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();
|
.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
final var response = run();
|
final var response = run();
|
||||||
verify();
|
verify(response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract HttpResponse run();
|
protected abstract HttpResponse run();
|
||||||
|
|
||||||
protected void verify() {
|
protected void verify(final HttpResponse response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final UseCase<T> given(final String propName, final Object propValue) {
|
public final UseCase<T> given(final String propName, final Object propValue) {
|
||||||
@ -233,6 +233,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
@Getter
|
@Getter
|
||||||
private final HttpStatus status;
|
private final HttpStatus status;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private UUID locationUuid;
|
private UUID locationUuid;
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ -40,7 +40,7 @@ public class AddPhoneNumberToContactData extends UseCase<AddPhoneNumberToContact
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<AddPhoneNumberToContactData>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify if the New Phone Number Got Added",
|
"Verify if the New Phone Number Got Added",
|
||||||
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
||||||
|
@ -39,7 +39,7 @@ public class RemovePhoneNumberFromContactData extends UseCase<RemovePhoneNumberF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<RemovePhoneNumberFromContactData>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify if the New Phone Number Got Added",
|
"Verify if the New Phone Number Got Added",
|
||||||
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
||||||
|
@ -57,7 +57,7 @@ public class ReplaceContactData extends UseCase<ReplaceContactData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<ReplaceContactData>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify if the Contact-Relation Got Replaced in the Partner-Relation",
|
"Verify if the Contact-Relation Got Replaced in the Partner-Relation",
|
||||||
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
||||||
|
@ -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 Cancelled",
|
||||||
|
() -> httpGet("/api/hs/office/memberships/%{Membership: %{memberNumber}}")
|
||||||
|
.expecting(OK).expecting(JSON),
|
||||||
|
path("validTo").contains("%{validTo}"),
|
||||||
|
path("status").contains("CANCELLED")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,9 @@ import net.hostsharing.hsadminng.hs.office.scenarios.UseCase;
|
|||||||
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
|
||||||
import org.springframework.http.HttpStatus;
|
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 class CreateMembership extends UseCase<CreateMembership> {
|
||||||
|
|
||||||
public CreateMembership(final ScenarioTest testSuite) {
|
public CreateMembership(final ScenarioTest testSuite) {
|
||||||
@ -13,17 +16,26 @@ public class CreateMembership extends UseCase<CreateMembership> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
obtain("Membership: %{partnerName} 00", () ->
|
return httpPost("/api/hs/office/memberships", usingJsonBody("""
|
||||||
httpPost("/api/hs/office/memberships", usingJsonBody("""
|
|
||||||
{
|
{
|
||||||
"partnerUuid": ${Partner: Test AG},
|
"partnerUuid": ${Partner: Test AG},
|
||||||
"memberNumberSuffix": ${memberNumberSuffix},
|
"memberNumberSuffix": ${memberNumberSuffix},
|
||||||
|
"status": "ACTIVE",
|
||||||
"validFrom": ${validFrom},
|
"validFrom": ${validFrom},
|
||||||
"membershipFeeBillable": ${membershipFeeBillable}
|
"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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class AddOperationsContactToPartner extends UseCase<AddOperationsContactT
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<AddOperationsContactToPartner>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify the New OPERATIONS Relation",
|
"Verify the New OPERATIONS Relation",
|
||||||
() -> httpGet("/api/hs/office/relations?relationType=OPERATIONS&personData=" + uriEncoded(
|
() -> httpGet("/api/hs/office/relations?relationType=OPERATIONS&personData=" + uriEncoded(
|
||||||
|
@ -69,7 +69,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<AddRepresentativeToPartner>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify the REPRESENTATIVE Relation Got Removed",
|
"Verify the REPRESENTATIVE Relation Got Removed",
|
||||||
() -> httpGet("/api/hs/office/relations?relationType=REPRESENTATIVE&personData=" + uriEncoded("%{representativeFamilyName}"))
|
() -> httpGet("/api/hs/office/relations?relationType=REPRESENTATIVE&personData=" + uriEncoded("%{representativeFamilyName}"))
|
||||||
|
@ -76,7 +76,7 @@ public class CreatePartner extends UseCase<CreatePartner> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<CreatePartner>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify the New Partner Relation",
|
"Verify the New Partner Relation",
|
||||||
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&contactData=&{contactCaption}")
|
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&contactData=&{contactCaption}")
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package net.hostsharing.hsadminng.hs.office.scenarios.person;
|
||||||
|
|
||||||
|
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 ShouldUpdatePersonData extends UseCase<ShouldUpdatePersonData> {
|
||||||
|
|
||||||
|
public ShouldUpdatePersonData(final ScenarioTest testSuite) {
|
||||||
|
super(testSuite);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected HttpResponse run() {
|
||||||
|
|
||||||
|
obtain(
|
||||||
|
"personUuid",
|
||||||
|
() -> httpGet("/api/hs/office/persons?name=" + uriEncoded("%{oldFamilyName}"))
|
||||||
|
.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."
|
||||||
|
);
|
||||||
|
|
||||||
|
withTitle("Patch the Additional Phone-Number into the Person", () ->
|
||||||
|
httpPatch("/api/hs/office/persons/%{personUuid}", usingJsonBody("""
|
||||||
|
{
|
||||||
|
"familyName": ${newFamilyName}
|
||||||
|
}
|
||||||
|
"""))
|
||||||
|
.expecting(HttpStatus.OK)
|
||||||
|
);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void verify(final UseCase<ShouldUpdatePersonData>.HttpResponse response) {
|
||||||
|
verify(
|
||||||
|
"Verify that the Family Name Got Amended",
|
||||||
|
() -> httpGet("/api/hs/office/persons/%{personUuid}")
|
||||||
|
.expecting(OK).expecting(JSON),
|
||||||
|
path("familyName").contains("%{newFamilyName}")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -33,7 +33,7 @@ public class RemoveOperationsContactFromPartner extends UseCase<RemoveOperations
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void verify() {
|
protected void verify(final UseCase<RemoveOperationsContactFromPartner>.HttpResponse response) {
|
||||||
verify(
|
verify(
|
||||||
"Verify the New OPERATIONS Relation",
|
"Verify the New OPERATIONS Relation",
|
||||||
() -> httpGet("/api/hs/office/relations/&{Operations-Contact: %{operationsContactPerson}}")
|
() -> httpGet("/api/hs/office/relations/&{Operations-Contact: %{operationsContactPerson}}")
|
||||||
|
Loading…
Reference in New Issue
Block a user