Search in sources :

Example 6 with SectionDetailForm

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

Example 7 with SectionDetailForm

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

the class QuestionGroupFormTest method testAddCurrentSectionForAddQuestion.

@Test
public void testAddCurrentSectionForAddQuestion() {
    QuestionGroupForm questionGroupForm = new QuestionGroupForm();
    String title = "title";
    questionGroupForm.setTitle(title);
    String sectionName = "SectionWithNewQuestion";
    Question currentQuestion = new Question(new QuestionDetail());
    currentQuestion.setText(" Question1 ");
    currentQuestion.setType("freeText");
    questionGroupForm.setCurrentQuestion(currentQuestion);
    questionGroupForm.setAddQuestionFlag(true);
    questionGroupForm.setSectionName(sectionName);
    questionGroupForm.addCurrentSection();
    List<SectionDetailForm> sections = questionGroupForm.getSections();
    assertThat(sections.size(), is(1));
    SectionDetailForm section1 = sections.get(0);
    assertThat(section1.getName(), is(sectionName));
    assertThat(section1.getSectionQuestionDetails().get(0).getText(), is("Question1"));
    assertThat(questionGroupForm.getSectionName(), is(section1.getName()));
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Question(org.mifos.platform.questionnaire.ui.model.Question) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 8 with SectionDetailForm

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

the class QuestionGroupFormTest method shouldGetSections.

@Test
public void shouldGetSections() {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName("Section1");
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(123, "Title", null, asList(sectionDetail), false);
    QuestionGroupForm questionGroupForm = new QuestionGroupForm(questionGroupDetail);
    List<SectionDetailForm> sections = questionGroupForm.getSections();
    assertThat(questionGroupForm.getInitialCountOfSections(), is(1));
    assertThat(sections, notNullValue());
    assertThat(sections.size(), is(1));
    assertThat(sections.get(0).getName(), is("Section1"));
    assertThat(sections.get(0).getInitialCountOfQuestions(), is(0));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) Test(org.junit.Test)

Example 9 with SectionDetailForm

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

the class QuestionGroupFormTest method testRemoveQuestionFromSection.

@Test
public void testRemoveQuestionFromSection() {
    QuestionGroupForm questionGroupForm = new QuestionGroupForm();
    List<SectionDetailForm> sections = new ArrayList<SectionDetailForm>();
    setupSection(questionGroupForm, sections, "sectionName");
    questionGroupForm.removeQuestion("sectionName", "1");
    assertThat(questionGroupForm.getSections().size(), is(1));
    assertThat(questionGroupForm.getSections().get(0).getSectionQuestions().size(), is(1));
    assertThat(questionGroupForm.getSections().get(0).getSectionQuestions().get(0).getText(), is("Q2"));
    assertThat(questionGroupForm.getSections().get(0).getSectionQuestions().get(0).isMandatory(), is(true));
    assertThat(questionGroupForm.getQuestionPool().size(), is(1));
    assertThat(questionGroupForm.getQuestionPool().get(0).getText(), is("Q1"));
    assertThat(questionGroupForm.getQuestionPool().get(0).isMandatory(), is(false));
    questionGroupForm.removeQuestion("sectionName", "2");
    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)

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