use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm 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.QuestionGroupForm in project head by mifos.
the class QuestionGroupFormTest method shouldGetEventSourceId.
@Test
public void shouldGetEventSourceId() {
EventSourceDto eventSourceDto = new EventSourceDto("Create", "Client", "Create Client");
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(123, "Title", Arrays.asList(eventSourceDto), new ArrayList<SectionDetail>(), false);
QuestionGroupForm questionGroupForm = new QuestionGroupForm(questionGroupDetail);
assertThat(questionGroupForm.getEventSourceIds().get(0), is("Create.Client"));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm 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.QuestionGroupForm in project head by mifos.
the class QuestionGroupFormTest method shouldGetEventSource.
@Test
public void shouldGetEventSource() {
QuestionGroupForm questionGroupForm;
questionGroupForm = new QuestionGroupForm();
questionGroupForm.setEventSourceIds(Arrays.asList("event.source"));
assertEventSource(questionGroupForm.getEventSources().get(0), "event", "source");
questionGroupForm = new QuestionGroupForm();
questionGroupForm.setEventSourceIds(null);
assertThat(questionGroupForm.getEventSources().size(), is(0));
questionGroupForm = new QuestionGroupForm();
questionGroupForm.setEventSourceIds(Arrays.asList(""));
assertThat(questionGroupForm.getEventSources().size(), is(0));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionGroupForm 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