Search in sources :

Example 6 with Message

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());
}
Also used : ValidationException(org.mifos.platform.validations.ValidationException) Message(org.springframework.binding.message.Message) StubMessageContext(org.mifos.ui.validation.StubMessageContext) StubMessageContext(org.mifos.ui.validation.StubMessageContext) MessageContext(org.springframework.binding.message.MessageContext)

Example 7 with Message

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"));
}
Also used : Message(org.springframework.binding.message.Message) Test(org.junit.Test)

Example 8 with Message

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"));
}
Also used : Message(org.springframework.binding.message.Message) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Example 9 with Message

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"));
}
Also used : Message(org.springframework.binding.message.Message) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Example 10 with Message

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"));
}
Also used : Message(org.springframework.binding.message.Message) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Aggregations

Message (org.springframework.binding.message.Message)20 Test (org.junit.Test)16 MessageContext (org.springframework.binding.message.MessageContext)16 ArrayList (java.util.ArrayList)3 LocalDate (org.joda.time.LocalDate)2 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)2 BigDecimal (java.math.BigDecimal)1 DateTime (org.joda.time.DateTime)1 VariableInstallmentWithFeeValidationResult (org.mifos.clientportfolio.newloan.applicationservice.VariableInstallmentWithFeeValidationResult)1 ErrorEntry (org.mifos.platform.validations.ErrorEntry)1 ValidationException (org.mifos.platform.validations.ValidationException)1 StubMessageContext (org.mifos.ui.validation.StubMessageContext)1 StubValidationContext (org.mifos.ui.validation.StubValidationContext)1 MessageBuilder (org.springframework.binding.message.MessageBuilder)1 MessageCriteria (org.springframework.binding.message.MessageCriteria)1 ValidationContext (org.springframework.binding.validation.ValidationContext)1 Errors (org.springframework.validation.Errors)1 FieldError (org.springframework.validation.FieldError)1