use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireMapperTest method getSectionDetailWithQuestions.
private SectionDetail getSectionDetailWithQuestions(int id, String name, List<QuestionDetail> questionDetails, String answer, List<String> answers) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
for (QuestionDetail questionDetail : questionDetails) {
SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(id, questionDetail, false, answer, getSelections(answers));
sectionQuestionDetails.add(sectionQuestionDetail);
}
sectionDetail.setQuestionDetails(sectionQuestionDetails);
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireMapperTest method assertQuestionType.
private void assertQuestionType(QuestionType questionType, AnswerType answerType) {
QuestionDetail questionDetail = questionnaireMapper.mapToQuestionDetail(getQuestion(TITLE, answerType));
assertThat(questionDetail.getType(), is(questionType));
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireServiceTest method testGetNumericQuestionByIdSuccess.
@Test
public void testGetNumericQuestionByIdSuccess() throws SystemException {
int questionId = 1;
String title = "Title";
QuestionEntity question = getQuestion(questionId, title, AnswerType.NUMBER);
question.setNumericMin(10);
question.setNumericMax(100);
when(questionDao.getDetails(questionId)).thenReturn(question);
QuestionDetail questionDetail = questionnaireService.getQuestion(questionId);
Assert.assertNotNull(questionDetail);
assertThat(questionDetail.getText(), is(title));
assertThat(questionDetail.getType(), is(QuestionType.NUMERIC));
assertThat(questionDetail.getNumericMin(), is(10));
assertThat(questionDetail.getNumericMax(), is(100));
verify(questionDao, times(1)).getDetails(questionId);
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireMapperTest method shouldMapQuestionDetailToQuestion.
@Test
public void shouldMapQuestionDetailToQuestion() {
QuestionDetail questionDefinition = new QuestionDetail(TITLE, QuestionType.FREETEXT);
questionDefinition.setActive(false);
QuestionEntity question = questionnaireMapper.mapToQuestion(questionDefinition);
assertThat(question.getAnswerTypeAsEnum(), CoreMatchers.is(AnswerType.FREETEXT));
assertThat(question.getQuestionText(), is(TITLE));
assertThat(question.getQuestionStateAsEnum(), is(QuestionState.INACTIVE));
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireMapperTest method getSectionDetailWithQuestions.
private SectionDetail getSectionDetailWithQuestions(int id, String name, List<QuestionDetail> questionDetails, List<SelectionDetail> answers) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
List<SectionQuestionDetail> sectionQuestionDetails = new ArrayList<SectionQuestionDetail>();
for (QuestionDetail questionDetail : questionDetails) {
SectionQuestionDetail sectionQuestionDetail = new SectionQuestionDetail(id, questionDetail, false, null, answers);
sectionQuestionDetails.add(sectionQuestionDetail);
}
sectionDetail.setQuestionDetails(sectionQuestionDetails);
return sectionDetail;
}
Aggregations