Search in sources :

Example 11 with AccountWithBalance

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance in project openbanking-aspsp by OpenBankingToolkit.

the class RCSInternationalScheduledPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalScheduledConsent consent = JMockData.mock(FRInternationalScheduledConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    InternationalSchedulePaymentConsentDetails body = (InternationalSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).contains(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) InternationalSchedulePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails) Test(org.junit.Test)

Example 12 with AccountWithBalance

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance in project openbanking-aspsp by OpenBankingToolkit.

the class RCSInternationalStandingOrderPaymentDetailsApiTest method shouldReturnAllAccountsWhenNoDebtor.

@Test
public void shouldReturnAllAccountsWhenNoDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<List<AccountWithBalance>>() {
    });
    FRInternationalStandingOrderConsent consent = JMockData.mock(FRInternationalStandingOrderConsent.class);
    consent.getInitiation().setDebtorAccount(null);
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    InternationalStandingOrderPaymentConsentDetails body = (InternationalStandingOrderPaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).isEqualTo(accounts);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent) List(java.util.List) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalStandingOrderPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalStandingOrderPaymentConsentDetails) Test(org.junit.Test)

Example 13 with AccountWithBalance

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance in project openbanking-aspsp by OpenBankingToolkit.

the class RCSDomesticPaymentDetailsApiTest method shouldReturnAllAccountsWhenNoDebtor.

@Test
public void shouldReturnAllAccountsWhenNoDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<List<AccountWithBalance>>() {
    });
    FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
    consent.getInitiation().setDebtorAccount(null);
    given(paymentService.getPayment(any())).willReturn(consent);
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(CLIENT_ID).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("abcd", accounts, "testuser", "c123", CLIENT_ID);
    // Then
    DomesticPaymentConsentDetails body = (DomesticPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).isEqualTo(accounts);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) List(java.util.List) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) DomesticPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails) Test(org.junit.Test)

Example 14 with AccountWithBalance

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance in project openbanking-aspsp by OpenBankingToolkit.

the class RCSDomesticSchedulePaymentDetailsApiTest method shouldReturnAllAccountsWhenNoDebtor.

@Test
public void shouldReturnAllAccountsWhenNoDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<List<AccountWithBalance>>() {
    });
    FRDomesticScheduledConsent consent = JMockData.mock(FRDomesticScheduledConsent.class);
    consent.getDomesticScheduledConsent().getData().getInitiation().setDebtorAccount(null);
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    DomesticSchedulePaymentConsentDetails body = (DomesticSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).isEqualTo(accounts);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) DomesticSchedulePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticSchedulePaymentConsentDetails) List(java.util.List) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) Test(org.junit.Test)

Example 15 with AccountWithBalance

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance in project openbanking-aspsp by OpenBankingToolkit.

the class RCSFilePaymentDetailsApiTest method validFilePayment_accountSpecifiedAndFound_createConsentDetailsWithAllAccounts.

@Test
public void validFilePayment_accountSpecifiedAndFound_createConsentDetailsWithAllAccounts() throws Exception {
    // Given
    List<AccountWithBalance> accounts = singletonList(DEBTOR_ACCOUNT);
    FRWriteFileDataInitiation validOBFileWithAccount = getValidOBFile().debtorAccount(FRAccountIdentifier.builder().identification("123").build()).build();
    FRWriteFileConsent frWriteFileConsent = FRWriteFileConsent.builder().data(FRWriteFileConsentData.builder().initiation(validOBFileWithAccount).build()).build();
    FRAmount amount = FRAmount.builder().currency("GBP").build();
    given(paymentService.getPayment(eq(CONSENT_ID))).willReturn(FRFileConsent.builder().id(CONSENT_ID).writeFileConsent(frWriteFileConsent).pispId(PISP_ID).pispName(PISP_NAME).payments(singletonList(FRFilePayment.builder().instructedAmount(amount).build())).build());
    givenTppExists();
    given(accountService.findAccountByIdentification(any(), any())).willReturn(Optional.of(DEBTOR_ACCOUNT));
    // When
    ResponseEntity response = rcsFilePaymentDetailsApi.consentDetails("", accounts, USERNAME, CONSENT_ID, CLIENT_ID);
    // Then
    assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    FilePaymentConsentDetails consentDetails = (FilePaymentConsentDetails) Objects.requireNonNull(response.getBody());
    assertThat(consentDetails.getAccounts()).isEqualTo(accounts);
    assertThat(consentDetails.getClientId()).isEqualTo(CLIENT_ID);
    assertThat(consentDetails.getNumberOfTransactions()).isEqualTo("19");
    assertThat(consentDetails.getMerchantName()).isEqualTo(PISP_NAME);
    verify(paymentService, times(1)).getPayment(any());
}
Also used : FilePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.FilePaymentConsentDetails) ResponseEntity(org.springframework.http.ResponseEntity) FRAmount(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount) FRWriteFileConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsent) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) FRWriteFileDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileDataInitiation) Test(org.junit.Test)

Aggregations

AccountWithBalance (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance)30 Test (org.junit.Test)20 ResponseEntity (org.springframework.http.ResponseEntity)20 FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)11 Tpp (com.forgerock.openbanking.model.Tpp)8 FRInternationalConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent)7 InternationalPaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails)7 List (java.util.List)5 FRRemittanceInformation (com.forgerock.openbanking.common.model.openbanking.domain.payment.common.FRRemittanceInformation)4 FRInternationalScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)4 FRWriteFileConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsent)3 FRWriteFileDataInitiation (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileDataInitiation)3 FRExchangeRateInformation (com.forgerock.openbanking.common.model.openbanking.domain.payment.common.FRExchangeRateInformation)3 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)3 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)3 FRDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent)3 FRInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent)3 InternationalSchedulePaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails)3 OBExchangeRate2 (uk.org.openbanking.datamodel.payment.OBExchangeRate2)3 FRAmount (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount)2