use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testAddSectionForSuccessWhenQuestionTitleProvidedWithAllBlanks.
@Test
public void testAddSectionForSuccessWhenQuestionTitleProvidedWithAllBlanks() throws Exception {
QuestionGroupForm questionGroup = new QuestionGroupForm();
questionGroup.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1"), getSectionQuestionDetail(2, "Q2"))));
questionGroup.setSelectedQuestionIds(asList("1", "2"));
questionGroup.setSectionName(" ");
String result = questionGroupController.addSection(questionGroup, requestContext);
assertThat(questionGroup.getSections().size(), Is.is(1));
assertThat(questionGroup.getSections().get(0).getName(), Is.is("Misc"));
assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), Is.is(2));
assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), Is.is("Q1"));
assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(1).getText(), Is.is("Q2"));
assertThat(result, Is.is("success"));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm 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")));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testAddQuestion.
@Test
public void testAddQuestion() {
QuestionGroupForm questionGroupForm = getQuestionGroupForm(TITLE, "Create.Client", "Default");
questionGroupForm.getCurrentQuestion().setText("Question1");
questionGroupForm.getCurrentQuestion().setType("freeText");
when(requestContext.getMessageContext()).thenReturn(messageContext);
String result = questionGroupController.addQuestion(questionGroupForm, requestContext);
assertThat(result, is("success"));
verify(requestContext, times(1)).getMessageContext();
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testAddSectionsSuccessWhenSectionNameIsNotProvided.
@Test
public void testAddSectionsSuccessWhenSectionNameIsNotProvided() {
QuestionGroupForm questionGroup = new QuestionGroupForm();
questionGroup.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1"), getSectionQuestionDetail(2, "Q2"))));
questionGroup.setSelectedQuestionIds(asList("2"));
String result = questionGroupController.addSection(questionGroup, requestContext);
assertThat(questionGroup.getSections().size(), Is.is(1));
assertThat(questionGroup.getSections().get(0).getName(), Is.is("Misc"));
assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), Is.is(1));
assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), Is.is("Q2"));
assertThat(result, Is.is("success"));
}
Aggregations