Search in sources :

Example 16 with QuestionDetail

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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 17 with QuestionDetail

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

Example 18 with QuestionDetail

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);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 19 with QuestionDetail

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));
}
Also used : QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 20 with QuestionDetail

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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) ArrayList(java.util.ArrayList) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Aggregations

QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)72 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)55 Test (org.junit.Test)44 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)24 Question (org.mifos.platform.questionnaire.ui.model.Question)16 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)13 ArrayList (java.util.ArrayList)11 SystemException (org.mifos.framework.exceptions.SystemException)11 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)9 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)8 ValidationException (org.mifos.platform.validations.ValidationException)5 QuestionForm (org.mifos.platform.questionnaire.ui.model.QuestionForm)4 Matchers.anyString (org.mockito.Matchers.anyString)4 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)3 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)3 BadNumericResponseException (org.mifos.platform.questionnaire.exceptions.BadNumericResponseException)3 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)3 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)2