use of org.mifos.platform.questionnaire.domain.QuestionGroup in project head by mifos.
the class QuestionnaireMapperImpl method mapToQuestionGroup.
@Override
public QuestionGroup mapToQuestionGroup(QuestionGroupDetail questionGroupDetail) {
QuestionGroup questionGroup = getQuestionGroup(questionGroupDetail);
questionGroup.setTitle(questionGroupDetail.getTitle());
questionGroup.setState(QuestionGroupState.getQuestionGroupStateAsEnum(questionGroupDetail.isActive()));
questionGroup.setDateOfCreation(getCurrentDateTime());
questionGroup.setSections(mapToSections(questionGroupDetail));
questionGroup.setEventSources(mapEventSourceDtoToEntity(questionGroupDetail.getEventSources()));
questionGroup.setEditable(questionGroupDetail.isEditable());
questionGroup.setActivityId(questionGroupDetail.getActivityId());
return questionGroup;
}
use of org.mifos.platform.questionnaire.domain.QuestionGroup in project head by mifos.
the class QuestionnaireMapperIntegrationTest method testMapEventSource.
private void testMapEventSource(String event, String source, String description) {
EventSourceDto eventSourceDto = new EventSourceDto(event, source, description);
List<SectionDetail> sectionDetails = getSectionDefinitions();
QuestionGroup questionGroup = questionnaireMapper.mapToQuestionGroup(new QuestionGroupDetail(0, "Title", Arrays.asList(eventSourceDto), sectionDetails, false));
Set<EventSourceEntity> eventSources = questionGroup.getEventSources();
assertThat(eventSources, is(not(nullValue())));
assertThat(eventSources.size(), is(1));
EventSourceEntity eventSourceEntity = eventSources.toArray(new EventSourceEntity[eventSources.size()])[0];
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
assertThat(eventSourceEntity.getEvent().getName(), is(event));
assertThat(eventSourceEntity.getSource().getEntityType(), is(source));
assertThat(eventSourceEntity.getDescription(), is(description));
}
use of org.mifos.platform.questionnaire.domain.QuestionGroup 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.QuestionGroup 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.domain.QuestionGroup in project head by mifos.
the class QuestionnaireServiceIntegrationTest method setState.
private void setState(Integer id, QuestionGroupState questionGroupState) {
QuestionGroup questionGroup = questionGroupDao.getDetails(id);
questionGroup.setState(questionGroupState);
questionGroupDao.update(questionGroup);
}
Aggregations