use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionGroupInstanceDaoIntegrationTest method getSection.
private SectionDetail getSection(String name) throws SystemException {
SectionDetail section = new SectionDetail();
section.setName(name);
String questionTitle = "Question" + name + currentTimeMillis();
QuestionDetail questionDetail = defineQuestion(questionTitle, QuestionType.NUMERIC);
section.addQuestion(new SectionQuestionDetail(questionDetail, true));
return section;
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionControllerTest method testAddQuestionWhenTitleIsEditedToOneAlreadyInDB.
@Test
public void testAddQuestionWhenTitleIsEditedToOneAlreadyInDB() throws Exception {
Question currentQuestion = new Question();
QuestionDetail questionDetail = new QuestionDetail();
questionDetail.setText(TITLE);
currentQuestion.setQuestionDetail(questionDetail);
QuestionForm questionForm = new QuestionForm();
questionForm.setCurrentQuestion(currentQuestion);
questionForm.getCurrentQuestion().setText(TITLE + 1);
when(requestContext.getMessageContext()).thenReturn(messageContext);
when(questionnaireServiceFacade.isDuplicateQuestion(TITLE + 1)).thenReturn(true);
String result = questionController.addQuestion(questionForm, requestContext, false);
Assert.assertThat(questionForm.getQuestions().size(), is(0));
Assert.assertThat(result, is("failure"));
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionControllerTest method testAddQuestionWhenTitleIsEdited.
@Test
public void testAddQuestionWhenTitleIsEdited() throws Exception {
Question currentQuestion = new Question();
QuestionDetail questionDetail = new QuestionDetail();
questionDetail.setText(TITLE);
questionDetail.setType(QuestionType.SINGLE_SELECT);
questionDetail.setAnswerChoices(new ArrayList<ChoiceDto>(Arrays.asList(new ChoiceDto("choice1"), new ChoiceDto("choice2"))));
currentQuestion.setQuestionDetail(questionDetail);
currentQuestion.setCurrentChoice("choice3");
currentQuestion.addAnswerChoice();
QuestionForm questionForm = new QuestionForm();
questionForm.setCurrentQuestion(currentQuestion);
questionForm.getCurrentQuestion().setText(TITLE + 1);
when(requestContext.getMessageContext()).thenReturn(messageContext);
when(questionnaireServiceFacade.isDuplicateQuestion(TITLE + 1)).thenReturn(false);
String result = questionController.addQuestion(questionForm, requestContext, false);
Assert.assertThat(questionForm.getQuestions().size(), is(1));
Assert.assertThat(questionForm.getQuestions().get(0).getInitialNumberOfChoices(), is(2));
Assert.assertThat(questionForm.getQuestions().get(0).getChoices().size(), is(3));
Assert.assertThat(result, is("success"));
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionControllerTest method testAddQuestionDuringEditOperationWhereTitleIsUnchanged.
@Test
public void testAddQuestionDuringEditOperationWhereTitleIsUnchanged() throws Exception {
Question currentQuestion = new Question();
QuestionDetail questionDetail = new QuestionDetail();
questionDetail.setText(TITLE);
currentQuestion.setQuestionDetail(questionDetail);
QuestionForm questionForm = new QuestionForm();
questionForm.setCurrentQuestion(currentQuestion);
when(requestContext.getMessageContext()).thenReturn(messageContext);
when(questionnaireServiceFacade.isDuplicateQuestion(TITLE)).thenReturn(true);
String result = questionController.addQuestion(questionForm, requestContext, false);
Assert.assertThat(questionForm.getQuestions().size(), is(1));
Assert.assertThat(result, is("success"));
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionFormTest method getQuestion.
private Question getQuestion(String title) {
Question question = new Question(new QuestionDetail());
question.setText(title);
return question;
}
Aggregations