use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.
the class DataCreatorTest method createBalancesShouldThrowExceptionForExceedingLimit.
@Test
public void createBalancesShouldThrowExceptionForExceedingLimit() {
// Given
String accountId = "1";
FRAccountData accountData = new FRAccountData().addBalance(new OBCashBalance1().accountId(accountId).type(OBBalanceType1Code.INTERIMAVAILABLE));
accountData.setAccount(new OBAccount6().accountId(accountId));
given(balanceRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
assertThatThrownBy(// When
() -> dataCreator.createBalances(accountData, Collections.singleton("1"))).satisfies(t -> assertThat(((ResponseStatusException) t).getStatus()).isEqualTo(HttpStatus.PAYLOAD_TOO_LARGE));
}
use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.
the class DataCreatorTest method createBeneficiariesShouldThrowExceptionForExceedingLimit.
@Test
public void createBeneficiariesShouldThrowExceptionForExceedingLimit() {
// Given
String accountId = "1";
FRAccountData accountData = new FRAccountData().addBeneficiary(new OBBeneficiary5().accountId(accountId));
accountData.setAccount(new OBAccount6().accountId(accountId));
given(beneficiaryRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
assertThatThrownBy(// When
() -> dataCreator.createBeneficiaries(accountData, Collections.singleton("1"))).satisfies(t -> assertThat(((ResponseStatusException) t).getStatus()).isEqualTo(HttpStatus.PAYLOAD_TOO_LARGE));
}
use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.
the class DataUpdaterTest method accountDataWithBalance.
private FRAccountData accountDataWithBalance(OBCashBalance1 balance) {
FRAccountData accountData = new FRAccountData();
accountData.setAccount(new OBAccount6().accountId(balance.getAccountId()));
accountData.setBalances(Collections.singletonList(balance));
return accountData;
}
use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.
the class DataUpdaterTest method updateBalance_balanceOfSameType_reject.
@Test
public void updateBalance_balanceOfSameType_reject() {
// Given
OBCashBalance1 interimAvailBalance = new OBCashBalance1().accountId("1").type(OBBalanceType1Code.INTERIMAVAILABLE);
FRBalance frBalance = FRBalance.builder().balance(toFRCashBalance(interimAvailBalance)).accountId(interimAvailBalance.getAccountId()).build();
given(balanceRepository.findByAccountIdAndBalanceType(any(), any())).willReturn(Optional.of(frBalance));
FRAccountData accountDataDiff = accountDataWithBalance(interimAvailBalance);
accountDataDiff.setBalances(Arrays.asList(interimAvailBalance, interimAvailBalance));
// When
assertThatThrownBy(() -> {
dataUpdater.updateBalances(accountDataDiff, Collections.emptySet());
}).satisfies(t -> assertThat(((ResponseStatusException) t).getStatus()).isEqualTo(HttpStatus.BAD_REQUEST));
}
use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.
the class DataUpdaterTest method updateTransactionsShouldAllowUpdatesWhenOnLimit.
@Test
public void updateTransactionsShouldAllowUpdatesWhenOnLimit() {
// Given
String accountId = "1";
OBTransaction6 transaction = new OBTransaction6().transactionId("2").accountId(accountId);
FRAccountData accountData = new FRAccountData().addTransaction(transaction);
accountData.setAccount(new OBAccount6().accountId(accountId));
given(transactionRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
FRTransaction existingTransaction = FRTransaction.builder().transaction(toFRTransactionData(transaction)).accountId(accountId).build();
given(transactionRepository.findById(transaction.getTransactionId())).willReturn(Optional.of(existingTransaction));
// When
dataUpdater.updateTransactions(accountData, Collections.singleton("1"));
// Then
verify(transactionRepository).saveAll(Collections.singletonList(existingTransaction));
}
Aggregations