Search in sources :

Example 1 with MifosBeanValidator

use of org.mifos.platform.validation.MifosBeanValidator 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());
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Errors(org.mifos.platform.validations.Errors) MifosBeanValidator(org.mifos.platform.validation.MifosBeanValidator) StubValidationContext(org.mifos.ui.validation.StubValidationContext) Before(org.junit.Before)

Example 2 with MifosBeanValidator

use of org.mifos.platform.validation.MifosBeanValidator 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"));
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ValidationException(org.mifos.platform.validations.ValidationException) MifosBeanValidator(org.mifos.platform.validation.MifosBeanValidator) AccountingConfigurationDto(org.mifos.config.servicefacade.dto.AccountingConfigurationDto) StubValidationContext(org.mifos.ui.validation.StubValidationContext) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) ConfigurationServiceFacade(org.mifos.config.servicefacade.ConfigurationServiceFacade) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 MifosBeanValidator (org.mifos.platform.validation.MifosBeanValidator)2 StubValidationContext (org.mifos.ui.validation.StubValidationContext)2 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)2 ConfigurationServiceFacade (org.mifos.config.servicefacade.ConfigurationServiceFacade)1 AccountingConfigurationDto (org.mifos.config.servicefacade.dto.AccountingConfigurationDto)1 QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)1 Errors (org.mifos.platform.validations.Errors)1 ValidationException (org.mifos.platform.validations.ValidationException)1