Search in sources :

Example 41 with FRAccountData

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

the class DataApiControllerIT method shouldReturnPayloadTooLargeWhenCreatingNewDataWithDataAlreadySaved.

@Test
public void shouldReturnPayloadTooLargeWhenCreatingNewDataWithDataAlreadySaved() throws Exception {
    // Given
    OBAccount6 account = new OBAccount6().accountId(UUID.randomUUID().toString());
    List<FRAccountData> accountDatas = Collections.singletonList(FRAccountData.builder().account(account).balances(Collections.singletonList(new OBCashBalance1().accountId(account.getAccountId()).type(OBBalanceType1Code.INTERIMAVAILABLE))).build());
    FRAccount savedAccount = frAccountRepository.save(FRAccount.builder().id(account.getAccountId()).userID(UUID.randomUUID().toString()).build());
    frBalanceRepository.save(FRBalance.builder().accountId(account.getAccountId()).build());
    FRUserData userData = new FRUserData();
    userData.setAccountDatas(accountDatas);
    userData.setUserName(savedAccount.getUserID());
    // When
    mockMvc.perform(post("/api/data/user").content(mapper.writeValueAsString(userData)).contentType("application/json")).andExpect(status().isPayloadTooLarge());
}
Also used : FRUserData(com.forgerock.openbanking.common.model.data.FRUserData) OBCashBalance1(uk.org.openbanking.datamodel.account.OBCashBalance1) FRAccount(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount) FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) OBAccount6(uk.org.openbanking.datamodel.account.OBAccount6) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 42 with FRAccountData

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

the class DataCreatorTest method createBalancesShouldAllowCreateWhenOnLimit.

@Test
public void createBalancesShouldAllowCreateWhenOnLimit() {
    // 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(999L);
    // When
    dataCreator.createBalances(accountData, Collections.singleton("1"));
    // Then
    ArgumentCaptor<List<FRBalance>> argumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(balanceRepository).saveAll(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().get(0).getAccountId()).isEqualTo(accountId);
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) List(java.util.List) Test(org.junit.Test)

Example 43 with FRAccountData

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

the class DataCreatorTest method createStandingOrdersShouldAllowCreateWhenOnLimit.

@Test
public void createStandingOrdersShouldAllowCreateWhenOnLimit() {
    // Given
    String accountId = "1";
    OBStandingOrder6 standingOrder = new OBStandingOrder6().accountId(accountId).standingOrderId("2");
    FRAccountData accountData = new FRAccountData().addStandingOrder(standingOrder);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(standingOrderRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(999L);
    // When
    dataCreator.createStandingOrders(accountData, Collections.singleton("1"));
    // Then
    ArgumentCaptor<List<FRStandingOrder>> argumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(standingOrderRepository).saveAll(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().get(0).getAccountId()).isEqualTo(accountId);
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) List(java.util.List) 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