Search in sources :

Example 16 with MessageContext

use of org.springframework.binding.message.MessageContext in project head by mifos.

the class CustomerSearchFormBean method validateCustomerSearchStep.

/**
     * Validation method that Spring webflow calls on state transition out of
     * customerSearchStep.
     */
public void validateCustomerSearchStep(ValidationContext context) {
    MessageContext messages = context.getMessageContext();
    validator.validate(this, messages);
}
Also used : MessageContext(org.springframework.binding.message.MessageContext)

Example 17 with MessageContext

use of org.springframework.binding.message.MessageContext in project head by mifos.

the class CustomizedTextSelectFormBean method validateSelectCustomizedTextStep.

/**
     * Validation method that Spring webflow calls on state transition out of
     * customerSearchStep.
     */
public void validateSelectCustomizedTextStep(ValidationContext context) {
    MessageContext messages = context.getMessageContext();
    if (context.getUserEvent().equals("add")) {
        return;
    }
    validator.validate(this, messages);
}
Also used : MessageContext(org.springframework.binding.message.MessageContext)

Example 18 with MessageContext

use of org.springframework.binding.message.MessageContext in project head by mifos.

the class LoanAccountFormBeanTest method shouldContainValidationMessageOnSourceOfFundsFieldWhenFieldIsMandatoryAndNotSelected.

@Test
public void shouldContainValidationMessageOnSourceOfFundsFieldWhenFieldIsMandatoryAndNotSelected() {
    // setup
    loanAccountFormBean.setSourceOfFundsMandatory(true);
    loanAccountFormBean.setFundId(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("fundId"));
    assertThat(message.getText().toString(), containsString("loanAccountFormBean.SourceOfFunds.invalid"));
}
Also used : Message(org.springframework.binding.message.Message) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Example 19 with MessageContext

use of org.springframework.binding.message.MessageContext in project head by mifos.

the class CreateSavingsAccountFormBeanTest method validateCustomerSearchStepEmptySearchStringShouldFail.

@Test
public void validateCustomerSearchStepEmptySearchStringShouldFail() {
    formBean.validateCustomerSearchStep(validationContext);
    MessageContext messageContext = validationContext.getMessageContext();
    Message[] messages = messageContext.getAllMessages();
    Assert.assertEquals(1, messages.length);
    Message message = messages[0];
    Assert.assertEquals("searchString", message.getSource());
    verifyErrorMessage(NotEmpty.class, message);
}
Also used : Message(org.springframework.binding.message.Message) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Example 20 with MessageContext

use of org.springframework.binding.message.MessageContext in project head by mifos.

the class CreateSavingsAccountFormBeanTest method validateAnswerQuestionGroupStepMissingMandatoryResponseShouldFail.

@Test
public void validateAnswerQuestionGroupStepMissingMandatoryResponseShouldFail() {
    List<QuestionGroupDetail> questionGroups = new ArrayList<QuestionGroupDetail>();
    formBean.setQuestionGroups(questionGroups);
    doThrow(validationException).when(questionnaireServiceFacade).validateResponses(formBean.getQuestionGroups());
    formBean.validateAnswerQuestionGroupStep(validationContext);
    MessageContext messageContext = validationContext.getMessageContext();
    Message[] messages = messageContext.getAllMessages();
    Assert.assertEquals(1, messages.length);
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) Message(org.springframework.binding.message.Message) ArrayList(java.util.ArrayList) MessageContext(org.springframework.binding.message.MessageContext) Test(org.junit.Test)

Aggregations

MessageContext (org.springframework.binding.message.MessageContext)48 Test (org.junit.Test)18 Message (org.springframework.binding.message.Message)16 MessageBuilder (org.springframework.binding.message.MessageBuilder)6 ArrayList (java.util.ArrayList)5 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)4 InvalidTicketException (org.apereo.cas.ticket.InvalidTicketException)4 UnsatisfiedAuthenticationPolicyException (org.apereo.cas.ticket.UnsatisfiedAuthenticationPolicyException)4 LocalDate (org.joda.time.LocalDate)4 BigDecimal (java.math.BigDecimal)3 GeneralSecurityException (java.security.GeneralSecurityException)3 HashMap (java.util.HashMap)3 AccountLockedException (javax.security.auth.login.AccountLockedException)3 AccountNotFoundException (javax.security.auth.login.AccountNotFoundException)3 PreventedException (org.apereo.cas.authentication.PreventedException)3 DateTime (org.joda.time.DateTime)3 LoanCreationInstallmentDto (org.mifos.dto.domain.LoanCreationInstallmentDto)2 LoanScheduleDto (org.mifos.dto.screen.LoanScheduleDto)2 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)2 ErrorEntry (org.mifos.platform.validations.ErrorEntry)2