use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData in project openbanking-aspsp by OpenBankingToolkit.
the class RCSFilePaymentDetailsApiTest method validFilePayment_noAccountSpecified_createConsentDetailsWithAllAccounts.
@Test
public void validFilePayment_noAccountSpecified_createConsentDetailsWithAllAccounts() throws Exception {
// Given
List<AccountWithBalance> accounts = singletonList(DEBTOR_ACCOUNT);
FRWriteFileConsentData data = FRWriteFileConsentData.builder().initiation(getValidOBFile().build()).build();
FRWriteFileConsent writeFileConsent = FRWriteFileConsent.builder().data(data).build();
FRAmount amount = FRAmount.builder().currency("GBP").build();
given(paymentService.getPayment(eq(CONSENT_ID))).willReturn(FRFileConsent.builder().id(CONSENT_ID).writeFileConsent(writeFileConsent).pispId(PISP_ID).pispName(PISP_NAME).payments(Arrays.asList(FRFilePayment.builder().instructedAmount(amount).build())).build());
givenTppExists();
// 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());
}
use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData in project openbanking-aspsp by OpenBankingToolkit.
the class RCSFilePaymentDetailsApiTest method validFilePayment_tppNotFound.
@Test
public void validFilePayment_tppNotFound() throws Exception {
// Given
FRWriteFileDataInitiation validOBFile = getValidOBFile().build();
FRWriteFileConsentData writeFileConsentData = FRWriteFileConsentData.builder().initiation(validOBFile).build();
given(paymentService.getPayment(eq(CONSENT_ID))).willReturn(FRFileConsent.builder().id(CONSENT_ID).writeFileConsent(FRWriteFileConsent.builder().data(writeFileConsentData).build()).pispId(PISP_ID).pispName(PISP_NAME).build());
given(tppStoreService.findById(any())).willReturn(Optional.empty());
// When
assertThatThrownBy(() -> rcsFilePaymentDetailsApi.consentDetails("", Collections.emptyList(), USERNAME, CONSENT_ID, CLIENT_ID)).isInstanceOf(OBErrorException.class).hasMessage("The TPP 'PISP1' that created this intent id 'PFC_123' doesn't exist anymore.");
}
use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData in project openbanking-aspsp by OpenBankingToolkit.
the class RCSFilePaymentDetailsApiTest method validFilePayment_wrongPisp.
@Test
public void validFilePayment_wrongPisp() throws Exception {
// Given
FRWriteFileDataInitiation validOBFile = getValidOBFile().build();
FRWriteFileConsentData writeFileConsentData = FRWriteFileConsentData.builder().initiation(validOBFile).build();
given(paymentService.getPayment(eq(CONSENT_ID))).willReturn(FRFileConsent.builder().id(CONSENT_ID).writeFileConsent(FRWriteFileConsent.builder().data(writeFileConsentData).build()).pispId(PISP_ID).pispName(PISP_NAME).build());
givenTppExists();
// When
assertThatThrownBy(() -> rcsFilePaymentDetailsApi.consentDetails("", Collections.emptyList(), USERNAME, CONSENT_ID, "Wrong Client Id")).isInstanceOf(OBErrorException.class).hasMessage("The PISP '" + CLIENT_ID + "' created the payment request '" + CONSENT_ID + "' but it's PISP 'Wrong Client Id' that is requesting consent for it.");
}
Aggregations