use of org.mifos.platform.questionnaire.ui.model.QuestionForm in project head by mifos.
the class QuestionFormTest method testAddCurrentQuestion.
@Test
public void testAddCurrentQuestion() {
QuestionForm questionForm = getQuestionForm(" Q1 ", "freeText", "choice1");
List<Question> questionList = questionForm.getQuestions();
assertThat(questionList.size(), is(1));
String text = questionList.get(0).getText();
String type = questionList.get(0).getType();
List<ChoiceDto> choices = questionList.get(0).getChoices();
assertNotSame(text, questionForm.getCurrentQuestion().getText());
assertNotSame(type, questionForm.getCurrentQuestion().getType());
assertThat(text, is("Q1"));
assertThat(type, is("freeText"));
assertThat(choices.size(), is(0));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionForm in project head by mifos.
the class QuestionFormTest method testDuplicateQuestionInForm.
@Test
public void testDuplicateQuestionInForm() {
QuestionForm questionForm = new QuestionForm();
questionForm.setQuestions(asList(getQuestion(TITLE), getQuestion(TITLE + 1), getQuestion(TITLE + 2)));
assertThat(questionForm.isDuplicateTitle(TITLE), is(true));
assertThat(questionForm.isDuplicateTitle(" " + TITLE), is(true));
assertThat(questionForm.isDuplicateTitle(TITLE.toUpperCase()), is(true));
assertThat(questionForm.isDuplicateTitle(null), is(false));
assertThat(questionForm.isDuplicateTitle(TITLE + "2"), is(true));
assertThat(questionForm.isDuplicateTitle(TITLE + 3), is(false));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionForm in project head by mifos.
the class QuestionFormTest method testAddCurrentSingleSelectQuestion.
@Test
public void testAddCurrentSingleSelectQuestion() {
QuestionForm questionForm = getQuestionForm("title1", "singleSelect", "choice");
List<Question> questionList = questionForm.getQuestions();
assertThat(questionList.size(), is(1));
String text = questionList.get(0).getText();
String type = questionList.get(0).getType();
List<ChoiceDto> choices = questionList.get(0).getChoices();
assertNotSame(text, questionForm.getCurrentQuestion().getText());
assertNotSame(type, questionForm.getCurrentQuestion().getType());
assertThat(choices.get(0).getValue(), is("choice"));
assertThat(text, is("title1"));
assertThat(type, is("singleSelect"));
}
use of org.mifos.platform.questionnaire.ui.model.QuestionForm in project head by mifos.
the class QuestionFormTest method getQuestionForm.
private QuestionForm getQuestionForm(String title, String type, String choice) {
QuestionForm questionForm = new QuestionForm();
questionForm.getCurrentQuestion().setText(title);
questionForm.getCurrentQuestion().setType(type);
questionForm.getCurrentQuestion().setCurrentChoice(choice);
questionForm.getCurrentQuestion().addAnswerChoice();
questionForm.addCurrentQuestion();
return questionForm;
}
use of org.mifos.platform.questionnaire.ui.model.QuestionForm 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"));
}
Aggregations