use of org.mifos.platform.matchers.MessageMatcher in project head by mifos.
the class QuestionGroupControllerTest method testSaveQuestionnaireFailureForNumericResponseGreaterThanMaxBound.
@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
@Test
public void testSaveQuestionnaireFailureForNumericResponseGreaterThanMaxBound() {
ValidationException validationException = new ValidationException(GENERIC_VALIDATION);
validationException.addChildException(new BadNumericResponseException("q1", null, 100));
doThrow(validationException).when(questionnaireServiceFacade).saveResponses(Mockito.<QuestionGroupDetails>any());
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.saveQuestionnaire(getQuestionGroupDetails(), 1, requestContext);
assertThat(result, is("failure"));
verify(requestContext, times(1)).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.invalid.numeric.max.response")));
}
use of org.mifos.platform.matchers.MessageMatcher in project head by mifos.
the class QuestionGroupControllerTest method testCreateQuestionGroupForFailureWhenQuestionGroupTitleNotProvided.
@Test
public void testCreateQuestionGroupForFailureWhenQuestionGroupTitleNotProvided() throws Exception {
QuestionGroupForm questionGroupForm = getQuestionGroupForm(null, "Create.Client", "Section");
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.defineQuestionGroup(questionGroupForm, requestContext, true);
assertThat(result, Is.is(notNullValue()));
assertThat(result, Is.is("failure"));
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.error.questionGroup.title.empty")));
}
use of org.mifos.platform.matchers.MessageMatcher in project head by mifos.
the class QuestionGroupControllerTest method testCreateQuestionGroupFailureWhenSectionsNotPresent.
@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
@Test
public void testCreateQuestionGroupFailureWhenSectionsNotPresent() throws Exception {
when(requestContext.getMessageContext()).thenReturn(messageContext);
QuestionGroupForm questionGroupForm = getQuestionGroupForm(TITLE, "Create.Client");
String result = questionGroupController.defineQuestionGroup(questionGroupForm, requestContext, true);
assertThat(result, Is.is("failure"));
verify(requestContext).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.error.section.atLeastOne")));
}
use of org.mifos.platform.matchers.MessageMatcher in project head by mifos.
the class QuestionGroupControllerTest method testSaveQuestionnaireFailureForNumericResponseLessThanMinBound.
@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
@Test
public void testSaveQuestionnaireFailureForNumericResponseLessThanMinBound() {
ValidationException validationException = new ValidationException(GENERIC_VALIDATION);
validationException.addChildException(new BadNumericResponseException("q1", 10, null));
doThrow(validationException).when(questionnaireServiceFacade).saveResponses(Mockito.<QuestionGroupDetails>any());
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.saveQuestionnaire(getQuestionGroupDetails(), 1, requestContext);
assertThat(result, is("failure"));
verify(requestContext, times(1)).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.invalid.numeric.min.response")));
}
use of org.mifos.platform.matchers.MessageMatcher in project head by mifos.
the class QuestionGroupControllerTest method testAddQuestionForDuplicateTitle.
@Test
public void testAddQuestionForDuplicateTitle() {
QuestionGroupForm questionGroupForm = getQuestionGroupForm(TITLE, "Create.Client", "Default");
questionGroupForm.setValidator(validator);
questionGroupForm.getCurrentQuestion().setText(TITLE);
questionGroupForm.getCurrentQuestion().setType("freeText");
when(questionnaireServiceFacade.isDuplicateQuestion(TITLE)).thenReturn(true);
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.addQuestion(questionGroupForm, requestContext);
assertThat(result, is("failure"));
verify(requestContext, times(1)).getMessageContext();
verify(messageContext).addMessage(argThat(new MessageMatcher("questionnaire.error.question.duplicate")));
}
Aggregations