use of org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldDefineSingleSelectQuestion.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldDefineSingleSelectQuestion() throws SystemException {
String questionTitle = TITLE + currentTimeMillis();
QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.SINGLE_SELECT, asList("choice1", "choice2"));
assertNotNull(questionDetail);
Integer questionId = questionDetail.getId();
assertNotNull(questionId);
QuestionEntity questionEntity = questionDao.getDetails(questionId);
assertNotNull(questionEntity);
Assert.assertEquals(questionTitle, questionEntity.getQuestionText());
Assert.assertEquals(AnswerType.SINGLESELECT, questionEntity.getAnswerTypeAsEnum());
assertThat(questionEntity.getChoices(), new QuestionChoicesMatcher(asList(new QuestionChoiceEntity("choice1"), new QuestionChoiceEntity("choice2"))));
}
use of org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldDefineMultiSelectQuestion.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldDefineMultiSelectQuestion() throws SystemException {
String questionTitle = TITLE + currentTimeMillis();
QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.MULTI_SELECT, asList("choice1", "choice2"));
Assert.assertNotNull(questionDetail);
Integer questionId = questionDetail.getId();
assertNotNull(questionId);
QuestionEntity questionEntity = questionDao.getDetails(questionId);
assertNotNull(questionEntity);
Assert.assertEquals(questionTitle, questionEntity.getQuestionText());
Assert.assertEquals(AnswerType.MULTISELECT, questionEntity.getAnswerTypeAsEnum());
assertThat(questionEntity.getChoices(), new QuestionChoicesMatcher(asList(new QuestionChoiceEntity("choice1"), new QuestionChoiceEntity("choice2"))));
}
use of org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher 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.matchers.QuestionChoicesMatcher 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.matchers.QuestionChoicesMatcher in project head by mifos.
the class QuestionnaireMapperTest method shouldMapSmartSelectQuestionDetailToQuestion.
@Test
public void shouldMapSmartSelectQuestionDetailToQuestion() {
ChoiceDto choice1 = new ChoiceDto("choice1");
choice1.setTags(asList("Tag1", "Tag2"));
ChoiceDto choice2 = new ChoiceDto("choice2");
choice2.setTags(asList("Tag3"));
QuestionDetail questionDefinition = new QuestionDetail(TITLE, QuestionType.SMART_SELECT);
questionDefinition.setActive(true);
questionDefinition.setAnswerChoices(asList(choice1, choice2));
QuestionEntity question = questionnaireMapper.mapToQuestion(questionDefinition);
assertThat(question.getAnswerTypeAsEnum(), is(AnswerType.SMARTSELECT));
assertThat(question.getQuestionText(), is(TITLE));
assertThat(question.getChoices(), new QuestionChoicesMatcher(asList(getChoiceEntity("choice1", "Tag1", "Tag2"), getChoiceEntity("choice2", "Tag3"))));
assertThat(question.getQuestionStateAsEnum(), is(QuestionState.ACTIVE));
}
Aggregations