Search in sources :

Example 21 with FRAccountData

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

the class DataUpdaterTest method updateStatementsShouldAllowUpdatesWhenOnLimit.

@Test
public void updateStatementsShouldAllowUpdatesWhenOnLimit() {
    // Given
    String accountId = "1";
    OBStatement2 statement = new OBStatement2().accountId(accountId).statementId("2");
    FRAccountData accountData = new FRAccountData().addStatement(statement);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(statementRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    FRStatement existingStatement = FRStatement.builder().statement(toFRStatementData(statement)).accountId(accountId).build();
    given(statementRepository.findById(statement.getStatementId())).willReturn(Optional.of(existingStatement));
    // When
    dataUpdater.updateStatements(accountData, Collections.singleton("1"));
    // Then
    verify(statementRepository).saveAll(Collections.singletonList(existingStatement));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 22 with FRAccountData

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

the class DataUpdaterTest method updateBeneficiariesShouldAllowUpdatesWhenOnLimit.

@Test
public void updateBeneficiariesShouldAllowUpdatesWhenOnLimit() {
    // Given
    String accountId = "1";
    OBBeneficiary5 beneficiary = new OBBeneficiary5().beneficiaryId("2").accountId(accountId);
    FRAccountData accountData = new FRAccountData().addBeneficiary(beneficiary);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(beneficiaryRepository.countByAccountIdIn(Collections.singleton("1"))).willReturn(1000L);
    FRBeneficiary existingBeneficiary = FRBeneficiary.builder().beneficiary(toFRAccountBeneficiary(beneficiary)).accountId(accountId).build();
    given(beneficiaryRepository.findById(beneficiary.getBeneficiaryId())).willReturn(Optional.of(existingBeneficiary));
    // When
    dataUpdater.updateBeneficiaries(accountData, Collections.singleton("1"));
    // Then
    verify(beneficiaryRepository).saveAll(Collections.singletonList(existingBeneficiary));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 23 with FRAccountData

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

the class DataUpdaterTest method updateStandingOrdersShouldAllowUpdatesWhenOnLimit.

@Test
public void updateStandingOrdersShouldAllowUpdatesWhenOnLimit() {
    // 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(1000L);
    FRStandingOrder existingStandingOrder = FRStandingOrder.builder().standingOrder(toFRStandingOrderData(standingOrder)).accountId(accountId).build();
    given(standingOrderRepository.findById(standingOrder.getStandingOrderId())).willReturn(Optional.of(existingStandingOrder));
    // When
    dataUpdater.updateStandingOrders(accountData, Collections.singleton("1"));
    // Then
    verify(standingOrderRepository).saveAll(Collections.singletonList(existingStandingOrder));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 24 with FRAccountData

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

the class DataUpdaterTest method updateOffersShouldAllowUpdatesWhenOnLimit.

@Test
public void updateOffersShouldAllowUpdatesWhenOnLimit() {
    // 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(1000L);
    FROffer existingOffer = FROffer.builder().offer(toFROfferData(offer)).accountId(accountId).build();
    given(offerRepository.findById(offer.getOfferId())).willReturn(Optional.of(existingOffer));
    // When
    dataUpdater.updateOffers(accountData, Collections.singleton("1"));
    // Then
    verify(offerRepository).saveAll(Collections.singletonList(existingOffer));
}
Also used : FRAccountData(com.forgerock.openbanking.common.model.data.FRAccountData) Test(org.junit.Test)

Example 25 with FRAccountData

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

the class DataUpdaterTest method updateBeneficiariesShouldThrowExceptionForExceedingLimit.

@Test
public void updateBeneficiariesShouldThrowExceptionForExceedingLimit() {
    // 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
    () -> dataUpdater.updateBeneficiaries(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