Search in sources :

Example 1 with Section

use of org.mifos.platform.questionnaire.domain.Section in project head by mifos.

the class QuestionnaireMapperImpl method mapToSection.

private Section mapToSection(SectionDto sectionDto) {
    Section section = new Section();
    section.setName(sectionDto.getName());
    section.setSequenceNumber(sectionDto.getOrder());
    section.setQuestions(mapToSectionQuestionsFromDtos(sectionDto.getQuestions(), section));
    return section;
}
Also used : Section(org.mifos.platform.questionnaire.domain.Section)

Example 2 with Section

use of org.mifos.platform.questionnaire.domain.Section in project head by mifos.

the class QuestionnaireMapperImpl method mapToSection.

private Section mapToSection(QuestionGroupDetail questionGroupDetail, SectionDetail sectionDetail) {
    Section section = getSection(questionGroupDetail, sectionDetail);
    section.setQuestions(mapToSectionQuestions(sectionDetail.getQuestions(), section));
    if (sectionDetail.getSequenceNumber() != null) {
        section.setSequenceNumber(sectionDetail.getSequenceNumber());
    }
    return section;
}
Also used : Section(org.mifos.platform.questionnaire.domain.Section)

Example 3 with Section

use of org.mifos.platform.questionnaire.domain.Section in project head by mifos.

the class QuestionnaireMapperTest method assertSectionsForExistingQuestion.

private void assertSectionsForExistingQuestion(List<Section> sections) {
    assertThat(sections, is(notNullValue()));
    assertThat(sections.size(), is(1));
    Section section = sections.get(0);
    assertThat(section.getName(), is("Misc"));
    List<SectionQuestion> questions = section.getQuestions();
    assertThat(questions, is(notNullValue()));
    assertThat(questions.size(), is(2));
    assertThat(questions.get(0).getQuestionText(), is("Ques1"));
    assertThat(questions.get(0).getId(), is(333));
    assertThat(questions.get(0).getQuestion().getQuestionId(), is(999));
    assertThat(questions.get(1).getQuestionText(), is("Ques2"));
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) Section(org.mifos.platform.questionnaire.domain.Section)

Example 4 with Section

use of org.mifos.platform.questionnaire.domain.Section in project head by mifos.

the class QuestionnaireMapperTest method assertSections.

private void assertSections(List<Section> sections) {
    assertThat(sections, notNullValue());
    assertThat(sections.size(), is(2));
    Section section1 = sections.get(0);
    assertThat(section1.getName(), is("S1"));
    assertSectionQuestions(section1.getQuestions());
    Section section2 = sections.get(1);
    assertThat(section2.getName(), is("S2"));
    assertSectionQuestions(section2.getQuestions());
}
Also used : Section(org.mifos.platform.questionnaire.domain.Section)

Example 5 with Section

use of org.mifos.platform.questionnaire.domain.Section in project head by mifos.

the class QuestionnaireMapperTest method getSection.

private Section getSection(String sectionName, int questionId) {
    Section section = new Section(sectionName);
    SectionQuestion sectionQuestion = new SectionQuestion();
    QuestionEntity question = new QuestionEntity();
    question.setQuestionId(questionId);
    question.setQuestionText(sectionName);
    question.setAnswerType(AnswerType.DATE);
    question.setChoices(new LinkedList<QuestionChoiceEntity>());
    sectionQuestion.setQuestion(question);
    section.setQuestions(asList(sectionQuestion));
    return section;
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) Section(org.mifos.platform.questionnaire.domain.Section)

Aggregations

Section (org.mifos.platform.questionnaire.domain.Section)14 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)7 Test (org.junit.Test)4 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)4 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)3 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)3 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)3 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)1 Matchers.anyString (org.mockito.Matchers.anyString)1