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