Search in sources :

Example 1 with QuestionGroup

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;
}
Also used : QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup)

Example 2 with 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));
}
Also used : EventSourceEntity(org.mifos.platform.questionnaire.domain.EventSourceEntity) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 3 with QuestionGroup

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);
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionGroupInstanceDto(org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto) QuestionGroupInstance(org.mifos.platform.questionnaire.domain.QuestionGroupInstance) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) Test(org.junit.Test)

Example 4 with QuestionGroup

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()));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with QuestionGroup

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);
}
Also used : QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup)

Aggregations

QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)23 Test (org.junit.Test)15 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)13 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)11 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)7 Transactional (org.springframework.transaction.annotation.Transactional)7 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)6 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)4 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)4 QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)3 Section (org.mifos.platform.questionnaire.domain.Section)3 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)3 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)2 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 SystemException (org.mifos.framework.exceptions.SystemException)1 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)1 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)1 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)1