Search in sources :

Example 26 with QuestionGroupForm

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));
}
Also used : QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 27 with QuestionGroupForm

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));
}
Also used : QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 28 with QuestionGroupForm

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)));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupDetailMatcher(org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 29 with QuestionGroupForm

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")));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 30 with QuestionGroupForm

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")));
}
Also used : MessageMatcher(org.mifos.platform.matchers.MessageMatcher) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Aggregations

QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)34 Test (org.junit.Test)31 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)10 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)8 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)6 SectionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionDetailForm)6 ArrayList (java.util.ArrayList)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)3 SystemException (org.mifos.framework.exceptions.SystemException)2 QuestionGroupDetailMatcher (org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 Question (org.mifos.platform.questionnaire.ui.model.Question)2 QuestionGroupDetailFormMatcher (org.mifos.platform.questionnaire.matchers.QuestionGroupDetailFormMatcher)1 SectionQuestionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1