use of org.mifos.platform.questionnaire.ui.model.Question in project head by mifos.
the class QuestionTest method testAddSmartChoice.
@Test
public void testAddSmartChoice() {
Question question = new Question(new QuestionDetail());
question.setCurrentSmartChoice("Choice1");
question.addAnswerSmartChoice();
assertThat(question.getCurrentSmartChoice(), is(nullValue()));
assertThat(question.getCurrentSmartChoiceTags().size(), is(1));
assertThat(question.getCurrentSmartChoiceTags().get(0), is(""));
question.setCurrentSmartChoice("Choice2");
question.addAnswerSmartChoice();
assertThat(question.getCurrentSmartChoice(), is(nullValue()));
assertThat(question.getCurrentSmartChoiceTags().size(), is(2));
assertThat(question.getCurrentSmartChoiceTags().get(0), is(""));
assertThat(question.getCurrentSmartChoiceTags().get(1), is(""));
}
use of org.mifos.platform.questionnaire.ui.model.Question in project head by mifos.
the class QuestionTest method testQuestionTypeConversion.
@Test
public void testQuestionTypeConversion() {
Question question = new Question(new QuestionDetail());
question.setType("number");
assertThat(question.getType(), is("number"));
question.setType("freeText");
assertThat(question.getType(), is("freeText"));
question.setType("date");
assertThat(question.getType(), is("date"));
question.setType("singleSelect");
assertThat(question.getType(), is("singleSelect"));
question.setType("number");
assertThat(question.getType(), is("number"));
question.setType("multiSelect");
assertThat(question.getType(), is("multiSelect"));
question.setType("Multi Selects");
Assert.assertNull(question.getType());
}
use of org.mifos.platform.questionnaire.ui.model.Question in project head by mifos.
the class QuestionGroupFormTest method testIsDuplicateTitle.
@Test
public void testIsDuplicateTitle() {
QuestionGroupForm questionGroupForm = new QuestionGroupForm();
String title = "title";
questionGroupForm.setTitle(title);
String sectionName = "SectionWithNewQuestion";
Question currentQuestion = new Question(new QuestionDetail());
currentQuestion.setText(" Question1 ");
currentQuestion.setType("freeText");
questionGroupForm.setCurrentQuestion(currentQuestion);
questionGroupForm.setAddQuestionFlag(true);
questionGroupForm.setSectionName(sectionName);
questionGroupForm.addCurrentSection();
questionGroupForm.getCurrentQuestion().setText("Question2 ");
questionGroupForm.addCurrentSection();
assertThat(questionGroupForm.isDuplicateText("Question1"), is(true));
}
use of org.mifos.platform.questionnaire.ui.model.Question in project head by mifos.
the class QuestionGroupFormTest method testAddCurrentSectionForAddQuestion.
@Test
public void testAddCurrentSectionForAddQuestion() {
QuestionGroupForm questionGroupForm = new QuestionGroupForm();
String title = "title";
questionGroupForm.setTitle(title);
String sectionName = "SectionWithNewQuestion";
Question currentQuestion = new Question(new QuestionDetail());
currentQuestion.setText(" Question1 ");
currentQuestion.setType("freeText");
questionGroupForm.setCurrentQuestion(currentQuestion);
questionGroupForm.setAddQuestionFlag(true);
questionGroupForm.setSectionName(sectionName);
questionGroupForm.addCurrentSection();
List<SectionDetailForm> sections = questionGroupForm.getSections();
assertThat(sections.size(), is(1));
SectionDetailForm section1 = sections.get(0);
assertThat(section1.getName(), is(sectionName));
assertThat(section1.getSectionQuestionDetails().get(0).getText(), is("Question1"));
assertThat(questionGroupForm.getSectionName(), is(section1.getName()));
}
use of org.mifos.platform.questionnaire.ui.model.Question in project head by mifos.
the class QuestionTest method testAddSmartChoiceTagUptoFiveTags.
@Test
public void testAddSmartChoiceTagUptoFiveTags() {
QuestionDetail questionDetail = new QuestionDetail();
Question question = new Question(questionDetail);
question.setCurrentSmartChoice("Choice1");
question.addAnswerSmartChoice();
question.getCurrentSmartChoiceTags().set(0, "Tag_1");
question.addSmartChoiceTag(0);
question.getCurrentSmartChoiceTags().set(0, "Tag_2");
question.addSmartChoiceTag(0);
question.getCurrentSmartChoiceTags().set(0, "Tag_3");
question.addSmartChoiceTag(0);
question.getCurrentSmartChoiceTags().set(0, "Tag_4");
question.addSmartChoiceTag(0);
question.getCurrentSmartChoiceTags().set(0, "Tag_5");
question.addSmartChoiceTag(0);
assertThat(questionDetail.getAnswerChoices().get(0).getTags().size(), is(5));
question.getCurrentSmartChoiceTags().set(0, "Tag_6");
question.addSmartChoiceTag(0);
assertThat(questionDetail.getAnswerChoices().get(0).getTags().size(), is(5));
assertThat(question.getCurrentSmartChoiceTags().get(0), is(""));
}
Aggregations