Search in sources :

Example 6 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion 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 7 with SectionQuestion

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

the class QuestionnaireMapperTest method getSectionQuestion.

private SectionQuestion getSectionQuestion(QuestionEntity questionEntity, int secQuesId) {
    SectionQuestion sectionQuestion = new SectionQuestion();
    sectionQuestion.setId(secQuesId);
    sectionQuestion.setSequenceNumber(0);
    sectionQuestion.setQuestion(questionEntity);
    return sectionQuestion;
}
Also used : SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion)

Example 8 with SectionQuestion

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

the class QuestionnaireMapperTest method shouldMapToQuestionGroupInstance.

@Test
public void shouldMapToQuestionGroupInstance() {
    QuestionGroupInstanceDto questionGroupInstanceDto = getQuestionGroupInstanceDto();
    QuestionGroup questionGroup = new QuestionGroup();
    when(questionGroupDao.getDetails(123)).thenReturn(questionGroup);
    SectionQuestion sectionQuestion = new SectionQuestion();
    when(sectionQuestionDao.getDetails(999)).thenReturn(sectionQuestion);
    QuestionGroupInstance questionGroupInstance = questionnaireMapper.mapToQuestionGroupInstance(questionGroupInstanceDto);
    assertThat(questionGroupInstance, is(notNullValue()));
    assertThat(questionGroupInstance.getCompletedStatus(), is(1));
    assertThat(questionGroupInstance.getCreatorId(), is(111));
    assertThat(questionGroupInstance.getEntityId(), is(12345));
    assertThat(questionGroupInstance.getVersionNum(), is(1));
    assertThat(questionGroupInstance.getQuestionGroup(), is(questionGroup));
    List<QuestionGroupResponse> questionGroupResponses = questionGroupInstance.getQuestionGroupResponses();
    assertThat(questionGroupResponses, is(notNullValue()));
    assertThat(questionGroupResponses.size(), is(1));
    QuestionGroupResponse questionGroupResponse = questionGroupResponses.get(0);
    assertThat(questionGroupResponse.getResponse(), is("Answer1"));
    assertThat(questionGroupResponse.getSectionQuestion(), is(sectionQuestion));
    verify(questionGroupDao).getDetails(123);
    verify(sectionQuestionDao).getDetails(999);
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionGroupInstanceDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto) QuestionGroupInstance(org.mifos.platform.questionnaire.domain.QuestionGroupInstance) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) Test(org.junit.Test)

Example 9 with SectionQuestion

use of org.mifos.platform.questionnaire.domain.SectionQuestion 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)

Example 10 with SectionQuestion

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

the class SectionQuestionDaoIntegrationTest method shouldRetrieveSectionQuestionByQuestionIdSectionId.

@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveSectionQuestionByQuestionIdSectionId() {
    String title = "QG1" + currentTimeMillis();
    SectionDetail sectionDetail1 = getSection("S1");
    SectionDetail sectionDetail2 = getSection("S2");
    List<SectionDetail> details = asList(sectionDetail1, sectionDetail2);
    QuestionGroupDetail questionGroupDetail = defineQuestionGroup(title, "Create", "Client", details, false);
    QuestionGroup questionGroup = questionGroupDao.getDetails(questionGroupDetail.getId());
    Integer questionId = questionGroup.getSections().get(1).getQuestions().get(1).getQuestion().getQuestionId();
    Integer sectionId = questionGroup.getSections().get(1).getId();
    List<SectionQuestion> sectionQuestions = sectionQuestionDao.retrieveFromQuestionIdSectionId(sectionId, questionId);
    assertThat(sectionQuestions, is(notNullValue()));
    assertThat(sectionQuestions.size(), is(1));
    assertThat(sectionQuestions.get(0).getQuestionText(), is(sectionDetail2.getQuestionDetail(1).getText()));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)20 Section (org.mifos.platform.questionnaire.domain.Section)7 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)5 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)5 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)4 QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)4 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)3 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)3 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)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 LinkedList (java.util.LinkedList)1 SectionLink (org.mifos.platform.questionnaire.domain.SectionLink)1 SectionQuestionLink (org.mifos.platform.questionnaire.domain.SectionQuestionLink)1 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)1