Search in sources :

Example 1 with FilePaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.FilePaymentConsentDetails 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 FilePaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.FilePaymentConsentDetails 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());
}
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) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) FRWriteFileDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFileDataInitiation) Test(org.junit.Test)

Aggregations

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