Search in sources :

Example 1 with SectionDetailForm

use of org.mifos.platform.questionnaire.ui.model.SectionDetailForm in project head by mifos.

the class QuestionGroupFormTest method testAddCurrentSection.

@Test
public void testAddCurrentSection() {
    QuestionGroupForm questionGroupForm = new QuestionGroupForm();
    questionGroupForm.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1", true), getSectionQuestionDetail(2, "Q2", false))));
    questionGroupForm.setSelectedQuestionIds(asList("1"));
    String title = "title";
    questionGroupForm.setTitle(title);
    String sectionName = "sectionName";
    questionGroupForm.setSectionName(sectionName);
    questionGroupForm.addCurrentSection();
    List<SectionDetailForm> sectionDetailForms = questionGroupForm.getSections();
    assertThat(sectionDetailForms.size(), is(1));
    String nameOfAddedSection = questionGroupForm.getSections().get(0).getName();
    assertThat(nameOfAddedSection, is(sectionName));
    List<SectionQuestionDetailForm> questions = sectionDetailForms.get(0).getSectionQuestions();
    assertThat(questions.size(), is(1));
    assertThat(questions.get(0).getText(), is("Q1"));
    assertThat(questions.get(0).isMandatory(), is(true));
    assertThat(questionGroupForm.getSectionName(), is(nameOfAddedSection));
    assertNotSame(questionGroupForm.getSelectedQuestionIds().size(), is(0));
    questionGroupForm.setSelectedQuestionIds(asList("2"));
    questionGroupForm.setSectionName(sectionName);
    questionGroupForm.addCurrentSection();
    sectionDetailForms = questionGroupForm.getSections();
    assertThat(sectionDetailForms.size(), is(1));
    nameOfAddedSection = questionGroupForm.getSections().get(0).getName();
    assertThat(nameOfAddedSection, is(sectionName));
    questions = sectionDetailForms.get(0).getSectionQuestions();
    assertThat(questions.size(), is(2));
    assertThat(questions.get(0).getText(), is("Q1"));
    assertThat(questions.get(0).isMandatory(), is(true));
    assertThat(questions.get(1).getText(), is("Q2"));
    assertThat(questions.get(1).isMandatory(), is(false));
    assertThat(questionGroupForm.getSectionName(), is(nameOfAddedSection));
    assertNotSame(questionGroupForm.getSelectedQuestionIds().size(), is(0));
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) SectionQuestionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 2 with SectionDetailForm

use of org.mifos.platform.questionnaire.ui.model.SectionDetailForm in project head by mifos.

the class QuestionGroupFormTest method removeSection.

@Test
public void removeSection() {
    QuestionGroupForm questionGroupForm = new QuestionGroupForm();
    List<SectionDetailForm> sections = new ArrayList<SectionDetailForm>();
    String sectionName = "sectionName";
    setupSection(questionGroupForm, sections, sectionName);
    questionGroupForm.removeSection(sectionName);
    assertThatQuestionFormHasNoSection(questionGroupForm);
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) ArrayList(java.util.ArrayList) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 3 with SectionDetailForm

use of org.mifos.platform.questionnaire.ui.model.SectionDetailForm in project head by mifos.

the class QuestionGroupFormTest method getSectionSectionDetailForm.

private SectionDetailForm getSectionSectionDetailForm(String sectionName, List<SectionQuestionDetail> questions) {
    SectionDetailForm section = new SectionDetailForm();
    section.setName(sectionName);
    section.setQuestionDetails(questions);
    return section;
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm)

Example 4 with SectionDetailForm

use of org.mifos.platform.questionnaire.ui.model.SectionDetailForm in project head by mifos.

the class QuestionGroupControllerTest method testRemoveQuestionFromSection.

@Test
public void testRemoveQuestionFromSection() {
    QuestionGroupForm questionGroup = new QuestionGroupForm();
    List<SectionDetailForm> sections = new ArrayList<SectionDetailForm>();
    sections.add(getSectionSectionDetailForm("sectionName", new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1"), getSectionQuestionDetail(2, "Q2")))));
    questionGroup.setSections(sections);
    assertThat(questionGroup.getSections().size(), CoreMatchers.is(1));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), CoreMatchers.is(2));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), CoreMatchers.is("Q1"));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(1).getText(), CoreMatchers.is("Q2"));
    questionGroupController.deleteQuestion(questionGroup, "sectionName", "1");
    assertThat(questionGroup.getSections().size(), CoreMatchers.is(1));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), CoreMatchers.is(1));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), CoreMatchers.is("Q2"));
    questionGroupController.deleteQuestion(questionGroup, "sectionName", "2");
    assertThat(questionGroup.getSections().size(), CoreMatchers.is(0));
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) ArrayList(java.util.ArrayList) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 5 with SectionDetailForm

use of org.mifos.platform.questionnaire.ui.model.SectionDetailForm in project head by mifos.

the class QuestionGroupControllerTest method getSectionSectionDetailForm.

private SectionDetailForm getSectionSectionDetailForm(String sectionName, List<SectionQuestionDetail> questions) {
    SectionDetailForm section = new SectionDetailForm();
    section.setName(sectionName);
    section.setQuestionDetails(questions);
    return section;
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm)

Aggregations

SectionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionDetailForm)9 Test (org.junit.Test)7 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)6 ArrayList (java.util.ArrayList)3 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)2 SectionQuestionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm)2 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)1 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)1 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)1 Question (org.mifos.platform.questionnaire.ui.model.Question)1