use of org.mifos.platform.questionnaire.domain.QuestionChoiceEntity in project head by mifos.
the class QuestionnaireMapperTest method getSection.
private Section getSection(String sectionName, int questionId) {
Section section = new Section(sectionName);
SectionQuestion sectionQuestion = new SectionQuestion();
QuestionEntity question = new QuestionEntity();
question.setQuestionId(questionId);
question.setQuestionText(sectionName);
question.setAnswerType(AnswerType.DATE);
question.setChoices(new LinkedList<QuestionChoiceEntity>());
sectionQuestion.setQuestion(question);
section.setQuestions(asList(sectionQuestion));
return section;
}
use of org.mifos.platform.questionnaire.domain.QuestionChoiceEntity 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.domain.QuestionChoiceEntity in project head by mifos.
the class QuestionnaireServiceIntegrationTest method getChoice.
private QuestionChoiceEntity getChoice(String choiceText, int choiceOrder, String... tagTexts) {
QuestionChoiceEntity questionChoiceEntity = new QuestionChoiceEntity();
questionChoiceEntity.setChoiceText(choiceText);
questionChoiceEntity.setChoiceOrder(choiceOrder);
Set<ChoiceTagEntity> tags = new HashSet<ChoiceTagEntity>();
for (String tagText : tagTexts) {
tags.add(getTag(tagText));
}
questionChoiceEntity.setTags(tags);
return questionChoiceEntity;
}
use of org.mifos.platform.questionnaire.domain.QuestionChoiceEntity 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.domain.QuestionChoiceEntity in project head by mifos.
the class QuestionnaireMapperTest method getSectionWithOneMultiSelectQuestion.
private Section getSectionWithOneMultiSelectQuestion(int sectionQuestionId, String sectionName, String questionName, String... choices) {
Section section = new Section(sectionName);
List<SectionQuestion> sectionQuestions = new ArrayList<SectionQuestion>();
SectionQuestion sectionQuestion = new SectionQuestion();
sectionQuestion.setId(sectionQuestionId);
sectionQuestion.setSection(section);
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setQuestionText(questionName);
questionEntity.setAnswerType(AnswerType.MULTISELECT);
LinkedList<QuestionChoiceEntity> questionChoiceEntities = new LinkedList<QuestionChoiceEntity>();
for (String choice : choices) {
QuestionChoiceEntity questionChoiceEntity = new QuestionChoiceEntity();
questionChoiceEntity.setChoiceText(choice);
questionChoiceEntities.add(questionChoiceEntity);
}
questionEntity.setChoices(questionChoiceEntities);
sectionQuestion.setQuestion(questionEntity);
sectionQuestions.add(sectionQuestion);
section.setQuestions(sectionQuestions);
return section;
}
Aggregations