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