From 7e3e48a23ce643f28248c60d9e617943783093f9 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 27 Nov 2024 19:29:37 +0100 Subject: [PATCH] add REST-test MEMBERSHIP_UUID_OR_MEMBER_NUMBER_MUST_BE_GIVEN und remove unreachable code --- .../HsOfficeCoopAssetsTransactionController.java | 4 ---- ...sOfficeCoopAssetsTransactionControllerRestTest.java | 10 ++++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index d3b99280..450e8cd1 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -254,10 +254,6 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse if (resource.getTransactionType() == HsOfficeCoopAssetsTransactionTypeResource.TRANSFER) { final var adoptingMembership = determineAdoptingMembership(resource); - if (adoptingMembership == null) { - throw new ValidationException( - "TRANSFER asset transaction requires adoptingMembership.uuid or adoptingMembership.memberNumber"); - } final var adoptingAssetTx = createAdoptingAssetTx(entity, adoptingMembership); entity.setAdoptionAssetTx(adoptingAssetTx); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index bd1a0698..c0ebfd00 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -53,7 +53,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { // set SINGLE_TEST_CASE_EXECUTION to true and make sure you do NOT EVER commit it to git! private static final boolean SINGLE_TEST_CASE_EXECUTION = false; - private static int DYNAMIC_UUID_START_INDEX = 13; + private static final int DYNAMIC_UUID_START_INDEX = 13; private static final UUID UNAVAILABLE_MEMBERSHIP_UUID = TestUuidGenerator.use(0); private static final String UNAVAILABLE_MEMBER_NUMBER = "M-1234699"; @@ -512,6 +512,12 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { .with("adoptingMembership.memberNumber", UNAVAILABLE_MEMBER_NUMBER), "either adoptingMembership.uuid or adoptingMembership.memberNumber can be given, not both"), + MEMBERSHIP_UUID_OR_MEMBER_NUMBER_MUST_BE_GIVEN( + requestBody -> requestBody + .with("transactionType", TRANSFER.name()) + .with("assetValue", "-128.00"), + "either adoptingMembership.uuid or adoptingMembership.memberNumber must be given for transactionType=TRANSFER"), + REVERSAL_ASSET_TRANSACTION_REQUIRES_REVERTED_ASSET_TX_UUID( requestBody -> requestBody .with("transactionType", REVERSAL.name()) @@ -594,7 +600,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { // - set SINGLE_TEST_CASE_EXECUTION to true - see above // - select the test case enum value you want to run assumeThat(!SINGLE_TEST_CASE_EXECUTION || - testCase == BadRequestTestCases.REVERSAL_ASSET_TRANSACTION_REQUIRES_REVERTED_ASSET_TX_UUID).isTrue(); + testCase == BadRequestTestCases.MEMBERSHIP_UUID_OR_MEMBER_NUMBER_MUST_BE_GIVEN).isTrue(); // when mockMvc.perform(MockMvcRequestBuilders