add REST-tests:
- MEMBERSHIP_UUID_NOT_FOUND_OR_NOT_ACCESSIBLE - MEMBERSHIP_UUID_AND_MEMBER_NUMBER_MUST_NOT_BE_GIVEN_BOTH - REVERSAL_ASSET_TRANSACTION_REQUIRES_REVERTED_ASSET_TX_UUID
This commit is contained in:
parent
021c286c63
commit
c1cc9c1589
@ -217,7 +217,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
|
||||
final HsOfficeMembershipEntity membership = ofNullable(emw.find(
|
||||
HsOfficeMembershipEntity.class,
|
||||
resource.getMembershipUuid()))
|
||||
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] membership.uuid %s not found".formatted(
|
||||
.orElseThrow(() -> new EntityNotFoundException("membership.uuid %s not found".formatted(
|
||||
resource.getMembershipUuid())));
|
||||
entity.setMembership(membership);
|
||||
}
|
||||
@ -227,7 +227,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
|
||||
throw new ValidationException("REVERSAL asset transaction requires revertedAssetTx.uuid");
|
||||
}
|
||||
final var revertedAssetTx = coopAssetsTransactionRepo.findByUuid(resource.getRevertedAssetTxUuid())
|
||||
.orElseThrow(() -> new EntityNotFoundException("ERROR: [400] revertedAssetTx.uuid %s not found".formatted(
|
||||
.orElseThrow(() -> new EntityNotFoundException("revertedAssetTx.uuid %s not found".formatted(
|
||||
resource.getRevertedAssetTxUuid())));
|
||||
revertedAssetTx.setReversalAssetTx(entity);
|
||||
entity.setRevertedAssetTx(revertedAssetTx);
|
||||
@ -267,11 +267,11 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
|
||||
final var adoptingMembershipUuid = resource.getAdoptingMembershipUuid();
|
||||
final var adoptingMembershipMemberNumber = resource.getAdoptingMembershipMemberNumber();
|
||||
if (adoptingMembershipUuid != null && adoptingMembershipMemberNumber != null) {
|
||||
throw new IllegalArgumentException(
|
||||
throw new ValidationException(
|
||||
// @formatter:off
|
||||
resource.getTransactionType() == HsOfficeCoopAssetsTransactionTypeResource.TRANSFER
|
||||
? "[400] either adoptingMembership.uuid or adoptingMembership.memberNumber can be given, not both"
|
||||
: "[400] adoptingMembership.uuid and adoptingMembership.memberNumber must not be given for transactionType="
|
||||
? "either adoptingMembership.uuid or adoptingMembership.memberNumber can be given, not both"
|
||||
: "adoptingMembership.uuid and adoptingMembership.memberNumber must not be given for transactionType="
|
||||
+ resource.getTransactionType());
|
||||
// @formatter:on
|
||||
}
|
||||
|
@ -500,6 +500,24 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
|
||||
requestBody -> requestBody.without("membership.uuid"),
|
||||
"[membershipUuid must not be null but is \"null\"]"), // TODO.impl: should be membership.uuid, Spring validation-problem?
|
||||
|
||||
MEMBERSHIP_UUID_NOT_FOUND_OR_NOT_ACCESSIBLE(
|
||||
requestBody -> requestBody.with("membership.uuid", UNAVAILABLE_MEMBERSHIP_UUID.toString()),
|
||||
"membership.uuid " + UNAVAILABLE_MEMBERSHIP_UUID + " not found"),
|
||||
|
||||
MEMBERSHIP_UUID_AND_MEMBER_NUMBER_MUST_NOT_BE_GIVEN_BOTH(
|
||||
requestBody -> requestBody
|
||||
.with("transactionType", TRANSFER.name())
|
||||
.with("assetValue", "-128.00")
|
||||
.with("adoptingMembership.uuid", UNAVAILABLE_MEMBERSHIP_UUID.toString())
|
||||
.with("adoptingMembership.memberNumber", UNAVAILABLE_MEMBER_NUMBER),
|
||||
"either adoptingMembership.uuid or adoptingMembership.memberNumber can be given, not both"),
|
||||
|
||||
REVERSAL_ASSET_TRANSACTION_REQUIRES_REVERTED_ASSET_TX_UUID(
|
||||
requestBody -> requestBody
|
||||
.with("transactionType", REVERSAL.name())
|
||||
.with("assetValue", "-128.00"),
|
||||
"REVERSAL asset transaction requires revertedAssetTx.uuid"),
|
||||
|
||||
TRANSACTION_TYPE_MISSING(
|
||||
requestBody -> requestBody.without("transactionType"),
|
||||
"[transactionType must not be null but is \"null\"]"),
|
||||
@ -576,7 +594,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.ADOPTING_MEMBERSHIP_NUMBER_FOR_TRANSFER_MUST_BE_GIVEN_AND_AVAILABLE).isTrue();
|
||||
testCase == BadRequestTestCases.REVERSAL_ASSET_TRANSACTION_REQUIRES_REVERTED_ASSET_TX_UUID).isTrue();
|
||||
|
||||
// when
|
||||
mockMvc.perform(MockMvcRequestBuilders
|
||||
|
Loading…
Reference in New Issue
Block a user