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