use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class QuestionnaireServiceTest method shouldDefineQuestionWithAnswerChoices.
@Test
public void shouldDefineQuestionWithAnswerChoices() throws SystemException {
ChoiceDto choice1 = new ChoiceDto("choice1");
ChoiceDto choice2 = new ChoiceDto("choice2");
List<ChoiceDto> answerChoices = asList(choice1, choice2);
QuestionDetail questionDefinition = new QuestionDetail(QUESTION_TITLE, QuestionType.MULTI_SELECT);
questionDefinition.setAnswerChoices(answerChoices);
try {
QuestionDetail questionDetail = questionnaireService.defineQuestion(questionDefinition);
verify(questionDao, times(1)).saveOrUpdate(any(QuestionEntity.class));
Assert.assertNotNull(questionDetail);
Assert.assertEquals(QUESTION_TITLE, questionDetail.getText());
Assert.assertEquals(QuestionType.MULTI_SELECT, questionDetail.getType());
Assert.assertEquals(choice1.getValue(), questionDetail.getAnswerChoices().get(0).getValue());
Assert.assertEquals(choice2.getValue(), questionDetail.getAnswerChoices().get(1).getValue());
} catch (SystemException e) {
Assert.fail("Should not have thrown the validation exception");
}
verify(questionnaireValidator).validateForDefineQuestion(questionDefinition);
verify(questionDao).saveOrUpdate(any(QuestionEntity.class));
}
use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class CenterCustActionTest method getSectionDetail.
private SectionDetail getSectionDetail(String name, String title, List<String> answerChoices) {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.setName(name);
QuestionDetail questionDetail = new QuestionDetail(111, title, QuestionType.SINGLE_SELECT, true, true);
List<ChoiceDto> choiceDtos = new ArrayList<ChoiceDto>();
for (String answerChoice : answerChoices) {
choiceDtos.add(new ChoiceDto(answerChoice));
}
questionDetail.setAnswerChoices(choiceDtos);
sectionDetail.setQuestionDetails(asList(new SectionQuestionDetail(questionDetail, true)));
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.dtos.ChoiceDto in project head by mifos.
the class QuestionnaireServiceFacadeTest method testGetQuestionWithAnswerChoicesById.
@Test
public void testGetQuestionWithAnswerChoicesById() throws SystemException {
int questionId = 1;
String title = "Title";
List<ChoiceDto> answerChoices = asList(new ChoiceDto("choice1"), new ChoiceDto("choice2"));
QuestionDetail expectedQuestionDetail = new QuestionDetail(questionId, title, QuestionType.MULTI_SELECT, true, true);
expectedQuestionDetail.setAnswerChoices(answerChoices);
when(questionnaireService.getQuestion(questionId)).thenReturn(expectedQuestionDetail);
QuestionDetail questionDetail = questionnaireServiceFacade.getQuestionDetail(questionId);
Assert.assertNotNull("Question group should not be null", questionDetail);
assertThat(questionDetail, new QuestionDetailMatcher(expectedQuestionDetail));
Mockito.verify(questionnaireService).getQuestion(questionId);
}
Aggregations