use of org.mifos.ui.validation.StubValidationContext in project head by mifos.
the class LoanAccountFormBeanTest method setUp.
@Before
public void setUp() {
MifosBeanValidator validator = new MifosBeanValidator();
LocalValidatorFactoryBean targetValidator = new LocalValidatorFactoryBean();
targetValidator.afterPropertiesSet();
validator.setTargetValidator(targetValidator);
loanAccountFormBean = new LoanAccountFormBean();
Integer productId = Integer.valueOf(1);
Integer customerId = Integer.valueOf(1);
loanAccountFormBean.setProductId(productId);
loanAccountFormBean.setCustomerId(customerId);
loanAccountFormBean.setPurposeOfLoanMandatory(false);
loanAccountFormBean.setSourceOfFundsMandatory(false);
loanAccountFormBean.setExternalIdMandatory(false);
loanAccountFormBean.setCollateralTypeAndNotesHidden(false);
loanAccountFormBean.setAmount(Double.valueOf("1000.0"));
loanAccountFormBean.setMinAllowedAmount(Integer.valueOf(400));
loanAccountFormBean.setMaxAllowedAmount(Integer.valueOf(20000));
loanAccountFormBean.setInterestRate(Double.valueOf(10.0));
loanAccountFormBean.setMinAllowedInterestRate(Double.valueOf(1.0));
loanAccountFormBean.setMaxAllowedInterestRate(Double.valueOf(20.0));
loanAccountFormBean.setDigitsBeforeDecimalForInterest(10);
loanAccountFormBean.setDigitsAfterDecimalForInterest(5);
loanAccountFormBean.setDigitsBeforeDecimalForMonetaryAmounts(14);
loanAccountFormBean.setDigitsAfterDecimalForMonetaryAmounts(1);
loanAccountFormBean.setAdditionalFees(createAdditionalFeesMocks());
loanAccountFormBean.setDisbursementDateDD(24);
loanAccountFormBean.setDisbursementDateMM(02);
loanAccountFormBean.setDisbursementDateYY(2011);
loanAccountFormBean.setNumberOfInstallments(12);
loanAccountFormBean.setMinNumberOfInstallments(1);
loanAccountFormBean.setMaxNumberOfInstallments(12);
loanAccountFormBean.setValidator(validator);
loanAccountFormBean.setLoanDisbursementDateValidationServiceFacade(loanDisbursementDateValidationServiceFacade);
context = new StubValidationContext();
when(loanDisbursementDateValidationServiceFacade.validateLoanDisbursementDate((LocalDate) anyObject(), anyInt(), anyInt())).thenReturn(new Errors());
}
use of org.mifos.ui.validation.StubValidationContext in project head by mifos.
the class CreateSavingsAccountFormBeanTest method setUp.
@Before
public void setUp() {
MifosBeanValidator validator = new MifosBeanValidator();
LocalValidatorFactoryBean targetValidator = new LocalValidatorFactoryBean();
targetValidator.afterPropertiesSet();
validator.setTargetValidator(targetValidator);
formBean = new CreateSavingsAccountFormBean();
formBean.setValidator(validator);
questionnaireServiceFacade = mock(QuestionnaireServiceFacade.class);
formBean.setQuestionnaireServiceFascade(questionnaireServiceFacade);
configurationDto = new AccountingConfigurationDto();
configurationDto.setDigitsBeforeDecimal((short) 14);
configurationDto.setDigitsAfterDecimal((short) 1);
configurationServiceFacade = mock(ConfigurationServiceFacade.class);
when(configurationServiceFacade.getAccountingConfiguration()).thenReturn(configurationDto);
formBean.setConfigurationServiceFacade(configurationServiceFacade);
validationContext = new StubValidationContext();
validationException = new ValidationException("Root");
validationException.addChildException(new ValidationException("Child"));
}
use of org.mifos.ui.validation.StubValidationContext in project head by mifos.
the class FundTransferFormBeanTest method testDateValidation.
@Test
public void testDateValidation() {
FundTransferFormBean formBean = new FundTransferFormBean();
ValidationContext validationContext = new StubValidationContext();
formBean.setAmount(BigDecimal.ONE);
formBean.setSourceBalance(BigDecimal.ONE);
// invalid dates
formBean.setTrxnDateDD("Invalid");
formBean.setTrxnDateMM("10");
formBean.setTrxnDateYY("2012");
formBean.setReceiptDateDD("");
formBean.setReceiptDateMM("11");
formBean.setReceiptDateYY("2011");
formBean.validateEnterDetailsStep(validationContext);
assertEquals(validationContext.getMessageContext().getAllMessages().length, 2);
int i = 0;
for (Message msg : validationContext.getMessageContext().getAllMessages()) {
if (i == 0) {
assertEquals(msg.getSource(), "trxnDateDD");
} else if (i == 1) {
assertEquals(msg.getSource(), "receiptDateDD");
}
i++;
}
formBean.setTrxnDate(new LocalDate());
formBean.setReceiptDate(null);
validationContext.getMessageContext().clearMessages();
formBean.validateEnterDetailsStep(validationContext);
assertEquals(validationContext.getMessageContext().getAllMessages().length, 0);
}
use of org.mifos.ui.validation.StubValidationContext in project head by mifos.
the class FundTransferFormBeanTest method testAmountValidation.
@Test
public void testAmountValidation() {
FundTransferFormBean formBean = new FundTransferFormBean();
ValidationContext validationContext = new StubValidationContext();
formBean.setSourceBalance(new BigDecimal("100"));
formBean.setTrxnDate(new LocalDate());
// amount bigger then balance
formBean.setAmount(new BigDecimal("200"));
formBean.validateEnterDetailsStep(validationContext);
assertEquals(validationContext.getMessageContext().getAllMessages().length, 1);
// proper amount
formBean.setAmount(new BigDecimal("100"));
formBean.validateEnterDetailsStep(validationContext);
validationContext.getMessageContext().clearMessages();
assertEquals(validationContext.getMessageContext().getAllMessages().length, 0);
}
Aggregations