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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations