Search in sources :

Example 26 with FRAccountData

use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.

the class DataUpdaterTest method updateStandingOrdersShouldThrowExceptionForExceedingLimit.

@Test
public void updateStandingOrdersShouldThrowExceptionForExceedingLimit() {
    // Given
    String accountId = "1";
    FRAccountData accountData = new FRAccountData().addStandingOrder(new OBStandingOrder6().accountId(accountId));
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(standingOrderRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    assertThatThrownBy(// When
    () -> dataUpdater.updateStandingOrders(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 27 with FRAccountData

use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.

the class DataUpdaterTest method updateStatementsShouldThrowExceptionForExceedingLimit.

@Test
public void updateStatementsShouldThrowExceptionForExceedingLimit() {
    // Given
    String accountId = "1";
    FRAccountData accountData = new FRAccountData().addStatement(new OBStatement2().accountId(accountId));
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(statementRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    assertThatThrownBy(// When
    () -> dataUpdater.updateStatements(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 28 with FRAccountData

use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.

the class DataUpdaterTest method updateBalancesShouldThrowExceptionForExceedingLimit.

@Test
public void updateBalancesShouldThrowExceptionForExceedingLimit() {
    // 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
    () -> dataUpdater.updateBalances(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 29 with FRAccountData

use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.

the class DataUpdaterTest method updateBalancesShouldAllowUpdatesWhenOnLimit.

@Test
public void updateBalancesShouldAllowUpdatesWhenOnLimit() {
    // Given
    String accountId = "1";
    OBCashBalance1 cashBalance = new OBCashBalance1().accountId(accountId).type(OBBalanceType1Code.INTERIMAVAILABLE);
    FRAccountData accountData = new FRAccountData().addBalance(cashBalance);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(balanceRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    FRBalance existingBalance = FRBalance.builder().balance(toFRCashBalance(cashBalance)).build();
    given(balanceRepository.findByAccountIdAndBalanceType(accountId, FRBalanceType.INTERIMAVAILABLE)).willReturn(Optional.of(existingBalance));
    // When
    dataUpdater.updateBalances(accountData, Collections.singleton("1"));
    // Then
    verify(balanceRepository).saveAll(Collections.singletonList(existingBalance));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 30 with FRAccountData

use of com.forgerock.openbanking.common.model.data.FRAccountData in project openbanking-aspsp by OpenBankingToolkit.

the class DataUpdaterTest method updateDirectDebitsShouldThrowExceptionForExceedingLimit.

@Test
public void updateDirectDebitsShouldThrowExceptionForExceedingLimit() {
    // Given
    String accountId = "1";
    FRAccountData accountData = new FRAccountData().addDirectDebit(new OBReadDirectDebit2DataDirectDebit().accountId(accountId));
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(directDebitRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    assertThatThrownBy(// When
    () -> dataUpdater.updateDirectDebits(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)

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