From f2733b804abc464bbc6d572a8c1cf2a42369da09 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 30 Oct 2024 15:33:34 +0100 Subject: [PATCH] migrate name->iban in sepamandates API --- .../hs-office/hs-office-sepamandates.yaml | 2 +- ...ceSepaMandateControllerAcceptanceTest.java | 33 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml b/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml index 3050ab79..724d8ece 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml @@ -7,7 +7,7 @@ get: parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' - - name: name + - name: iban in: query required: false schema: diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java index 89b25f35..48ed0d9c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java @@ -8,7 +8,6 @@ import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountReposi import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; -import org.json.JSONException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; @@ -58,7 +57,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl class ListSepaMandates { @Test - void globalAdmin_canViewAllSepaMandates_ifNoCriteriaGiven() throws JSONException { + void globalAdmin_canViewAllSepaMandates_ifNoCriteriaGiven() { RestAssured // @formatter:off .given() @@ -97,6 +96,36 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl """)); // @formatter:on } + + @Test + void globalAdmin_canFindSepaMandateByName() { + + RestAssured // @formatter:off + .given() + .header("current-subject", "superuser-alex@hostsharing.net") + .port(port) + .when() + .get("http://localhost/api/hs/office/sepamandates?iban=DE02120300000000202051") + .then().log().all().assertThat() + .statusCode(200) + .contentType("application/json") + .log().all() + .body("", lenientlyEquals(""" + [ + { + "debitor": { "debitorNumber": 1000111 }, + "bankAccount": { + "iban": "DE02120300000000202051", + "holder": "First GmbH" + }, + "reference": "ref-10001-11", + "validFrom": "2022-10-01", + "validTo": "2026-12-31" + } + ] + """)); + // @formatter:on + } } @Nested