Search in sources :

Example 16 with FRAccountData

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

the class DataCreatorTest method createOffersShouldAllowCreateWhenOnLimit.

@Test
public void createOffersShouldAllowCreateWhenOnLimit() {
    // Given
    String accountId = "1";
    OBOffer1 offer = new OBOffer1().accountId(accountId).offerId("2");
    FRAccountData accountData = new FRAccountData().addOffer(offer);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(offerRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(999L);
    // When
    dataCreator.createOffers(accountData, Collections.singleton("1"));
    // Then
    ArgumentCaptor<List<FROffer>> argumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(offerRepository).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 17 with FRAccountData

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

the class DataCreatorTest method createStandingOrdersShouldThrowExceptionForExceedingLimit.

@Test
public void createStandingOrdersShouldThrowExceptionForExceedingLimit() {
    // 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
    () -> dataCreator.createStandingOrders(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 18 with FRAccountData

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

the class DataCreatorTest 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 19 with FRAccountData

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

the class DataUpdaterTest method updateScheduledPaymentsShouldAllowUpdatesWhenOnLimit.

@Test
public void updateScheduledPaymentsShouldAllowUpdatesWhenOnLimit() {
    // Given
    String accountId = "1";
    OBScheduledPayment3 scheduledPayment = new OBScheduledPayment3().accountId(accountId).scheduledPaymentId("2");
    FRAccountData accountData = new FRAccountData().addScheduledPayment(scheduledPayment);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(scheduledPaymentRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    FRScheduledPayment existingScheduledPayment = FRScheduledPayment.builder().scheduledPayment(toFRScheduledPaymentData(scheduledPayment)).accountId(accountId).build();
    given(scheduledPaymentRepository.findById(scheduledPayment.getScheduledPaymentId())).willReturn(Optional.of(existingScheduledPayment));
    // When
    dataUpdater.updateScheduledPayments(accountData, Collections.singleton("1"));
    // Then
    verify(scheduledPaymentRepository).saveAll(Collections.singletonList(existingScheduledPayment));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 20 with FRAccountData

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

the class DataUpdaterTest method updateOffersShouldThrowExceptionForExceedingLimit.

@Test
public void updateOffersShouldThrowExceptionForExceedingLimit() {
    // Given
    String accountId = "1";
    FRAccountData accountData = new FRAccountData().addOffer(new OBOffer1().accountId(accountId));
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(offerRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    assertThatThrownBy(// When
    () -> dataUpdater.updateOffers(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