Search in sources :

Example 11 with FRAccountIdentifier

use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.

the class RCSInternationalScheduledPaymentDetailsApiTest method shouldReturnExchangeRate.

@Test
public void shouldReturnExchangeRate() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalScheduledConsent consent = JMockData.mock(FRInternationalScheduledConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    FRExchangeRateInformation exchangeRateInformation = consent.getCalculatedExchangeRate();
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    InternationalSchedulePaymentConsentDetails body = (InternationalSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getRate()).isEqualTo(new OBExchangeRate2().exchangeRate(exchangeRateInformation.getExchangeRate()).rateType(toOBExchangeRateType2Code(exchangeRateInformation.getRateType())).contractIdentification(exchangeRateInformation.getContractIdentification()).unitCurrency(exchangeRateInformation.getUnitCurrency()));
}
Also used : OBExchangeRate2(uk.org.openbanking.datamodel.payment.OBExchangeRate2) ResponseEntity(org.springframework.http.ResponseEntity) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) InternationalSchedulePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails) FRExchangeRateInformation(com.forgerock.openbanking.common.model.openbanking.domain.payment.common.FRExchangeRateInformation) Test(org.junit.Test)

Example 12 with FRAccountIdentifier

use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.

the class RCSInternationalStandingOrderPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRInternationalStandingOrderConsent consent = JMockData.mock(FRInternationalStandingOrderConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    InternationalStandingOrderPaymentConsentDetails body = (InternationalStandingOrderPaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).contains(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalStandingOrderPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalStandingOrderPaymentConsentDetails) Test(org.junit.Test)

Example 13 with FRAccountIdentifier

use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier 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));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) DomesticPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 14 with FRAccountIdentifier

use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.

the class RCSDomesticSchedulePaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRDomesticScheduledConsent consent = JMockData.mock(FRDomesticScheduledConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getDomesticScheduledConsent().getData().getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    DomesticSchedulePaymentConsentDetails body = (DomesticSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) DomesticSchedulePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticSchedulePaymentConsentDetails) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) Test(org.junit.Test)

Example 15 with FRAccountIdentifier

use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier in project openbanking-aspsp by OpenBankingToolkit.

the class RCSDomesticStandingOrderDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRDomesticStandingOrderConsent consent = JMockData.mock(FRDomesticStandingOrderConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    given(paymentService.getPayment("")).willReturn(consent);
    String clientId = "clientId";
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(clientId).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    DomesticStandingOrderPaymentConsentDetails body = (DomesticStandingOrderPaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).contains(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) DomesticStandingOrderPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticStandingOrderPaymentConsentDetails) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) Test(org.junit.Test)

Aggregations

FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)17 Test (org.junit.Test)15 AccountWithBalance (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance)11 ResponseEntity (org.springframework.http.ResponseEntity)11 FRInternationalConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent)5 InternationalPaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails)5 FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier (com.forgerock.openbanking.aspsp.rs.store.api.openbanking.testsupport.domain.FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier)2 FRInternationalScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)2 FRDomesticVRPConsent (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent)2 InternationalSchedulePaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalSchedulePaymentConsentDetails)2 FRAccountIdentifierConverter.toFRAccountIdentifier (com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toFRAccountIdentifier)2 FRAccountIdentifierConverter.toOBFundsConfirmationConsent1DataDebtorAccount (com.forgerock.openbanking.common.services.openbanking.converter.common.FRAccountIdentifierConverter.toOBFundsConfirmationConsent1DataDebtorAccount)2 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 OBFundsConfirmationConsent1DataDebtorAccount (uk.org.openbanking.datamodel.fund.OBFundsConfirmationConsent1DataDebtorAccount)2 OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest (uk.org.openbanking.testsupport.vrp.OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)1 FRExternalPermissionsCode (com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)1 FRFinancialAgent (com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialAgent)1