use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupFormTest method testAddCurrentSectionWhenSectionNameIsNotProvided.
@Test
public void testAddCurrentSectionWhenSectionNameIsNotProvided() {
QuestionGroupForm questionGroupForm = new QuestionGroupForm();
String title = "title";
questionGroupForm.setTitle(title);
questionGroupForm.addCurrentSection();
assertThat(questionGroupForm.getSections().size(), is(1));
String nameOfAddedSection = questionGroupForm.getSections().get(0).getName();
assertThat(nameOfAddedSection, is("Misc"));
assertThat(questionGroupForm.getSectionName(), is(nameOfAddedSection));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testDeleteSection.
@Test
public void testDeleteSection() {
QuestionGroupForm questionGroup = new QuestionGroupForm();
String sectionName = "sectionName";
questionGroup.setSectionName(sectionName);
questionGroup.addCurrentSection();
assertThat(questionGroup.getSections().size(), Is.is(1));
questionGroupController.deleteSection(questionGroup, sectionName);
assertThat(questionGroup.getSections().size(), Is.is(0));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm in project head by mifos.
the class QuestionGroupControllerTest method testCreateQuestionGroupSuccess.
@Test
public void testCreateQuestionGroupSuccess() throws Exception {
QuestionGroupForm questionGroup = getQuestionGroupForm(" " + TITLE + " ", "Create.Client", "S1", "S2");
String result = questionGroupController.defineQuestionGroup(questionGroup, requestContext, true);
assertThat(result, Is.is("success"));
QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(TITLE, "Create", "Client", "S1", "S2");
questionGroupDetail.setActive(true);
verify(questionnaireServiceFacade).createActiveQuestionGroup(argThat(new QuestionGroupDetailMatcher(questionGroupDetail)));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm 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.questionnaire.ui.model.QuestionGroupForm 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")));
}
Aggregations