Search in sources :

Example 6 with FRAccountIdentifier

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

the class RCSInternationalScheduledPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() 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()));
    // When
    ResponseEntity responseEntity = api.consentDetails("", accounts, "", "", clientId);
    // Then
    InternationalSchedulePaymentConsentDetails body = (InternationalSchedulePaymentConsentDetails) responseEntity.getBody();
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).contains(accounts.get(0));
}
Also used : 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) Test(org.junit.Test)

Example 7 with FRAccountIdentifier

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithNoCreditorAgent.

@Test
public void shouldReturnRequestedAccountWithNoCreditorAgent() 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().setCreditorAgent(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));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 8 with FRAccountIdentifier

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() 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());
    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));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 9 with FRAccountIdentifier

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithNoExchangeRate.

@Test
public void shouldReturnRequestedAccountWithNoExchangeRate() 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);
    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(body.getRate()).isNull();
    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) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) Test(org.junit.Test)

Example 10 with FRAccountIdentifier

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

the class RCSInternationalPaymentDetailsApiTest method shouldReturnRequestedAccountWithNoCreditor.

@Test
public void shouldReturnRequestedAccountWithNoCreditor() 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().setCreditor(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));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) InternationalPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.InternationalPaymentConsentDetails) 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