Search in sources :

Example 6 with QuestionEntity

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);
}
Also used : QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity)

Example 7 with 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"))));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with QuestionEntity

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"))));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with QuestionEntity

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));
}
Also used : QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with QuestionEntity

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());
}
Also used : QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)25 Test (org.junit.Test)16 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)9 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)7 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)7 Transactional (org.springframework.transaction.annotation.Transactional)7 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)5 Section (org.mifos.platform.questionnaire.domain.Section)3 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)3 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)3 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)3 EventSourceEntity (org.mifos.platform.questionnaire.domain.EventSourceEntity)2 QuestionGroup (org.mifos.platform.questionnaire.domain.QuestionGroup)2 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)2 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)2 Matchers.anyString (org.mockito.Matchers.anyString)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 QuestionDtoBuilder (org.mifos.platform.questionnaire.builders.QuestionDtoBuilder)1 QuestionType (org.mifos.platform.questionnaire.service.QuestionType)1