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());
}
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());
}
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());
}
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());
}
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
}
Aggregations