Search in sources :

Example 1 with OBWriteDomesticConsent2

use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2 in project openbanking-aspsp by OpenBankingToolkit.

the class PaymentsApiEndpointWrapperTest method validatePaymentCodeContext_no_validator.

@Test
public void validatePaymentCodeContext_no_validator() throws OBErrorException {
    // given
    expectedEx.expect(NullPointerException.class);
    expectedEx.expectMessage("validatePaymentCodeContext called but no validator present");
    OBWriteDomesticConsent2 consent = new OBWriteDomesticConsent2();
    // then
    getEndpointWrapper(null).validateRisk(consent.getRisk());
}
Also used : OBWriteDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2) Test(org.junit.Test)

Example 2 with OBWriteDomesticConsent2

use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2 in project openbanking-aspsp by OpenBankingToolkit.

the class PaymentsApiEndpointWrapperTest method validatePaymentCodeContext_throwsException.

@Test
public void validatePaymentCodeContext_throwsException() throws OBErrorException {
    // given
    expectedEx.expect(OBErrorException.class);
    expectedEx.expectMessage("The 'OBRisk1.PaymentCodeContext' field must be set and be valid");
    OBRisk1Validator riskValidator = new OBRisk1Validator(true);
    OBWriteDomesticConsent2 consent = new OBWriteDomesticConsent2();
    // then
    getEndpointWrapper(riskValidator).validateRisk(consent.getRisk());
}
Also used : OBRisk1Validator(com.forgerock.openbanking.aspsp.rs.api.payment.verifier.OBRisk1Validator) OBWriteDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2) Test(org.junit.Test)

Example 3 with OBWriteDomesticConsent2

use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2 in project openbanking-aspsp by OpenBankingToolkit.

the class BalanceTransferPaymentValidatorTest method validate_enabled_invalidBalanceTransfer_notRemittance_exception.

@Test
public void validate_enabled_invalidBalanceTransfer_notRemittance_exception() {
    // Given
    BalanceTransferPaymentValidator balanceTransferPaymentValidator = new BalanceTransferPaymentValidator(true);
    OBWriteDomesticConsent2 balanceTransferConsent = JMockData.mock(OBWriteDomesticConsent2.class);
    balanceTransferConsent.getData().getInitiation().localInstrument(LocalInstrument.UK_OBIE_BalanceTransfer.getNamespacedValue());
    balanceTransferConsent.getData().getInitiation().getCreditorAccount().schemeName(AccountSchemeName.UK_OBIE_PAN.getNamespacedValue());
    balanceTransferConsent.getData().getInitiation().getDebtorAccount().schemeName(AccountSchemeName.UK_OBIE_PAN.getNamespacedValue());
    balanceTransferConsent.getData().getInitiation().remittanceInformation(null);
    balanceTransferConsent.getRisk().paymentContextCode(OBExternalPaymentContext1Code.PARTYTOPARTY);
    // When
    assertThatThrownBy(() -> balanceTransferPaymentValidator.validate(balanceTransferConsent)).isInstanceOf(OBErrorException.class).hasMessage(OBRIErrorType.PAYMENT_BALANCE_TRANSFER_INVALID_REMITTANCE_REFERENCE.getMessage());
}
Also used : OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) OBWriteDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2) Test(org.junit.Test)

Example 4 with OBWriteDomesticConsent2

use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2 in project openbanking-aspsp by OpenBankingToolkit.

the class BalanceTransferPaymentValidatorTest method validate_enabled_invalidBalanceTransfer_wrongDebtorAccountType_exception.

@Test
public void validate_enabled_invalidBalanceTransfer_wrongDebtorAccountType_exception() {
    // Given
    BalanceTransferPaymentValidator balanceTransferPaymentValidator = new BalanceTransferPaymentValidator(true);
    OBWriteDomesticConsent2 balanceTransferConsent = JMockData.mock(OBWriteDomesticConsent2.class);
    balanceTransferConsent.getData().getInitiation().localInstrument(LocalInstrument.UK_OBIE_BalanceTransfer.getNamespacedValue());
    balanceTransferConsent.getData().getInitiation().getCreditorAccount().schemeName(AccountSchemeName.UK_OBIE_PAN.getNamespacedValue());
    // Debtor bank account not credit card - invalid
    balanceTransferConsent.getData().getInitiation().getDebtorAccount().schemeName("UK.OBIE.SortCodeAccountNumber");
    balanceTransferConsent.getData().getInitiation().getRemittanceInformation().reference("ref123");
    balanceTransferConsent.getRisk().paymentContextCode(OBExternalPaymentContext1Code.PARTYTOPARTY);
    // When
    assertThatThrownBy(() -> balanceTransferPaymentValidator.validate(balanceTransferConsent)).isInstanceOf(OBErrorException.class).hasMessage(OBRIErrorType.PAYMENT_BALANCE_TRANSFER_INVALID_DEBTOR_ACCOUNT.getMessage());
}
Also used : OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) OBWriteDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2) Test(org.junit.Test)

Example 5 with OBWriteDomesticConsent2

use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2 in project openbanking-aspsp by OpenBankingToolkit.

the class BalanceTransferPaymentValidatorTest method validate_disabled.

@Test
public void validate_disabled() throws Exception {
    // Given
    BalanceTransferPaymentValidator disabledBalanceTransferPaymentValidator = new BalanceTransferPaymentValidator(false);
    OBWriteDomesticConsent2 invalidConsent = new OBWriteDomesticConsent2().data(new OBWriteDataDomesticConsent2().initiation(new OBDomestic2().creditorAccount(new OBCashAccount3())));
    // When
    disabledBalanceTransferPaymentValidator.validate(invalidConsent);
// Then
// No exception because validation is disabled
}
Also used : OBWriteDataDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDataDomesticConsent2) OBWriteDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2) OBDomestic2(uk.org.openbanking.datamodel.payment.OBDomestic2) OBCashAccount3(uk.org.openbanking.datamodel.account.OBCashAccount3) Test(org.junit.Test)

Aggregations

OBWriteDomesticConsent2 (uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2)34 Test (org.junit.Test)31 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)18 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)3 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)3 DomesticPaymentService (com.forgerock.openbanking.common.services.store.payment.DomesticPaymentService)3 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)3 Principal (java.security.Principal)3 Collections (java.util.Collections)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 DateTime (org.joda.time.DateTime)3 HttpHeaders (org.springframework.http.HttpHeaders)3 ResponseEntity (org.springframework.http.ResponseEntity)3 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)3 Controller (org.springframework.stereotype.Controller)3 OBCashAccount3 (uk.org.openbanking.datamodel.account.OBCashAccount3)3 OBDomestic2 (uk.org.openbanking.datamodel.payment.OBDomestic2)3 OBWriteDataDomesticConsent2 (uk.org.openbanking.datamodel.payment.OBWriteDataDomesticConsent2)3