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);
}
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()));
}
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));
}
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);
}
Aggregations