Search in sources :

Example 16 with AccountWithBalance

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithNoCreditorAgent.

@Test
public void shouldReturnRequestedAccountWithNoCreditorAgent() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalConsent consent = JMockData.mock(FRInternationalConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    consent.getInitiation().setCreditorAgent(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, "user1", "c123", CLIENT_ID);
    // Then
    InternationalPaymentConsentDetails body = (InternationalPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts().size()).isEqualTo(1);
    assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 17 with AccountWithBalance

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalConsent consent = JMockData.mock(FRInternationalConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    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, "user1", "c123", CLIENT_ID);
    // Then
    InternationalPaymentConsentDetails body = (InternationalPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts().size()).isEqualTo(1);
    assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 18 with AccountWithBalance

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithNoExchangeRate.

@Test
public void shouldReturnRequestedAccountWithNoExchangeRate() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalConsent consent = JMockData.mock(FRInternationalConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    consent.getInitiation().setExchangeRateInformation(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, "user1", "c123", CLIENT_ID);
    // Then
    InternationalPaymentConsentDetails body = (InternationalPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    assertThat(body.getRate()).isNull();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts().size()).isEqualTo(1);
    assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 19 with AccountWithBalance

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithNoCreditor.

@Test
public void shouldReturnRequestedAccountWithNoCreditor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalConsent consent = JMockData.mock(FRInternationalConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    consent.getInitiation().setCreditor(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, "user1", "c123", CLIENT_ID);
    // Then
    InternationalPaymentConsentDetails body = (InternationalPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts().size()).isEqualTo(1);
    assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 20 with AccountWithBalance

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

the class RCSInternationalScheduledPaymentDetailsApiTest method shouldReturnAllAccountsWhenNoDebtor.

@Test
public void shouldReturnAllAccountsWhenNoDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalScheduledConsent consent = JMockData.mock(FRInternationalScheduledConsent.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
    InternationalSchedulePaymentConsentDetails body = (InternationalSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).isEqualTo(accounts);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) 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)

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