use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.
the class QuestionnaireServiceIntegrationTest method assertQuestionGroup.
private void assertQuestionGroup(QuestionGroup questionGroup, String questionGroupTitle, String firstQuestionTitle, String secondQuestionTitle) {
assertThat(questionGroup, is(notNullValue()));
assertThat(questionGroup.getTitle(), is(questionGroupTitle));
Set<EventSourceEntity> eventSources = questionGroup.getEventSources();
assertThat(eventSources, is(notNullValue()));
assertThat(eventSources.size(), is(1));
EventSourceEntity eventSourceEntity = eventSources.toArray(new EventSourceEntity[eventSources.size()])[0];
assertThat(eventSourceEntity.getEvent().getName(), is("Create"));
assertThat(eventSourceEntity.getSource().getEntityType(), is("Client"));
assertThat(questionGroup.getState(), is(QuestionGroupState.ACTIVE));
List<Section> sections = questionGroup.getSections();
assertThat(sections, is(notNullValue()));
assertThat(sections.size(), is(1));
Section section = sections.get(0);
assertThat(section.getName(), is("Sec1"));
List<SectionQuestion> questions = section.getQuestions();
assertThat(questions, is(notNullValue()));
assertThat(questions.size(), is(2));
SectionQuestion sectionQuestion1 = questions.get(0);
assertThat(sectionQuestion1.getSequenceNumber(), is(1));
assertThat(sectionQuestion1.getSection(), is(notNullValue()));
assertThat(sectionQuestion1.getSection().getName(), is("Sec1"));
assertThat(sectionQuestion1.getSection().getSequenceNumber(), is(1));
assertThat(sectionQuestion1.getQuestion(), is(notNullValue()));
assertThat(sectionQuestion1.getQuestion().getQuestionStateAsEnum(), is(QuestionState.ACTIVE));
assertThat(sectionQuestion1.getQuestion().getQuestionText(), is(firstQuestionTitle));
assertThat(sectionQuestion1.getQuestion().getAnswerTypeAsEnum(), is(AnswerType.FREETEXT));
SectionQuestion sectionQuestion2 = questions.get(1);
assertThat(sectionQuestion2.getSequenceNumber(), is(2));
assertThat(sectionQuestion2.getSection(), is(notNullValue()));
assertThat(sectionQuestion2.getSection().getName(), is("Sec1"));
assertThat(sectionQuestion2.getSection().getSequenceNumber(), is(1));
assertThat(sectionQuestion2.getQuestion(), is(notNullValue()));
assertThat(sectionQuestion2.getQuestion().getQuestionStateAsEnum(), is(QuestionState.ACTIVE));
assertThat(sectionQuestion2.getQuestion().getQuestionText(), is(secondQuestionTitle));
assertThat(sectionQuestion2.getQuestion().getAnswerTypeAsEnum(), is(AnswerType.SINGLESELECT));
assertThat(sectionQuestion2.getQuestion().getChoices(), is(notNullValue()));
assertThat(sectionQuestion2.getQuestion().getChoices().size(), is(3));
assertThat(sectionQuestion2.getQuestion().getChoices().get(0).getChoiceText(), is("Ch2"));
assertThat(sectionQuestion2.getQuestion().getChoices().get(0).getChoiceOrder(), is(1));
assertThat(sectionQuestion2.getQuestion().getChoices().get(1).getChoiceText(), is("Ch1"));
assertThat(sectionQuestion2.getQuestion().getChoices().get(1).getChoiceOrder(), is(2));
assertThat(sectionQuestion2.getQuestion().getChoices().get(2).getChoiceText(), is("Ch3"));
assertThat(sectionQuestion2.getQuestion().getChoices().get(2).getChoiceOrder(), is(3));
}
use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.
the class QuestionnaireMapperTest method assertSectionQuestions.
private void assertSectionQuestions(List<SectionQuestion> sectionQuestions) {
assertThat(sectionQuestions, notNullValue());
assertThat(sectionQuestions.size(), is(1));
SectionQuestion sectionQuestion = sectionQuestions.get(0);
assertThat(sectionQuestion.getQuestion(), notNullValue());
assertThat(sectionQuestion.getSection(), notNullValue());
assertThat(sectionQuestion.isRequired(), is(true));
assertThat(sectionQuestion.getSequenceNumber(), is(0));
}
use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.
the class QuestionnaireMapperTest method getSectionWithOneMultiSelectQuestion.
private Section getSectionWithOneMultiSelectQuestion(int sectionQuestionId, String sectionName, String questionName, String... choices) {
Section section = new Section(sectionName);
List<SectionQuestion> sectionQuestions = new ArrayList<SectionQuestion>();
SectionQuestion sectionQuestion = new SectionQuestion();
sectionQuestion.setId(sectionQuestionId);
sectionQuestion.setSection(section);
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setQuestionText(questionName);
questionEntity.setAnswerType(AnswerType.MULTISELECT);
LinkedList<QuestionChoiceEntity> questionChoiceEntities = new LinkedList<QuestionChoiceEntity>();
for (String choice : choices) {
QuestionChoiceEntity questionChoiceEntity = new QuestionChoiceEntity();
questionChoiceEntity.setChoiceText(choice);
questionChoiceEntities.add(questionChoiceEntity);
}
questionEntity.setChoices(questionChoiceEntities);
sectionQuestion.setQuestion(questionEntity);
sectionQuestions.add(sectionQuestion);
section.setQuestions(sectionQuestions);
return section;
}
use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.
the class QuestionGroupDaoIntegrationTest method shouldRetrieveSectionQuestionIdByQuestionGroupNameSectionNameQuestionId.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldRetrieveSectionQuestionIdByQuestionGroupNameSectionNameQuestionId() {
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);
List<Section> sections = questionGroupDao.retrieveSectionByNameAndQuestionGroupId("S2", questionGroupDetail.getId());
assertThat(sections, is(notNullValue()));
assertThat(sections.size(), is(1));
Section section2 = sections.get(0);
assertThat(section2.getName(), is("S2"));
List<SectionQuestion> sections2Questions = section2.getQuestions();
assertThat(sections2Questions, is(notNullValue()));
assertThat(sections2Questions.size(), is(3));
assertThat(sections2Questions.get(0).getQuestionText(), is(sectionDetail2.getQuestionDetail(0).getText()));
assertThat(sections2Questions.get(1).getQuestionText(), is(sectionDetail2.getQuestionDetail(1).getText()));
assertThat(sections2Questions.get(2).getQuestionText(), is(sectionDetail2.getQuestionDetail(2).getText()));
}
use of org.mifos.platform.questionnaire.domain.SectionQuestion in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method getQuestionGroupInstance.
private QuestionGroupInstance getQuestionGroupInstance(int version, QuestionGroup questionGroup, int entityId, String... responses) {
QuestionGroupInstance questionGroupInstance = new QuestionGroupInstance();
questionGroupInstance.setCompletedStatus(1);
questionGroupInstance.setQuestionGroup(questionGroup);
questionGroupInstance.setDateConducted(Calendar.getInstance().getTime());
questionGroupInstance.setCreatorId(122);
questionGroupInstance.setVersionNum(version);
questionGroupInstance.setEntityId(entityId);
List<QuestionGroupResponse> questionGroupResponses = new ArrayList<QuestionGroupResponse>();
for (int index = 0; index < responses.length; index++) {
SectionQuestion sectionQuestion = questionGroup.getSections().get(index).getQuestions().get(0);
questionGroupResponses.add(getQuestionGroupResponse(responses[index], questionGroupInstance, sectionQuestion));
}
questionGroupInstance.setQuestionGroupResponses(questionGroupResponses);
return questionGroupInstance;
}
Aggregations