From ce6981c7ca241dd9713ad537e427588f9b2cc2f9 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 15:10:50 +0100 Subject: [PATCH] add M- in front of memberNumber for related tests --- .../HsOfficeMembershipController.java | 5 +++-- .../hs-office/hs-office-memberships.yaml | 5 ++++- .../scenarios/HsOfficeScenarioTests.java | 20 +++++++++---------- .../CreateCoopAssetsRevertTransaction.java | 2 +- .../CreateCoopSharesRevertTransaction.java | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java index de8cc01a..a8add39a 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java @@ -17,6 +17,7 @@ import java.util.UUID; import java.util.function.BiConsumer; import static java.util.Optional.ofNullable; +import static net.hostsharing.hsadminng.repr.TaggedNumber.cropTag; @RestController @@ -37,11 +38,11 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { final String currentSubject, final String assumedRoles, final UUID partnerUuid, - final Integer memberNumber) { + final String memberNumber) { context.define(currentSubject, assumedRoles); final var entities = ( memberNumber != null) - ? ofNullable(membershipRepo.findMembershipByMemberNumber(memberNumber)).stream().toList() + ? ofNullable(membershipRepo.findMembershipByMemberNumber(cropTag("M-", memberNumber))).stream().toList() : membershipRepo.findMembershipsByOptionalPartnerUuid(partnerUuid); final var resources = mapper.mapList(entities, HsOfficeMembershipResource.class, diff --git a/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml b/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml index 8436134b..74093839 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-memberships.yaml @@ -19,7 +19,10 @@ get: in: query required: false schema: - type: integer + type: string + minLength: 9 + maxLength: 9 + pattern: 'M-[0-9]{7}' description: Member number, exclusive to `partnerUuid`. responses: "200": 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 ab5419ae..e5e47cf6 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 @@ -260,7 +260,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Person: Test AG") void shouldDeleteDebitor() { new DeleteDebitor(this) - .given("partnerNumber", 31020) + .given("partnerNumber", "P-31020") .given("debitorSuffix", "02") .doRun(); } @@ -271,7 +271,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Disabled("see TODO.spec in DontDeleteDefaultDebitor") void shouldNotDeleteDefaultDebitor() { new DontDeleteDefaultDebitor(this) - .given("partnerNumber", 31010) + .given("partnerNumber", "P-31010") .given("debitorSuffix", "00") .doRun(); } @@ -337,7 +337,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Shares SUBSCRIPTION Transaction") void shouldSubscribeCoopShares() { new CreateCoopSharesSubscriptionTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "sign 2024-01-15") .given("shareCount", 100) .given("comment", "Signing the Membership") @@ -350,7 +350,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Membership: M-3101000 - Test AG") void shouldRevertCoopSharesSubscription() { new CreateCoopSharesRevertTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("comment", "reverting some incorrect transaction") .given("dateOfIncorrectTransaction", "2024-02-15") .doRun(); @@ -362,7 +362,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Shares CANCELLATION Transaction") void shouldCancelCoopSharesSubscription() { new CreateCoopSharesCancellationTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "cancel 2024-01-15") .given("sharesToCancel", 8) .given("comment", "Cancelling 8 Shares") @@ -376,7 +376,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Assets DEPOSIT Transaction") void shouldSubscribeCoopAssets() { new CreateCoopAssetsDepositTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "sign 2024-01-15") .given("assetValue", 100*64) .given("comment", "disposal for initial shares") @@ -386,10 +386,10 @@ class HsOfficeScenarioTests extends ScenarioTest { @Test @Order(4302) - @Requires("Membership: M-3101000 - Test AG") + @Requires("Coop-Assets DEPOSIT Transaction") void shouldRevertCoopAssetsSubscription() { new CreateCoopAssetsRevertTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("comment", "reverting some incorrect transaction") .given("dateOfIncorrectTransaction", "2024-02-15") .doRun(); @@ -401,7 +401,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Produces("Coop-Assets DISBURSAL Transaction") void shouldDisburseCoopAssets() { new CreateCoopAssetsDisbursalTransaction(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("reference", "cancel 2024-01-15") .given("valueToDisburse", 8*64) .given("comment", "disbursal according to shares cancellation") @@ -414,7 +414,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Membership: M-3101000 - Test AG") void shouldCancelMembershipOfPartner() { new CancelMembership(this) - .given("memberNumber", "3101000") + .given("memberNumber", "M-3101000") .given("validTo", "2025-12-30") .given("newStatus", "CANCELLED") .doRun(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java index 0750847c..a83c21a2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopassets/CreateCoopAssetsRevertTransaction.java @@ -9,7 +9,7 @@ public class CreateCoopAssetsRevertTransaction extends CreateCoopAssetsTransacti requires("CoopAssets-Transaction with incorrect assetValue", alias -> new CreateCoopAssetsDepositTransaction(testSuite) - .given("memberNumber", "3101000") + .given("memberNumber", "%{memberNumber}") .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedAssetTx .given("assetValue", 10) .given("comment", "coop-assets deposit transaction with wrong asset value") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java index 03963834..8464393a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/membership/coopshares/CreateCoopSharesRevertTransaction.java @@ -9,7 +9,7 @@ public class CreateCoopSharesRevertTransaction extends CreateCoopSharesTransacti requires("CoopShares-Transaction with incorrect shareCount", alias -> new CreateCoopSharesSubscriptionTransaction(testSuite) - .given("memberNumber", "3101000") + .given("memberNumber", "%{memberNumber}") .given("reference", "sign %{dateOfIncorrectTransaction}") // same as revertedShareTx .given("shareCount", 100) .given("comment", "coop-shares subscription transaction with wrong share count")