use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.
the class FRAccountIdentifierConverterTest method OBFundsConfirmationConsent1DataDebtorAccount_toFRAccountIdentifier.
@Test
public void OBFundsConfirmationConsent1DataDebtorAccount_toFRAccountIdentifier() {
// Given
OBFundsConfirmationConsent1DataDebtorAccount obFundsConfirmationConsent1DataDebtorAccount = new OBFundsConfirmationConsent1DataDebtorAccount();
obFundsConfirmationConsent1DataDebtorAccount.schemeName(this.schemeName).identification(this.identification).name(this.name).secondaryIdentification(this.secondaryIdentification);
// When
FRAccountIdentifier accountIdentifier = toFRAccountIdentifier(obFundsConfirmationConsent1DataDebtorAccount);
// Then
assertThat(accountIdentifier.getSchemeName()).isEqualTo(this.schemeName);
assertThat(accountIdentifier.getIdentification()).isEqualTo(this.identification);
assertThat(accountIdentifier.getName()).isEqualTo(this.name);
assertThat(accountIdentifier.getSecondaryIdentification()).isEqualTo(this.secondaryIdentification);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.
the class FRResponseDataRefundFactory method frInternationalResponseDataRefund.
/**
* Creates a {@link FRInternationalResponseDataRefund}, so long as the provided {@link FRReadRefundAccount} is
* set to 'Yes' and the initiation's debit account is null. Otherwise returns an empty {@link Optional}.
*
* @param frReadRefundAccount The {@link FRReadRefundAccount} indicating if a refund should be issued.
* @param initiation {@link FRDomesticDataInitiation} The payment's initiation data.
* @return The {@link Optional} {@link FRDomesticResponseDataRefund} instance.
*/
public static Optional<FRInternationalResponseDataRefund> frInternationalResponseDataRefund(FRReadRefundAccount frReadRefundAccount, FRInternationalDataInitiation initiation) {
if (hasRefund(frReadRefundAccount) && initiation.getDebtorAccount() != null) {
FRAccountIdentifier debtorAccount = initiation.getDebtorAccount();
FRFinancialCreditor creditor = initiation.getCreditor();
FRFinancialAgent creditorAgent = initiation.getCreditorAgent();
return Optional.of(FRInternationalResponseDataRefund.builder().account(FRAccountIdentifier.builder().schemeName(debtorAccount.getSchemeName()).identification(debtorAccount.getIdentification()).name(debtorAccount.getName()).secondaryIdentification(debtorAccount.getSecondaryIdentification()).build()).creditor(creditor == null ? null : FRFinancialCreditor.builder().name(creditor.getName()).postalAddress(creditor.getPostalAddress()).build()).agent(creditorAgent == null ? null : FRFinancialAgent.builder().schemeName(creditorAgent.getSchemeName()).identification(creditorAgent.getIdentification()).name(creditorAgent.getName()).postalAddress(creditorAgent.getPostalAddress()).build()).build());
}
return Optional.empty();
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_not_available.
@Test
public void getFundsConfirmation_not_available() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(false);
FRAccountIdentifier accountIdentifier = consent.getVrpDetails().getData().getInitiation().getDebtorAccount();
given(accountRepository.findByUserID(any())).willReturn(Collections.singletonList(FRAccount.builder().account(FRFinancialAccount.builder().accounts(Collections.singletonList(accountIdentifier)).build()).id("111").build()));
// When
HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(request).asObject(OBVRPFundsConfirmationResponse.class);
// Then
if (response.getParsingError().isPresent()) {
log.error("The response: {}", response);
log.error("Parsing error", response.getParsingError().get());
}
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
OBVRPFundsConfirmationRequestData requestData = request.getData();
assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
assertThat(responseData.getFundsConfirmationId()).isNotNull();
assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.NOTAVAILABLE);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_available.
@Test
public void getFundsConfirmation_available() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(true);
FRAccountIdentifier accountIdentifier = consent.getVrpDetails().getData().getInitiation().getDebtorAccount();
given(accountRepository.findByUserID(any())).willReturn(Collections.singletonList(FRAccount.builder().account(FRFinancialAccount.builder().accounts(Collections.singletonList(accountIdentifier)).build()).id("111").build()));
// When
HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(request).asObject(OBVRPFundsConfirmationResponse.class);
// Then
if (response.getParsingError().isPresent()) {
log.error("The response: {}", response);
log.error("Parsing error", response.getParsingError().get());
}
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
OBVRPFundsConfirmationRequestData requestData = request.getData();
assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
assertThat(responseData.getFundsConfirmationId()).isNotNull();
assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.AVAILABLE);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.
the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithOnlyMandatoryFields.
@Test
public void shouldReturnRequestedAccountWithOnlyMandatoryFields() 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);
consent.getInitiation().setCreditor(null);
consent.getInitiation().setCreditorAgent(null);
consent.getInitiation().setRemittanceInformation(null);
consent.getInitiation().setSupplementaryData(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));
}
Aggregations