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;
}
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;
}
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);
}
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;
}
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"));
}
Aggregations