use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupsToQuestionGroupDetails.
@Test
public void shouldMapQuestionGroupsToQuestionGroupDetails() {
int countOfQuestions = 10;
List<QuestionGroup> questionGroups = new ArrayList<QuestionGroup>();
for (int i = 0; i < countOfQuestions; i++) {
questionGroups.add(getQuestionGroup(1991, TITLE + i, "View", "Loan", QuestionGroupState.ACTIVE, true, getSection(SECTION + i), getSection(SECTION + (i + 1))));
}
List<QuestionGroupDetail> questionGroupDetails = questionnaireMapper.mapToQuestionGroupDetails(questionGroups);
assertThat(questionGroupDetails, is(notNullValue()));
for (int i = 0; i < countOfQuestions; i++) {
QuestionGroupDetail questionGroupDetail = questionGroupDetails.get(i);
assertThat(questionGroupDetail.getTitle(), is(TITLE + i));
SectionDetail sectionDefinition1 = questionGroupDetail.getSectionDetails().get(0);
assertThat(sectionDefinition1.getName(), is(SECTION + i));
List<SectionQuestionDetail> questionDetails1 = sectionDefinition1.getQuestions();
assertThat(questionDetails1.size(), is(1));
assertThat(questionDetails1.get(0).getText(), is(SECTION + i));
assertThat(questionDetails1.get(0).getQuestionType(), is(QuestionType.DATE));
SectionDetail sectionDefinition2 = questionGroupDetail.getSectionDetails().get(1);
assertThat(sectionDefinition2.getName(), is(SECTION + (i + 1)));
List<SectionQuestionDetail> questionDetails2 = sectionDefinition2.getQuestions();
assertThat(questionDetails2.size(), is(1));
assertThat(questionDetails2.get(0).getText(), is(SECTION + (i + 1)));
assertThat(questionDetails2.get(0).getQuestionType(), is(QuestionType.DATE));
}
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupToExistingQuestionGroupWhileAddingQuestionToOldSection.
@Test
public void shouldMapQuestionGroupToExistingQuestionGroupWhileAddingQuestionToOldSection() {
Integer questionGroupId = 123;
EventSourceDto eventSourceDto = getEventSource("Create", "Client");
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName("Misc");
SectionQuestionDetail sectionQuestionDetail1 = getSectionQuestionDetail(111, 999, "Ques1");
SectionQuestionDetail sectionQuestionDetail2 = getSectionQuestionDetail(0, 0, "Ques2");
sectionDetail.setQuestionDetails(asList(sectionQuestionDetail1, sectionQuestionDetail2));
List<SectionDetail> sectionDetails = asList(sectionDetail);
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(questionGroupId, TITLE, Arrays.asList(eventSourceDto), sectionDetails, true, true);
SectionQuestion sectionQuestion = getSectionQuestion(getQuestionEntity(999, "Ques1"), 333);
Section section = getSection(sectionQuestion, 222, "Misc");
when(questionGroupDao.retrieveSectionByNameAndQuestionGroupId("Misc", 123)).thenReturn(asList(section));
when(questionGroupDao.getDetails(questionGroupId)).thenReturn(getQuestionGroup(questionGroupId, "QG Title", section));
when(sectionQuestionDao.retrieveFromQuestionIdSectionId(222, 999)).thenReturn(asList(sectionQuestion));
when(eventSourceDao.retrieveByEventAndSource(anyString(), anyString())).thenReturn(new ArrayList<EventSourceEntity>());
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
assertQuestionGroupForExistingQuestion(questionGroup, QuestionGroupState.ACTIVE);
verify(questionGroupDao).retrieveSectionByNameAndQuestionGroupId("Misc", 123);
verify(questionGroupDao).getDetails(questionGroupId);
verify(sectionQuestionDao).retrieveFromQuestionIdSectionId(222, 999);
verify(eventSourceDao).retrieveByEventAndSource(anyString(), anyString());
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionnaireServiceTest method getSectionDetailWithQuestions.
private SectionDetail getSectionDetailWithQuestions(String name, List<QuestionDetail> questionDetails, String value, boolean mandatory) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
for (QuestionDetail questionDetail : questionDetails) {
SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(questionDetail, mandatory);
sectionQuestionDetail.setValue(value);
sectionQuestionDetails.add(sectionQuestionDetail);
}
sectionDetail.setQuestionDetails(sectionQuestionDetails);
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method getSection.
private SectionDetail getSection(String name) throws SystemException {
SectionDetail section = new SectionDetail();
section.setName(name);
String questionTitle = "Question" + name + currentTimeMillis();
QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.NUMERIC);
section.addQuestion(new SectionQuestionDetail(questionDetail, true));
return section;
}
use of org.mifos.platform.questionnaire.service.SectionQuestionDetail in project head by mifos.
the class SectionQuestionDaoIntegrationTest 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;
}
Aggregations