Search in sources :

Example 31 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method getSection.

private SectionDetail getSection(String name) {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(12, "Q1", QuestionType.INVALID, true, true), true, null));
    return section;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 32 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method getSectionWithOneQuestion.

private SectionDetail getSectionWithOneQuestion(String name, QuestionDetail questionDetail, String response) {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.setName(name);
    sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true, response)));
    return sectionDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail)

Example 33 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class SectionDetailFormTest method getSectionDefinition.

private SectionDetail getSectionDefinition() {
    SectionDetail sectionDetail = new SectionDetail();
    sectionDetail.addQuestion(new SectionQuestionDetail(new QuestionDetail(121, "Question1", QuestionType.FREETEXT, true, true), true));
    sectionDetail.addQuestion(new SectionQuestionDetail(new QuestionDetail(122, "Question2", QuestionType.FREETEXT, true, true), false));
    sectionDetail.addQuestion(new SectionQuestionDetail(new QuestionDetail(123, "Question3", QuestionType.FREETEXT, true, true), true));
    return sectionDetail;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail)

Example 34 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionGroupControllerTest method testAddSectionForSuccessWhenQuestionTitleProvidedWithAllBlanks.

@Test
public void testAddSectionForSuccessWhenQuestionTitleProvidedWithAllBlanks() throws Exception {
    QuestionGroupForm questionGroup = new QuestionGroupForm();
    questionGroup.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1"), getSectionQuestionDetail(2, "Q2"))));
    questionGroup.setSelectedQuestionIds(asList("1", "2"));
    questionGroup.setSectionName("        ");
    String result = questionGroupController.addSection(questionGroup, requestContext);
    assertThat(questionGroup.getSections().size(), Is.is(1));
    assertThat(questionGroup.getSections().get(0).getName(), Is.is("Misc"));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), Is.is(2));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), Is.is("Q1"));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(1).getText(), Is.is("Q2"));
    assertThat(result, Is.is("success"));
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 35 with SectionQuestionDetail

use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.

the class QuestionGroupControllerTest method testAddSectionsSuccessWhenSectionNameIsNotProvided.

@Test
public void testAddSectionsSuccessWhenSectionNameIsNotProvided() {
    QuestionGroupForm questionGroup = new QuestionGroupForm();
    questionGroup.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1"), getSectionQuestionDetail(2, "Q2"))));
    questionGroup.setSelectedQuestionIds(asList("2"));
    String result = questionGroupController.addSection(questionGroup, requestContext);
    assertThat(questionGroup.getSections().size(), Is.is(1));
    assertThat(questionGroup.getSections().get(0).getName(), Is.is("Misc"));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), Is.is(1));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), Is.is("Q2"));
    assertThat(result, Is.is("success"));
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Aggregations

SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)44 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)25 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)21 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)7 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)6 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)5 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)3 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)3 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)2 QuestionLinkDetail (org.mifos.platform.questionnaire.service.QuestionLinkDetail)2 SectionLinkDetail (org.mifos.platform.questionnaire.service.SectionLinkDetail)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 HashSet (java.util.HashSet)1 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)1 AuditLog (org.mifos.framework.components.audit.business.AuditLog)1 AuditLogRecord (org.mifos.framework.components.audit.business.AuditLogRecord)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 QuestionGroupInstanceDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionGroupInstanceDtoBuilder)1