Search in sources :

Example 31 with FRAccountData

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));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 32 with FRAccountData

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));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 33 with FRAccountData

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;
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData)

Example 34 with FRAccountData

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));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 35 with FRAccountData

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));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Aggregations

FRAccountData (com.forgerock.openbanking.common.model.data.FRAccountData)43 Test (org.junit.Test)38 List (java.util.List)8 FRUserData (com.forgerock.openbanking.common.model.data.FRUserData)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 OBAccount6 (uk.org.openbanking.datamodel.account.OBAccount6)5 OBCashBalance1 (uk.org.openbanking.datamodel.account.OBCashBalance1)5 FRAccount (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount)3 FRCustomerInfo (com.forgerock.openbanking.common.model.data.FRCustomerInfo)2 FRFinancialAccount (com.forgerock.openbanking.common.model.openbanking.domain.account.FRFinancialAccount)1 FRPartyData (com.forgerock.openbanking.common.model.openbanking.domain.account.FRPartyData)1 FRPartyConverter.toFRPartyData (com.forgerock.openbanking.common.services.openbanking.converter.account.FRPartyConverter.toFRPartyData)1 Page (org.springframework.data.domain.Page)1