Search in sources :

Example 11 with QuestionChoiceEntity

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

the class QuestionnaireMapperTest method shouldMapSingleSelectQuestionDetailToQuestion.

@Test
public void shouldMapSingleSelectQuestionDetailToQuestion() {
    ChoiceDto choice1 = new ChoiceDto("choice1");
    ChoiceDto choice2 = new ChoiceDto("choice2");
    QuestionDetail questionDefinition = new QuestionDetail(TITLE, QuestionType.SINGLE_SELECT);
    questionDefinition.setAnswerChoices(asList(choice1, choice2));
    QuestionEntity question = questionnaireMapper.mapToQuestion(questionDefinition);
    assertThat(question.getAnswerTypeAsEnum(), is(AnswerType.SINGLESELECT));
    assertThat(question.getQuestionText(), is(TITLE));
    assertThat(question.getChoices(), new QuestionChoicesMatcher(asList(new QuestionChoiceEntity(choice1.getValue()), new QuestionChoiceEntity(choice2.getValue()))));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test)

Example 12 with QuestionChoiceEntity

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

the class QuestionnaireMapperTest method shouldMapMultiSelectQuestionDetailToQuestion.

@Test
public void shouldMapMultiSelectQuestionDetailToQuestion() {
    ChoiceDto choice1 = new ChoiceDto("choice1");
    ChoiceDto choice2 = new ChoiceDto("choice2");
    QuestionDetail questionDefinition = new QuestionDetail(TITLE, QuestionType.MULTI_SELECT);
    questionDefinition.setAnswerChoices(asList(choice1, choice2));
    QuestionEntity question = questionnaireMapper.mapToQuestion(questionDefinition);
    assertThat(question.getAnswerTypeAsEnum(), is(AnswerType.MULTISELECT));
    assertThat(question.getQuestionText(), is(TITLE));
    assertThat(question.getChoices(), new QuestionChoicesMatcher(asList(new QuestionChoiceEntity(choice1.getValue()), new QuestionChoiceEntity(choice2.getValue()))));
    assertThat(question.getQuestionStateAsEnum(), is(QuestionState.ACTIVE));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test)

Example 13 with QuestionChoiceEntity

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

the class QuestionnaireMapperTest method getChoiceEntity.

private QuestionChoiceEntity getChoiceEntity(String choiceText, String... tagTexts) {
    QuestionChoiceEntity choiceEntity = new QuestionChoiceEntity(choiceText);
    Set<ChoiceTagEntity> tags = new HashSet<ChoiceTagEntity>();
    for (String tagText : tagTexts) {
        ChoiceTagEntity choiceTagEntity = new ChoiceTagEntity();
        choiceTagEntity.setTagText(tagText);
        tags.add(choiceTagEntity);
    }
    choiceEntity.setTags(tags);
    return choiceEntity;
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) ChoiceTagEntity(org.mifos.platform.questionnaire.domain.ChoiceTagEntity) Matchers.anyString(org.mockito.Matchers.anyString) HashSet(java.util.HashSet)

Aggregations

QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)13 Test (org.junit.Test)8 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)7 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)4 ChoiceTagEntity (org.mifos.platform.questionnaire.domain.ChoiceTagEntity)3 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)3 QuestionGroupDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto)3 ValidationException (org.mifos.platform.validations.ValidationException)3 Arrays.asList (java.util.Arrays.asList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Section (org.mifos.platform.questionnaire.domain.Section)2 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)2 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1