use of org.mifos.platform.questionnaire.service.SectionDetail 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()));
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionGroupDefinitionToQuestionGroup.
@Test
public void shouldMapQuestionGroupDefinitionToQuestionGroup() {
when(eventSourceDao.retrieveByEventAndSource(anyString(), anyString())).thenReturn(new ArrayList<EventSourceEntity>());
when(questionDao.getDetails(12)).thenReturn(new QuestionEntity());
EventSourceDto eventSourceDto = getEventSource("Create", "Client");
List<SectionDetail> sectionDetails = asList(getSectionDefinition("S1", 12, TITLE), getSectionDefinition("S2", 0, TITLE));
QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(0, TITLE, Arrays.asList(eventSourceDto), sectionDetails, true);
questionGroupDetail.setActive(false);
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(questionGroupDetail);
assertQuestionGroup(questionGroup, QuestionGroupState.INACTIVE);
assertThat(questionGroup.isEditable(), is(true));
verify(eventSourceDao, times(1)).retrieveByEventAndSource(anyString(), anyString());
verify(questionDao, times(1)).getDetails(12);
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionnaireMapperTest method getSectionDefinition.
private SectionDetail getSectionDefinition(String name, int questionId, String questionTitle) {
SectionDetail section = new SectionDetail();
section.setName(name);
section.addQuestion(new SectionQuestionDetail(new QuestionDetail(questionId, questionTitle, QuestionType.FREETEXT, true, true), true));
return section;
}
use of org.mifos.platform.questionnaire.service.SectionDetail in project head by mifos.
the class QuestionGroupDaoIntegrationTest 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;
}
use of org.mifos.platform.questionnaire.service.SectionDetail 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()));
}
Aggregations