Search in sources :

Example 1 with SectionQuestionDetailForm

use of org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm 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 SectionQuestionDetailForm

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

the class SectionDetailFormTest method shouldGetQuestions.

@Test
public void shouldGetQuestions() {
    SectionDetailForm sectionDetailForm = new SectionDetailForm(getSectionDefinition());
    List<SectionQuestionDetailForm> sectionQuestions = sectionDetailForm.getSectionQuestions();
    assertThat(sectionQuestions, Matchers.notNullValue());
    assertThat(sectionQuestions.size(), Matchers.is(3));
    assertQuestionDetailForm(sectionQuestions.get(0), 121, "Question1", true);
    assertQuestionDetailForm(sectionQuestions.get(1), 122, "Question2", false);
    assertQuestionDetailForm(sectionQuestions.get(2), 123, "Question3", true);
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) SectionQuestionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SectionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionDetailForm)2 SectionQuestionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm)2 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)1 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)1