### Question:
SinglePaymentTypeValidatorImpl extends AbstractBodyValidatorImpl implements PaymentTypeValidator { void validateAccount(AccountReference accountReference, MessageError messageError, PaymentValidationConfig validationConfig) { ibanValidator.validate(accountReference.getIban(), messageError); if (StringUtils.isNotBlank(accountReference.getBban()) && !isValidBban(accountReference.getBban())) { errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_INVALID_FIELD, "BBAN")); } checkFieldForMaxLength(accountReference.getPan(), "PAN", validationConfig.getPan(), messageError); checkFieldForMaxLength(accountReference.getMaskedPan(), "Masked PAN", validationConfig.getMaskedPan(), messageError); checkFieldForMaxLength(accountReference.getMsisdn(), "MSISDN", validationConfig.getMsisdn(), messageError); } @Autowired  SinglePaymentTypeValidatorImpl(ErrorBuildingService errorBuildingService, Xs2aObjectMapper xs2aObjectMapper,
                                          PaymentMapper paymentMapper, AmountValidator amountValidator,
                                          IbanValidator ibanValidator); @Override PaymentType getPaymentType(); @Override MessageError validate(Object body, MessageError messageError, PaymentValidationConfig validationConfig);  }### Answer:
@Test void validateAccount_success() { validator.validateAccount(accountReference, messageError, validationConfig); assertTrue(messageError.getTppMessages().isEmpty()); }
@Test void validateAccount_iban_error() { accountReference.setIban("123"); validator.validateAccount(accountReference, messageError, validationConfig); assertEquals(MessageErrorCode.FORMAT_ERROR_INVALID_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new Object[]{"IBAN"}, messageError.getTppMessage().getTextParameters()); }
@Test void validateAccount_bban_error() { accountReference.setBban("123"); validator.validateAccount(accountReference, messageError, validationConfig); assertEquals(MessageErrorCode.FORMAT_ERROR_INVALID_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new Object[]{"BBAN"}, messageError.getTppMessage().getTextParameters()); }
@Test void doValidation_pan_tooLong_error() { accountReference.setPan(VALUE_36_LENGHT); validator.validateAccount(accountReference, messageError, validationConfig); assertEquals(MessageErrorCode.FORMAT_ERROR_OVERSIZE_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new Object[]{"PAN", 35}, messageError.getTppMessage().getTextParameters()); }
@Test void doValidation_maskedPan_tooLong_error() { accountReference.setMaskedPan(VALUE_36_LENGHT); validator.validateAccount(accountReference, messageError, validationConfig); assertEquals(MessageErrorCode.FORMAT_ERROR_OVERSIZE_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new Object[]{"Masked PAN", 35}, messageError.getTppMessage().getTextParameters()); }
@Test void doValidation_Msisdn_tooLong_error() { accountReference.setMsisdn(VALUE_36_LENGHT); validator.validateAccount(accountReference, messageError, validationConfig); assertEquals(MessageErrorCode.FORMAT_ERROR_OVERSIZE_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new Object[]{"MSISDN", 35}, messageError.getTppMessage().getTextParameters()); }