use of org.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnAmountFieldWhenAmountViolatesAllowedRange.
@Test
public void shouldContainValidationMessageOnAmountFieldWhenAmountViolatesAllowedRange() {
// setup
loanAccountFormBean.setAmount(Double.valueOf("0.0"));
// exercise test
loanAccountFormBean.validateEnterAccountDetailsStep(context);
// verification
MessageContext messageContext = context.getMessageContext();
Message[] messages = messageContext.getAllMessages();
assertThat(messages.length, is(1));
Message message = messages[0];
assertThat(message.getSource().toString(), is("amount"));
assertThat(message.getText().toString(), containsString("loanAccountFormBean.Amount.invalid"));
}
use of org.springframework.binding.message.Message 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.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnNumberOfInstallmentsFieldWhenNumberOfInstallmentsViolatesAllowedRange.
@Test
public void shouldContainValidationMessageOnNumberOfInstallmentsFieldWhenNumberOfInstallmentsViolatesAllowedRange() {
// setup
loanAccountFormBean.setNumberOfInstallments(100);
// exercise test
loanAccountFormBean.validateEnterAccountDetailsStep(context);
// verification
MessageContext messageContext = context.getMessageContext();
Message[] messages = messageContext.getAllMessages();
assertThat(messages.length, is(1));
Message message = messages[0];
assertThat(message.getSource().toString(), is("numberOfInstallments"));
assertThat(message.getText().toString(), containsString("loanAccountFormBean.NumberOfInstallments.invalid"));
}
use of org.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnAdditionalInterestFeeWhenDigitsBeforeAreOutOfRange.
@Test
public void shouldContainValidationMessageOnAdditionalInterestFeeWhenDigitsBeforeAreOutOfRange() {
// setup
loanAccountFormBean.setSelectedFeeId(new Number[] { 1 });
loanAccountFormBean.setSelectedFeeAmount(new Number[] { 10000000000L });
// exercise test
loanAccountFormBean.validateEnterAccountDetailsStep(context);
// verification
Message[] messages = context.getMessageContext().getAllMessages();
assertThat(messages.length, is(1));
Message message = messages[0];
assertThat(message.getSource().toString(), is("selectedFeeId"));
assertThat(message.getText().toString(), containsString("loanAccountFormBean.additionalfees.amountOrRate.digits.before.decimal.invalid"));
}
use of org.springframework.binding.message.Message in project head by mifos.
the class CreateSavingsAccountFormBeanTest method validateAnswerQuestionGroupStepEmptyQuestionGroupShouldPass.
@Test
public void validateAnswerQuestionGroupStepEmptyQuestionGroupShouldPass() {
List<QuestionGroupDetail> questionGroups = new ArrayList<QuestionGroupDetail>();
formBean.setQuestionGroups(questionGroups);
formBean.validateAnswerQuestionGroupStep(validationContext);
MessageContext messageContext = validationContext.getMessageContext();
Message[] messages = messageContext.getAllMessages();
Assert.assertEquals(0, messages.length);
}
Aggregations