From 922ff2e27f5cf02b05d109321352f604fe922523 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 30 Oct 2024 15:55:46 +0100 Subject: [PATCH] explicitly fetch SEPA-Mandate in FinallyDeleteSepaMandateForDebitor --- .../scenarios/HsOfficeScenarioTests.java | 8 ++--- .../debitor/DeleteSepaMandateForDebitor.java | 20 ------------ .../FinallyDeleteSepaMandateForDebitor.java | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+), 24 deletions(-) delete mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteSepaMandateForDebitor.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/FinallyDeleteSepaMandateForDebitor.java diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 6c727eb4..4178b65a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateExternalDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSelfDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandateForDebitor; -import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteSepaMandateForDebitor; +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.CreateMembership; @@ -202,9 +202,9 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(3109) @Requires("SEPA-Mandate: Test AG") - void shouldDeleteSepaMandateForDebitor() { - new DeleteSepaMandateForDebitor(this) - .given("sepaMandateUuid", "%{SEPA-Mandate: Test AG}") + void shouldFinallyDeleteSepaMandateForDebitor() { + new FinallyDeleteSepaMandateForDebitor(this) + .given("bankAccountIBAN", "DE02701500000000594937") .doRun(); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteSepaMandateForDebitor.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteSepaMandateForDebitor.java deleted file mode 100644 index e9470a4e..00000000 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/DeleteSepaMandateForDebitor.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.hostsharing.hsadminng.hs.office.scenarios.debitor; - -import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; -import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; -import org.springframework.http.HttpStatus; - - -public class DeleteSepaMandateForDebitor extends UseCase { - - public DeleteSepaMandateForDebitor(final ScenarioTest testSuite) { - super(testSuite); - } - - @Override - protected HttpResponse run() { - httpDelete("/api/hs/office/sepamandates/&{SEPA-Mandate: Test AG}") - .expecting(HttpStatus.NO_CONTENT); - return null; - } -} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/FinallyDeleteSepaMandateForDebitor.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/FinallyDeleteSepaMandateForDebitor.java new file mode 100644 index 00000000..c1a95677 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/debitor/FinallyDeleteSepaMandateForDebitor.java @@ -0,0 +1,31 @@ +package net.hostsharing.hsadminng.hs.office.scenarios.debitor; + +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 FinallyDeleteSepaMandateForDebitor extends UseCase { + + public FinallyDeleteSepaMandateForDebitor(final ScenarioTest testSuite) { + super(testSuite); + } + + @Override + protected HttpResponse run() { + + obtain("SEPA-Mandate: %{bankAccountIBAN}", () -> + httpGet("/api/hs/office/sepamandates?iban=&{bankAccountIBAN}") + .expecting(OK).expecting(JSON), + response -> response.expectArrayElements(1).getFromBody("[0].uuid"), + "With production data, the bank-account could be used in multiple SEPA-mandates, make sure to use the right one!" + ); + + // TODO.spec: When to allow actual deletion of SEPA-mandates? Add constraint accordingly. + httpDelete("/api/hs/office/sepamandates/&{SEPA-Mandate: %{bankAccountIBAN}}") + .expecting(HttpStatus.NO_CONTENT); + return null; + } +}