Search in sources :

Example 1 with QuestionGroupResponse

use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.

the class QuestionnaireMapperImpl method mapToQuestionGroupResponse.

private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, SectionQuestion sectionQuestion, SelectionDetail selectionDetail) {
    QuestionGroupResponse questionGroupResponse = mapToQuestionGroupResponse(questionGroupInstance, sectionQuestion, selectionDetail.getSelectedChoice());
    questionGroupResponse.setTag(selectionDetail.getSelectedTag());
    return questionGroupResponse;
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse)

Example 2 with QuestionGroupResponse

use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.

the class QuestionnaireMapperImpl method mapToQuestionGroupResponse.

private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, QuestionGroupResponseDto questionGroupResponseDto) {
    QuestionGroupResponse questionGroupResponse = new QuestionGroupResponse();
    questionGroupResponse.setResponse(questionGroupResponseDto.getResponse());
    questionGroupResponse.setQuestionGroupInstance(questionGroupInstance);
    SectionQuestion sq;
    if (sectionQuestionMap.containsKey(questionGroupResponseDto.getSectionQuestionId())) {
        sq = sectionQuestionMap.get(questionGroupResponseDto.getSectionQuestionId());
    } else {
        sq = sectionQuestionDao.getDetails(questionGroupResponseDto.getSectionQuestionId());
        sectionQuestionMap.put(questionGroupResponseDto.getSectionQuestionId(), sq);
    }
    questionGroupResponse.setSectionQuestion(sq);
    return questionGroupResponse;
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse) SectionQuestion(org.mifos.platform.questionnaire.domain.SectionQuestion)

Example 3 with QuestionGroupResponse

use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.

the class QuestionnaireMapperImpl method mapToQuestionGroupResponse.

private QuestionGroupResponse mapToQuestionGroupResponse(QuestionGroupInstance questionGroupInstance, SectionQuestion sectionQuestion, String value) {
    QuestionGroupResponse questionGroupResponse = new QuestionGroupResponse();
    questionGroupResponse.setSectionQuestion(sectionQuestion);
    questionGroupResponse.setResponse(value);
    questionGroupResponse.setQuestionGroupInstance(questionGroupInstance);
    return questionGroupResponse;
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse)

Example 4 with QuestionGroupResponse

use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse in project head by mifos.

the class QuestionnaireMapperTest method getQuestionGroupResponse.

private QuestionGroupResponse getQuestionGroupResponse(String response, QuestionGroupInstance instance, SectionQuestion sectionQuestion) {
    QuestionGroupResponse questionGroupResponse = new QuestionGroupResponse();
    questionGroupResponse.setResponse(response);
    questionGroupResponse.setQuestionGroupInstance(instance);
    questionGroupResponse.setSectionQuestion(sectionQuestion);
    return questionGroupResponse;
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse)

Example 5 with QuestionGroupResponse

use of org.mifos.platform.questionnaire.domain.QuestionGroupResponse 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)

Aggregations

QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)13 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)7 Test (org.junit.Test)5 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)4 ArrayList (java.util.ArrayList)3 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)3 Transactional (org.springframework.transaction.annotation.Transactional)3 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)2 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)2 QuestionGroupInstanceDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupInstanceDto)2 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)1 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)1 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)1 SelectionDetail (org.mifos.platform.questionnaire.service.SelectionDetail)1 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)1 Matchers.anyString (org.mockito.Matchers.anyString)1