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"));
}
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;
}
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);
}
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;
}
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()));
}
Aggregations