Search in sources :

Example 21 with Question

use of org.mifos.platform.questionnaire.ui.model.Question in project head by mifos.

the class QuestionControllerTest method testAddQuestionForSuccess.

@Test
public void testAddQuestionForSuccess() throws Exception {
    QuestionForm questionForm = getQuestionForm(TITLE, "numeric");
    when(questionnaireServiceFacade.isDuplicateQuestion(TITLE)).thenReturn(false);
    when(messageContext.getAllMessages()).thenReturn(new Message[] {});
    when(requestContext.getMessageContext()).thenReturn(messageContext);
    String result = questionController.addQuestion(questionForm, requestContext, true);
    List<Question> questions = questionForm.getQuestions();
    Mockito.verify(questionnaireServiceFacade).isDuplicateQuestion(TITLE);
    Assert.assertThat(questions, is(notNullValue()));
    Assert.assertThat(questions.size(), is(1));
    Assert.assertThat(result, is("success"));
}
Also used : QuestionForm(org.mifos.platform.questionnaire.ui.model.QuestionForm) Question(org.mifos.platform.questionnaire.ui.model.Question) Test(org.junit.Test)

Example 22 with Question

use of org.mifos.platform.questionnaire.ui.model.Question 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"));
}
Also used : QuestionForm(org.mifos.platform.questionnaire.ui.model.QuestionForm) Question(org.mifos.platform.questionnaire.ui.model.Question) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) Test(org.junit.Test)

Example 23 with Question

use of org.mifos.platform.questionnaire.ui.model.Question 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;
}
Also used : Question(org.mifos.platform.questionnaire.ui.model.Question) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail)

Aggregations

Question (org.mifos.platform.questionnaire.ui.model.Question)23 Test (org.junit.Test)18 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)16 QuestionForm (org.mifos.platform.questionnaire.ui.model.QuestionForm)8 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)5 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)2 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)2 ArrayList (java.util.ArrayList)1 SectionDetailForm (org.mifos.platform.questionnaire.ui.model.SectionDetailForm)1