Search in sources :

Example 6 with FRAccountData

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

the class DataCreatorTest method createBeneficiariesShouldAllowCreateWhenOnLimit.

@Test
public void createBeneficiariesShouldAllowCreateWhenOnLimit() {
    // 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(accountId))).willReturn(999L);
    // When
    dataCreator.createBeneficiaries(accountData, Collections.singleton("1"));
    // Then
    ArgumentCaptor<List<FRBeneficiary>> argumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(beneficiaryRepository).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 7 with FRAccountData

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

the class DataCreatorTest method createTransactionsShouldAllowCreateWhenOnLimit.

@Test
public void createTransactionsShouldAllowCreateWhenOnLimit() {
    // Given
    String accountId = "1";
    OBTransaction6 transaction = new OBTransaction6().transactionId("2").accountId(accountId);
    FRAccountData accountData = new FRAccountData().addTransaction(transaction);
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(transactionRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(999L);
    // When
    dataCreator.createTransactions(accountData, Collections.singleton("1"));
    // Then
    ArgumentCaptor<List<FRTransaction>> argumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(transactionRepository).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 8 with FRAccountData

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

the class DataCreatorTest method createStatementsShouldThrowExceptionForExceedingLimit.

@Test
public void createStatementsShouldThrowExceptionForExceedingLimit() {
    // 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
    () -> dataCreator.createStatements(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 9 with FRAccountData

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

the class DataCreatorTest method createScheduledPaymentsShouldAllowCreateWhenOnLimit.

@Test
public void createScheduledPaymentsShouldAllowCreateWhenOnLimit() {
    // 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(999L);
    // When
    dataCreator.createScheduledPayments(accountData, Collections.singleton("1"));
    // Then
    ArgumentCaptor<List<FRScheduledPayment>> argumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(scheduledPaymentRepository).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 10 with FRAccountData

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

the class DataCreatorTest method createTransactionsShouldThrowExceptionForExceedingLimit.

@Test
public void createTransactionsShouldThrowExceptionForExceedingLimit() {
    // Given
    String accountId = "1";
    FRAccountData accountData = new FRAccountData().addTransaction(new OBTransaction6().accountId(accountId));
    accountData.setAccount(new OBAccount6().accountId(accountId));
    given(transactionRepository.countByAccountIdIn(Collections.singleton(accountId))).willReturn(1000L);
    assertThatThrownBy(// When
    () -> dataCreator.createTransactions(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