Search in sources :

Example 1 with FRWriteFileConsentData

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());
}
Also used : FilePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.FilePaymentConsentDetails) ResponseEntity(org.springframework.http.ResponseEntity) FRAmount(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount) FRWriteFileConsent(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsent) FRWriteFileConsentData(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) Test(org.junit.Test)

Example 2 with FRWriteFileConsentData

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.");
}
Also used : FRWriteFileConsentData(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) FRWriteFileDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileDataInitiation) Test(org.junit.Test)

Example 3 with FRWriteFileConsentData

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.");
}
Also used : FRWriteFileConsentData(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) FRWriteFileDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileDataInitiation) Test(org.junit.Test)

Aggregations

FRWriteFileConsentData (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsentData)3 Test (org.junit.Test)3 FRWriteFileDataInitiation (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileDataInitiation)2 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)2 FRAmount (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount)1 FRWriteFileConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileConsent)1 AccountWithBalance (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance)1 FilePaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.FilePaymentConsentDetails)1 ResponseEntity (org.springframework.http.ResponseEntity)1