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