verify response body
This commit is contained in:
parent
12837212ca
commit
87dfec9efe
@ -147,16 +147,16 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
|
||||
}
|
||||
|
||||
final BiConsumer<HsOfficeCoopAssetsTransactionEntity, HsOfficeCoopAssetsTransactionResource> ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
||||
if (resource.getReversalAssetTx() != null) {
|
||||
if (entity.getReversalAssetTx() != null) {
|
||||
resource.getReversalAssetTx().setRevertedAssetTxUuid(entity.getUuid());
|
||||
}
|
||||
if (resource.getRevertedAssetTx() != null) {
|
||||
if (entity.getRevertedAssetTx() != null) {
|
||||
resource.getRevertedAssetTx().setReversalAssetTxUuid(entity.getUuid());
|
||||
}
|
||||
if (resource.getAdoptionAssetTx() != null) {
|
||||
if (entity.getAdoptionAssetTx() != null) {
|
||||
resource.getAdoptionAssetTx().setTransferAssetTxUuid(entity.getUuid());
|
||||
}
|
||||
if (resource.getTransferAssetTx() != null) {
|
||||
if (entity.getTransferAssetTx() != null) {
|
||||
resource.getTransferAssetTx().setAdoptionAssetTxUuid(entity.getUuid());
|
||||
}
|
||||
};
|
||||
@ -174,7 +174,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
|
||||
final var adoptingMembership = determineAdoptingMembership(resource);
|
||||
if (adoptingMembership != null) {
|
||||
final var adoptingAssetTx = coopAssetsTransactionRepo.save(createAdoptingAssetTx(entity, adoptingMembership));
|
||||
entity.setAssetAdoptionAssetTx(adoptingAssetTx);
|
||||
entity.setAdoptionAssetTx(adoptingAssetTx);
|
||||
}
|
||||
};
|
||||
|
||||
@ -223,7 +223,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse
|
||||
return HsOfficeCoopAssetsTransactionEntity.builder()
|
||||
.membership(adoptingMembership)
|
||||
.transactionType(HsOfficeCoopAssetsTransactionType.ADOPTION)
|
||||
.assetTransferTx(transferAssetTxEntity)
|
||||
.transferAssetTx(transferAssetTxEntity)
|
||||
.assetValue(transferAssetTxEntity.getAssetValue().negate())
|
||||
.comment(transferAssetTxEntity.getComment())
|
||||
.reference(transferAssetTxEntity.getReference())
|
||||
|
@ -52,8 +52,8 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getComment)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getRevertedAssetTx)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getReversalAssetTx)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetAdoptionAssetTx)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getAssetTransferTx)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getAdoptionAssetTx)
|
||||
.withProp(HsOfficeCoopAssetsTransactionEntity::getTransferAssetTx)
|
||||
.quotedValues(false);
|
||||
|
||||
@Id
|
||||
@ -109,11 +109,11 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, BaseE
|
||||
// Optionally, the UUID of the corresponding transaction for a transfer transaction.
|
||||
@OneToOne(cascade = CascadeType.PERSIST) // TODO.impl: can probably be removed after office data migration
|
||||
@JoinColumn(name = "assetadoptiontxuuid")
|
||||
private HsOfficeCoopAssetsTransactionEntity assetAdoptionAssetTx;
|
||||
private HsOfficeCoopAssetsTransactionEntity adoptionAssetTx;
|
||||
|
||||
// and the other way around
|
||||
@OneToOne(mappedBy = "assetAdoptionAssetTx")
|
||||
private HsOfficeCoopAssetsTransactionEntity assetTransferTx;
|
||||
@OneToOne(mappedBy = "adoptionAssetTx")
|
||||
private HsOfficeCoopAssetsTransactionEntity transferAssetTx;
|
||||
|
||||
@Override
|
||||
public HsOfficeCoopAssetsTransactionEntity load() {
|
||||
|
@ -900,7 +900,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
||||
.findAny()
|
||||
.orElseThrow(() -> new IllegalStateException(
|
||||
"cannot determine asset adoption entry for reversal " + assetTransaction));
|
||||
assetTransaction.setAssetAdoptionAssetTx(adoptionAssetTx);
|
||||
assetTransaction.setAdoptionAssetTx(adoptionAssetTx);
|
||||
//adoptionAssetTx.setAssetTransferTx(assetTransaction);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static net.hostsharing.hsadminng.rbac.test.JsonBuilder.jsonObject;
|
||||
import static net.hostsharing.hsadminng.rbac.test.JsonMatcher.lenientlyEquals;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
@ -183,23 +184,47 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
|
||||
.with("transactionType", "TRANSFER")
|
||||
.with("assetValue", -64.00)
|
||||
.with("adoptingMembership.memberNumber", AVAILABLE_MEMBER_NUMBER),
|
||||
"adoptingMembership.memberNumber='M-1234699' not found or not accessible"),
|
||||
"""
|
||||
{
|
||||
"transactionType": "TRANSFER",
|
||||
"assetValue": -64.00,
|
||||
"adoptionAssetTx": {
|
||||
"transactionType": "ADOPTION",
|
||||
"assetValue": 64.00
|
||||
},
|
||||
"reversalAssetTx": null,
|
||||
"transferAssetTx": null,
|
||||
"revertedAssetTx": null
|
||||
}
|
||||
"""),
|
||||
|
||||
ADOPTING_MEMBERSHIP_UUID_FOR_TRANSFER_MUST_BE_GIVEN_AND_AVAILABLE(
|
||||
requestBody -> requestBody
|
||||
.with("transactionType", "TRANSFER")
|
||||
.with("assetValue", -64.00)
|
||||
.with("adoptingMembership.uuid", AVAILABLE_MEMBERSHIP_UUID.toString()),
|
||||
"adoptingMembership.uuid='" + UNAVAILABLE_MEMBERSHIP_UUID + "' not found or not accessible");
|
||||
"""
|
||||
{
|
||||
"transactionType": "TRANSFER",
|
||||
"assetValue": -64.00,
|
||||
"adoptionAssetTx": {
|
||||
"transactionType": "ADOPTION",
|
||||
"assetValue": 64.00
|
||||
},
|
||||
"transferAssetTx": null,
|
||||
"revertedAssetTx": null,
|
||||
"reversalAssetTx": null
|
||||
}
|
||||
""");
|
||||
|
||||
private final Function<JsonBuilder, JsonBuilder> givenBodyTransformation;
|
||||
private final String expectedErrorMessage;
|
||||
private final String expectedResponseBody;
|
||||
|
||||
SuccessfullyCreatedTestCases(
|
||||
final Function<JsonBuilder, JsonBuilder> givenBodyTransformation,
|
||||
final String expectedErrorMessage) {
|
||||
final String expectedResponseBody) {
|
||||
this.givenBodyTransformation = givenBodyTransformation;
|
||||
this.expectedErrorMessage = expectedErrorMessage;
|
||||
this.expectedResponseBody = expectedResponseBody;
|
||||
}
|
||||
|
||||
String givenRequestBody() {
|
||||
@ -220,8 +245,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest {
|
||||
.accept(MediaType.APPLICATION_JSON))
|
||||
|
||||
// then
|
||||
//FIXME.andExpect(jsonPath("message", is("ERROR: [400] " + testCase.expectedErrorMessage)))
|
||||
//FIXME.andExpect(jsonPath("statusPhrase", is("Bad Request")))
|
||||
.andExpect(jsonPath("$", lenientlyEquals(testCase.expectedResponseBody)))
|
||||
.andExpect(status().is2xxSuccessful());
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class HsOfficeCoopAssetsTransactionEntityUnitTest {
|
||||
|
||||
@Test
|
||||
void toStringWithAdoptedAssetTxContainsRevertedAssetTx() {
|
||||
givenCoopAssetTransaction.setAssetAdoptionAssetTx(givenAdoptedCoopAssetTransaction);
|
||||
givenCoopAssetTransaction.setAdoptionAssetTx(givenAdoptedCoopAssetTransaction);
|
||||
|
||||
final var result = givenCoopAssetTransaction.toString();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user