use of org.springframework.binding.message.Message in project head by mifos.
the class ValidationExceptionMessageExtractorTest method testBadNumericResponseException.
private void testBadNumericResponseException(BadNumericResponseException e, String expectedMessage) {
ValidationException parent = new ValidationException("Key");
parent.addChildException(e);
ValidationExceptionMessageExtractor extractor = new ValidationExceptionMessageExtractor();
MessageContext context = new StubMessageContext();
extractor.extract(context, parent);
Message[] messages = context.getAllMessages();
Assert.assertEquals(1, messages.length);
Message m = messages[0];
Assert.assertEquals(expectedMessage, m.getText());
}
use of org.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnAdditionalInterestFeeWhenDigitsAfterSeparatorAreOutOfRange.
@Test
public void shouldContainValidationMessageOnAdditionalInterestFeeWhenDigitsAfterSeparatorAreOutOfRange() {
// setup
loanAccountFormBean.setSelectedFeeId(new Number[] { 1 });
loanAccountFormBean.setSelectedFeeAmount(new Number[] { 10.000001 });
// 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.after.decimal.invalid"));
}
use of org.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnInterestRateFieldWhenInterestRateViolatesAllowedRange.
@Test
public void shouldContainValidationMessageOnInterestRateFieldWhenInterestRateViolatesAllowedRange() {
// setup
loanAccountFormBean.setInterestRate(200);
// 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("interestRate"));
assertThat(message.getText().toString(), containsString("loanAccountFormBean.InterestRate.invalid"));
}
use of org.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnLoanPurposeFieldWhenFieldIsMandatoryAndNotSelected.
@Test
public void shouldContainValidationMessageOnLoanPurposeFieldWhenFieldIsMandatoryAndNotSelected() {
// setup
loanAccountFormBean.setPurposeOfLoanMandatory(true);
loanAccountFormBean.setLoanPurposeId(null);
// 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("loanPurposeId"));
assertThat(message.getText().toString(), containsString("loanAccountFormBean.PurposeOfLoan.invalid"));
}
use of org.springframework.binding.message.Message in project head by mifos.
the class LoanAccountFormBeanTest method shouldContainValidationMessageOnDisbursementDateDayFieldWhenDateIsInvalid.
@Test
public void shouldContainValidationMessageOnDisbursementDateDayFieldWhenDateIsInvalid() {
// setup
loanAccountFormBean.setDisbursementDateDD(32);
loanAccountFormBean.setDisbursementDateMM(1);
loanAccountFormBean.setDisbursementDateYY(2011);
// 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("disbursementDateDD"));
assertThat(message.getText().toString(), containsString("loanAccountFormBean.DisbursalDate.invalid"));
}
Aggregations