Search in sources :

Example 1 with InternationalSchedulePaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails 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 2 with InternationalSchedulePaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails 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)

Example 3 with InternationalSchedulePaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails in project openbanking-aspsp by OpenBankingToolkit.

the class RCSInternationalScheduledPaymentDetailsApiTest method shouldReturnExchangeRate.

@Test
public void shouldReturnExchangeRate() 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()));
    FRExchangeRateInformation exchangeRateInformation = consent.getCalculatedExchangeRate();
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    InternationalSchedulePaymentConsentDetails body = (InternationalSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getRate()).isEqualTo(new OBExchangeRate2().exchangeRate(exchangeRateInformation.getExchangeRate()).rateType(toOBExchangeRateType2Code(exchangeRateInformation.getRateType())).contractIdentification(exchangeRateInformation.getContractIdentification()).unitCurrency(exchangeRateInformation.getUnitCurrency()));
}
Also used : OBExchangeRate2(uk.org.openbanking.datamodel.payment.OBExchangeRate2) 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) FRExchangeRateInformation(com.forgerock.openbanking.common.model.openbanking.domain.payment.common.FRExchangeRateInformation) Test(org.junit.Test)

Aggregations

AccountWithBalance (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance)3 FRInternationalScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)3 InternationalSchedulePaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails)3 Test (org.junit.Test)3 ResponseEntity (org.springframework.http.ResponseEntity)3 FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)2 FRExchangeRateInformation (com.forgerock.openbanking.common.model.openbanking.domain.payment.common.FRExchangeRateInformation)1 OBExchangeRate2 (uk.org.openbanking.datamodel.payment.OBExchangeRate2)1