Search in sources :

Example 1 with QuestionChoicesMatcher

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"))));
}
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 2 with QuestionChoicesMatcher

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"))));
}
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 3 with QuestionChoicesMatcher

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()))));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test)

Example 4 with QuestionChoicesMatcher

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));
}
Also used : QuestionChoiceEntity(org.mifos.platform.questionnaire.domain.QuestionChoiceEntity) QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test)

Example 5 with QuestionChoicesMatcher

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));
}
Also used : QuestionEntity(org.mifos.platform.questionnaire.domain.QuestionEntity) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionChoicesMatcher(org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)5 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)5 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)4 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)3 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)3 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)3 Transactional (org.springframework.transaction.annotation.Transactional)2