Search in sources :

Example 21 with QuestionGroupForm

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()));
}
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 22 with QuestionGroupForm

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"));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test)

Example 23 with QuestionGroupForm

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));
}
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 24 with QuestionGroupForm

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));
}
Also used : QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 25 with QuestionGroupForm

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

QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)34 Test (org.junit.Test)31 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)10 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)8 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)6 SectionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionDetailForm)6 ArrayList (java.util.ArrayList)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)3 SystemException (org.mifos.framework.exceptions.SystemException)2 QuestionGroupDetailMatcher (org.mifos.platform.questionnaire.matchers.QuestionGroupDetailMatcher)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 Question (org.mifos.platform.questionnaire.ui.model.Question)2 QuestionGroupDetailFormMatcher (org.mifos.platform.questionnaire.matchers.QuestionGroupDetailFormMatcher)1 SectionQuestionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1