use of org.mifos.platform.questionnaire.service.QuestionDetail 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.service.QuestionDetail in project head by mifos.
the class SectionDetailFormTest method getSectionDefinition.
private SectionDetail getSectionDefinition() {
SectionDetail sectionDetail = new SectionDetail();
sectionDetail.addQuestion(new SectionQuestionDetail(new QuestionDetail(121, "Question1", QuestionType.FREETEXT, true, true), true));
sectionDetail.addQuestion(new SectionQuestionDetail(new QuestionDetail(122, "Question2", QuestionType.FREETEXT, true, true), false));
sectionDetail.addQuestion(new SectionQuestionDetail(new QuestionDetail(123, "Question3", QuestionType.FREETEXT, true, true), true));
return sectionDetail;
}
use of org.mifos.platform.questionnaire.service.QuestionDetail 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.service.QuestionDetail 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.service.QuestionDetail 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