use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireServiceIntegrationTest method createSingleSelectQuestion.
private void createSingleSelectQuestion(String ques1Title) {
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setAnswerType(AnswerType.SINGLESELECT);
questionEntity.setQuestionState(QuestionState.INACTIVE);
questionEntity.setNickname(ques1Title);
questionEntity.setQuestionText(ques1Title);
questionEntity.setChoices(asList(getChoice("Ch2", 1), getChoice("Ch1", 2), getChoice("Ch3", 3)));
questionDao.create(questionEntity);
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity 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.QuestionEntity 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.QuestionEntity in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldSaveQuestionWithSmartSelectOptionType.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldSaveQuestionWithSmartSelectOptionType() {
String quesTitle = "Ques" + currentTimeMillis();
QuestionEntity questionEntity = new QuestionEntity();
questionEntity.setAnswerType(AnswerType.SMARTSELECT);
questionEntity.setQuestionState(QuestionState.ACTIVE);
questionEntity.setNickname(quesTitle);
questionEntity.setQuestionText(quesTitle);
questionEntity.setChoices(asList(getChoice("Choice1", 0, "Tag1", "Tag2"), getChoice("Choice2", 1, "Tag4")));
Integer quesId = questionDao.create(questionEntity);
QuestionEntity newQuestionEntity = questionDao.getDetails(quesId);
assertThat(newQuestionEntity, is(notNullValue()));
assertThat(newQuestionEntity.getAnswerTypeAsEnum(), is(AnswerType.SMARTSELECT));
assertThat(newQuestionEntity.getChoices(), is(notNullValue()));
assertThat(newQuestionEntity.getChoices().size(), is(2));
assertThat(newQuestionEntity.getChoices().get(0).getChoiceText(), is("Choice1"));
assertThat(newQuestionEntity.getChoices().get(0).getTags(), is(notNullValue()));
assertThat(newQuestionEntity.getChoices().get(0).getTags().size(), is(2));
assertThat(newQuestionEntity.getChoices().get(1).getChoiceText(), is("Choice2"));
assertThat(newQuestionEntity.getChoices().get(1).getTags(), is(notNullValue()));
assertThat(newQuestionEntity.getChoices().get(1).getTags().size(), is(1));
}
use of org.mifos.platform.questionnaire.domain.QuestionEntity in project head by mifos.
the class QuestionnaireServiceIntegrationTest method shouldDefineQuestion.
@Test
@Transactional(rollbackFor = DataAccessException.class)
public void shouldDefineQuestion() throws SystemException {
String questionTitle = TITLE + currentTimeMillis();
QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.DATE, true);
assertNotNull(questionDetail);
Integer questionId = questionDetail.getId();
assertNotNull(questionId);
QuestionEntity questionEntity = questionDao.getDetails(questionId);
assertNotNull(questionEntity);
Assert.assertEquals(questionTitle, questionEntity.getQuestionText());
Assert.assertEquals(AnswerType.DATE, questionEntity.getAnswerTypeAsEnum());
Assert.assertEquals(questionDetail.getAnswerChoices(), asList());
}
Aggregations