Search in sources :

Example 16 with SectionQuestionDetail

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

the class QuestionnaireMapperTest method getSectionDefinition.

private SectionDetail getSectionDefinition(String name, int questionId, String questionTitle) {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(questionId, questionTitle, QuestionType.FREETEXT, true, true), true));
    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 17 with SectionQuestionDetail

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

the class QuestionGroupDaoIntegrationTest method getSection.

private SectionDetail getSection(String name) throws SystemException {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    section.addQuestion(new SectionQuestionDetail(defineQuestion("Question1" + name + currentTimeMillis(), QuestionType.NUMERIC), true));
    section.addQuestion(new SectionQuestionDetail(defineQuestion("Question2" + name + currentTimeMillis(), QuestionType.DATE), true));
    section.addQuestion(new SectionQuestionDetail(defineQuestion("Question3" + name + currentTimeMillis(), QuestionType.FREETEXT), false));
    return section;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail)

Example 18 with SectionQuestionDetail

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

the class QuestionnaireValidatorTest method getSectionWithQuestions.

private SectionDetail getSectionWithQuestions(String name, int... questionIds) {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    if (questionIds != null) {
        for (int questionId : questionIds) {
            section.addQuestion(new SectionQuestionDetail(new QuestionDetail(questionId, null, 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 19 with SectionQuestionDetail

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

the class QuestionGroupFormTest method testAddCurrentSection.

@Test
public void testAddCurrentSection() {
    QuestionGroupForm questionGroupForm = new QuestionGroupForm();
    questionGroupForm.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1", true), getSectionQuestionDetail(2, "Q2", false))));
    questionGroupForm.setSelectedQuestionIds(asList("1"));
    String title = "title";
    questionGroupForm.setTitle(title);
    String sectionName = "sectionName";
    questionGroupForm.setSectionName(sectionName);
    questionGroupForm.addCurrentSection();
    List<SectionDetailForm> sectionDetailForms = questionGroupForm.getSections();
    assertThat(sectionDetailForms.size(), is(1));
    String nameOfAddedSection = questionGroupForm.getSections().get(0).getName();
    assertThat(nameOfAddedSection, is(sectionName));
    List<SectionQuestionDetailForm> questions = sectionDetailForms.get(0).getSectionQuestions();
    assertThat(questions.size(), is(1));
    assertThat(questions.get(0).getText(), is("Q1"));
    assertThat(questions.get(0).isMandatory(), is(true));
    assertThat(questionGroupForm.getSectionName(), is(nameOfAddedSection));
    assertNotSame(questionGroupForm.getSelectedQuestionIds().size(), is(0));
    questionGroupForm.setSelectedQuestionIds(asList("2"));
    questionGroupForm.setSectionName(sectionName);
    questionGroupForm.addCurrentSection();
    sectionDetailForms = questionGroupForm.getSections();
    assertThat(sectionDetailForms.size(), is(1));
    nameOfAddedSection = questionGroupForm.getSections().get(0).getName();
    assertThat(nameOfAddedSection, is(sectionName));
    questions = sectionDetailForms.get(0).getSectionQuestions();
    assertThat(questions.size(), is(2));
    assertThat(questions.get(0).getText(), is("Q1"));
    assertThat(questions.get(0).isMandatory(), is(true));
    assertThat(questions.get(1).getText(), is("Q2"));
    assertThat(questions.get(1).isMandatory(), is(false));
    assertThat(questionGroupForm.getSectionName(), is(nameOfAddedSection));
    assertNotSame(questionGroupForm.getSelectedQuestionIds().size(), is(0));
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) SectionQuestionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionQuestionDetailForm) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Test(org.junit.Test)

Example 20 with SectionQuestionDetail

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

the class QuestionGroupControllerTest method testAddSectionForSuccess.

@Test
public void testAddSectionForSuccess() throws Exception {
    QuestionGroupForm questionGroup = new QuestionGroupForm();
    questionGroup.setQuestionPool(new ArrayList<SectionQuestionDetail>(asList(getSectionQuestionDetail(1, "Q1"), getSectionQuestionDetail(2, "Q2"))));
    questionGroup.setSelectedQuestionIds(asList("1"));
    questionGroup.setTitle("title");
    questionGroup.setSectionName("sectionName");
    String result = questionGroupController.addSection(questionGroup, requestContext);
    assertThat(questionGroup.getSections().size(), Is.is(1));
    assertThat(questionGroup.getSections().get(0).getName(), Is.is("sectionName"));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().size(), Is.is(1));
    assertThat(questionGroup.getSections().get(0).getSectionQuestions().get(0).getText(), Is.is("Q1"));
    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