Search in sources :

Example 41 with MessageContext

use of org.springframework.binding.message.MessageContext 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 42 with MessageContext

use of org.springframework.binding.message.MessageContext 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)

Example 43 with MessageContext

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

Example 44 with MessageContext

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

the class ClearOverpaymentFormBean method validateEnterOverpaymentClearStep.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "REC_CATCH_EXCEPTION", justification = "should be the exception thrown by jodatime but not sure what it is right now.")
public void validateEnterOverpaymentClearStep(ValidationContext context) {
    MessageContext messages = context.getMessageContext();
    validator.validate(this, messages);
}
Also used : MessageContext(org.springframework.binding.message.MessageContext)

Example 45 with MessageContext

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

Aggregations

MessageContext (org.springframework.binding.message.MessageContext)51 Test (org.junit.Test)18 Message (org.springframework.binding.message.Message)16 MessageBuilder (org.springframework.binding.message.MessageBuilder)9 ArrayList (java.util.ArrayList)5 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)5 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