Search in sources :

Example 1 with SelectionDetail

use of org.mifos.platform.questionnaire.service.SelectionDetail in project head by mifos.

the class QuestionnaireMapperTest method getSelections.

private List<SelectionDetail> getSelections(List<String> answers) {
    List<SelectionDetail> selectionDetails = new ArrayList<SelectionDetail>();
    if (answers != null) {
        for (String answer : answers) {
            SelectionDetail selectionDetail = new SelectionDetail();
            selectionDetail.setSelectedChoice(answer);
            selectionDetails.add(selectionDetail);
        }
    }
    return selectionDetails;
}
Also used : SelectionDetail(org.mifos.platform.questionnaire.service.SelectionDetail) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString)

Example 2 with SelectionDetail

use of org.mifos.platform.questionnaire.service.SelectionDetail in project head by mifos.

the class QuestionnaireMapperTest method getSelectionDetail.

private SelectionDetail getSelectionDetail(String selectedChoice, String selectedTag) {
    SelectionDetail selectionDetail1 = new SelectionDetail();
    selectionDetail1.setSelectedChoice(selectedChoice);
    selectionDetail1.setSelectedTag(selectedTag);
    return selectionDetail1;
}
Also used : SelectionDetail(org.mifos.platform.questionnaire.service.SelectionDetail)

Example 3 with SelectionDetail

use of org.mifos.platform.questionnaire.service.SelectionDetail in project head by mifos.

the class QuestionnaireMapperImpl method setMultiChoiceResponses.

private void setMultiChoiceResponses(List<QuestionGroupResponse> questionGroupResponses, SectionQuestionDetail sectionQuestionDetail) {
    List<SelectionDetail> answers = new ArrayList<SelectionDetail>();
    for (QuestionGroupResponse questionGroupResponse : questionGroupResponses) {
        if (questionGroupResponse.getSectionQuestion().getId() == sectionQuestionDetail.getId()) {
            answers.add(mapToSelectionDetail(questionGroupResponse));
        }
    }
    sectionQuestionDetail.setSelections(answers);
}
Also used : QuestionGroupResponse(org.mifos.platform.questionnaire.domain.QuestionGroupResponse) SelectionDetail(org.mifos.platform.questionnaire.service.SelectionDetail) ArrayList(java.util.ArrayList)

Example 4 with SelectionDetail

use of org.mifos.platform.questionnaire.service.SelectionDetail in project head by mifos.

the class QuestionnaireMapperImpl method mapToSelectionDetail.

private SelectionDetail mapToSelectionDetail(QuestionGroupResponse questionGroupResponse) {
    SelectionDetail selectionDetail = new SelectionDetail();
    selectionDetail.setSelectedChoice(questionGroupResponse.getResponse());
    selectionDetail.setSelectedTag(questionGroupResponse.getTag());
    return selectionDetail;
}
Also used : SelectionDetail(org.mifos.platform.questionnaire.service.SelectionDetail)

Example 5 with SelectionDetail

use of org.mifos.platform.questionnaire.service.SelectionDetail in project head by mifos.

the class QuestionnaireMapperTest method shouldMapToQuestionGroupInstanceDetails.

@Test
public void shouldMapToQuestionGroupInstanceDetails() {
    QuestionGroupInstance questionGroupInstance1 = getQuestionGroupInstance("QG1", 2010, 7, 25);
    QuestionGroupInstance questionGroupInstance2 = getQuestionGroupInstance("QG3", 2009, 2, 12);
    QuestionGroup questionGroup = getQuestionGroup(1991, "QG5", getSectionWithOneMultiSelectQuestion(222, "Section3", "Question3", "Choice1", "Choice2", "Choice3", "Choice4"));
    QuestionGroupInstance questionGroupInstance3 = getQuestionGroupInstanceWithSingleMultiSelectQuestion(101, 3, questionGroup, "Choice1", "Choice3", "Choice4");
    List<QuestionGroupInstance> questionGroupInstances = asList(questionGroupInstance1, questionGroupInstance2, questionGroupInstance3);
    List<QuestionGroupInstanceDetail> questionGroupInstanceDetails = questionnaireMapper.mapToQuestionGroupInstanceDetails(questionGroupInstances);
    assertThat(questionGroupInstanceDetails, is(notNullValue()));
    assertThat(questionGroupInstanceDetails.size(), is(3));
    assertQuestionGroupInstanceDetail(questionGroupInstanceDetails.get(0), "QG1", 2010, 7, 25);
    assertQuestionGroupInstanceDetail(questionGroupInstanceDetails.get(1), "QG3", 2009, 2, 12);
    QuestionGroupInstanceDetail detail = questionGroupInstanceDetails.get(2);
    assertThat(detail.getQuestionGroupTitle(), is("QG5"));
    List<SelectionDetail> values = detail.getQuestionGroupDetail().getSectionDetail(0).getQuestionDetail(0).getSelections();
    assertThat(values, is(notNullValue()));
    assertThat(values.size(), is(3));
    assertThat(values.get(0).getSelectedChoice(), is("Choice1"));
    assertThat(values.get(1).getSelectedChoice(), is("Choice3"));
    assertThat(values.get(2).getSelectedChoice(), is("Choice4"));
}
Also used : SelectionDetail(org.mifos.platform.questionnaire.service.SelectionDetail) QuestionGroupInstance(org.mifos.platform.questionnaire.domain.QuestionGroupInstance) QuestionGroup(org.mifos.platform.questionnaire.domain.QuestionGroup) QuestionGroupInstanceDetail(org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail) Test(org.junit.Test)

Aggregations

SelectionDetail (org.mifos.platform.questionnaire.service.SelectionDetail)5 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)1 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)1 QuestionGroupInstance (org.mifos.platform.questionnaire.domain.QuestionGroupInstance)1 QuestionGroupResponse (org.mifos.platform.questionnaire.domain.QuestionGroupResponse)1 QuestionGroupInstanceDetail (org.mifos.platform.questionnaire.service.QuestionGroupInstanceDetail)1 Matchers.anyString (org.mockito.Matchers.anyString)1