use of org.springframework.binding.message.Message 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"));
}
use of org.springframework.binding.message.Message 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);
}
use of org.springframework.binding.message.Message 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);
}
use of org.springframework.binding.message.Message in project head by mifos.
the class CreateSavingsAccountFormBeanTest method validateSelectProductOfferingStepNonEmptyProductIdShouldPass.
@Test
public void validateSelectProductOfferingStepNonEmptyProductIdShouldPass() {
formBean.setProductId(1);
formBean.validateSelectProductOfferingStep(validationContext);
MessageContext messageContext = validationContext.getMessageContext();
Message[] messages = messageContext.getAllMessages();
Assert.assertEquals(0, messages.length);
}
use of org.springframework.binding.message.Message in project head by mifos.
the class CreateSavingsAccountFormBeanTest method validateEnterAccountDetailsStepMandatoryDeposit.
private void validateEnterAccountDetailsStepMandatoryDeposit(String amount, @SuppressWarnings("rawtypes") Map<String, Class> expectedViolations, boolean expectingPass) {
setDepositType(formBean, CreateSavingsAccountFormBean.MANDATORY_DEPOSIT);
formBean.setMandatoryDepositAmount(amount);
formBean.validateEnterAccountDetailsStep(validationContext);
MessageContext messageContext = validationContext.getMessageContext();
Message[] messages = messageContext.getAllMessages();
if (expectingPass) {
Assert.assertEquals(0, messages.length);
return;
} else {
Assert.assertEquals(expectedViolations.size(), messages.length);
for (Message message : messages) {
Assert.assertEquals("mandatoryDepositAmount", message.getSource());
String reason = message.getText().substring(0, message.getText().indexOf("."));
Assert.assertTrue(expectedViolations.containsKey(reason));
verifyErrorMessage(expectedViolations.get(reason), message);
}
}
}
Aggregations