use of com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails in project openbanking-aspsp by OpenBankingToolkit.
the class RCSConsentDecisionApiControllerIT method getConsentDetailsForDomesticPayment.
@Test
public void getConsentDetailsForDomesticPayment() throws Exception {
// Given
FRWriteDomesticConsentData writeDomesticConsentData = FRWriteDomesticConsentData.builder().initiation(FRWriteDomesticDataInitiation.builder().build()).build();
FRDomesticConsent payment = FRDomesticConsent.builder().pispId(PISP_ID).pispName(PISP_NAME).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticConsent(FRWriteDomesticConsent.builder().data(writeDomesticConsentData).build()).build();
payment.getInitiation().setInstructedAmount(FRAmount.builder().build());
when(domesticPaymentService.getPayment(any())).thenReturn(payment);
String signedJwtEncoded = toEncodedSignedTestJwt("jwt/domesticPaymentConsentRequestPayload.json");
// When
HttpResponse<DomesticPaymentConsentDetails> response = Unirest.post("https://rs-rcs:" + port + "/api/rcs/consent/details/").header(OBHeaders.CONTENT_TYPE, CONTENT_TYPE_JWT).header("Cookie", MOCK_COOKIE).body(signedJwtEncoded).asObject(DomesticPaymentConsentDetails.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
DomesticPaymentConsentDetails resp = response.getBody();
assertThat(resp.getClientId()).isEqualTo(PISP_ID);
assertThat(resp.getUsername()).isEqualTo(USER_ID);
assertThat(resp.getIntentType()).isEqualTo(IntentType.PAYMENT_DOMESTIC_CONSENT);
assertThat(resp.getDecisionAPIUri()).isEqualTo(EXPECTED_DECISION_API_URI);
}
use of com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails 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.rcs.consentdetails.DomesticPaymentConsentDetails in project openbanking-aspsp by OpenBankingToolkit.
the class RCSDomesticPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.
@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException, JsonProcessingException {
// Given
List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
});
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
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
DomesticPaymentConsentDetails body = (DomesticPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.registerModule(new JodaModule());
mapper.setTimeZone(TimeZone.getDefault());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
String json = mapper.writeValueAsString(body);
log.info("Json Serialize as String \n{}", json);
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(body.getAccounts().size()).isEqualTo(1);
assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Aggregations