implement coop-asset-TRANSFER-transaction reversal #125

Merged
hsh-michaelhoennig merged 7 commits from feature/implement-coop-asset-transaction-reversal into master 2024-11-28 07:10:36 +01:00
2 changed files with 8 additions and 6 deletions
Showing only changes of commit 7e3e48a23c - Show all commits

View File

@ -254,10 +254,6 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
if (resource.getTransactionType() == HsOfficeCoopAssetsTransactionTypeResource.TRANSFER) { if (resource.getTransactionType() == HsOfficeCoopAssetsTransactionTypeResource.TRANSFER) {
final var adoptingMembership = determineAdoptingMembership(resource); 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); final var adoptingAssetTx = createAdoptingAssetTx(entity, adoptingMembership);
entity.setAdoptionAssetTx(adoptingAssetTx); entity.setAdoptionAssetTx(adoptingAssetTx);
} }

View File

@ -53,7 +53,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
// set SINGLE_TEST_CASE_EXECUTION to true and make sure you do NOT EVER commit it to git! // 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 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 UUID UNAVAILABLE_MEMBERSHIP_UUID = TestUuidGenerator.use(0);
private static final String UNAVAILABLE_MEMBER_NUMBER = "M-1234699"; private static final String UNAVAILABLE_MEMBER_NUMBER = "M-1234699";
@ -512,6 +512,12 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
.with("adoptingMembership.memberNumber", UNAVAILABLE_MEMBER_NUMBER), .with("adoptingMembership.memberNumber", UNAVAILABLE_MEMBER_NUMBER),
"either adoptingMembership.uuid or adoptingMembership.memberNumber can be given, not both"), "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( REVERSAL_ASSET_TRANSACTION_REQUIRES_REVERTED_ASSET_TX_UUID(
requestBody -> requestBody requestBody -> requestBody
.with("transactionType", REVERSAL.name()) .with("transactionType", REVERSAL.name())
@ -594,7 +600,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
// - set SINGLE_TEST_CASE_EXECUTION to true - see above // - set SINGLE_TEST_CASE_EXECUTION to true - see above
// - select the test case enum value you want to run // - select the test case enum value you want to run
assumeThat(!SINGLE_TEST_CASE_EXECUTION || 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 // when
mockMvc.perform(MockMvcRequestBuilders mockMvc.perform(MockMvcRequestBuilders