use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionnaireValidatorTest method shouldNotThrowExceptionForNumericQuestionTypeWhenOnlyMaxBoundGiven.
@Test
public void shouldNotThrowExceptionForNumericQuestionTypeWhenOnlyMaxBoundGiven() {
try {
QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
questionDetail.setNumericMax(-100);
questionnaireValidator.validateForDefineQuestion(questionDetail);
} catch (SystemException e) {
fail("Should not have thrown the exception");
}
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionTest method testAddSmartChoiceTag.
@Test
public void testAddSmartChoiceTag() {
QuestionDetail questionDetail = new QuestionDetail();
Question question = new Question(questionDetail);
question.setCurrentSmartChoice("Choice1");
question.addAnswerSmartChoice();
question.setCurrentSmartChoice("Choice2");
question.addAnswerSmartChoice();
question.getCurrentSmartChoiceTags().set(1, "Tag1");
question.addSmartChoiceTag(0);
assertThat(questionDetail.getAnswerChoices().get(0).getTags().size(), is(0));
assertThat(questionDetail.getAnswerChoices().get(1).getTags().size(), is(0));
question.addSmartChoiceTag(1);
assertThat(questionDetail.getAnswerChoices().get(1).getTags().get(0), is("Tag1"));
assertThat(question.getCurrentSmartChoiceTags().get(1), is(""));
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionTest method testAddAnswerChoice.
@Test
public void testAddAnswerChoice() {
Question question = new Question(new QuestionDetail());
question.setCurrentChoice("choice1");
question.addAnswerChoice();
question.setCurrentChoice("choice2");
question.addAnswerChoice();
question.setCurrentChoice("choice1");
question.addAnswerChoice();
question.setCurrentChoice("choice3");
question.addAnswerChoice();
assertThat(question.getChoices().size(), is(4));
assertThat(question.getCurrentSmartChoiceTags().size(), is(4));
assertEquals("choice1", question.getChoices().get(0).getValue());
assertEquals("choice2", question.getChoices().get(1).getValue());
assertEquals("choice1", question.getChoices().get(2).getValue());
assertEquals("choice3", question.getChoices().get(3).getValue());
assertEquals("choice1, choice2, choice1, choice3", question.getCommaSeparateChoices());
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionTest method assertQuestion.
private void assertQuestion(String text, QuestionType questionType, String questionTypeString, List<String> choices) {
QuestionDetail questionDetail = new QuestionDetail(123, text, questionType, true, true);
List<ChoiceDto> choiceDtos = getChoiceDetails(choices);
questionDetail.setAnswerChoices(choiceDtos);
Question question = new Question(questionDetail);
assertThat(question.getText(), is(text));
assertThat(question.getType(), is(questionTypeString));
assertEquals(question.getChoices(), choiceDtos);
}
use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.
the class QuestionTest method testAddSmartChoiceTagDoesnotAllowDuplicates.
@Test
public void testAddSmartChoiceTagDoesnotAllowDuplicates() {
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_1");
question.addSmartChoiceTag(0);
question.getCurrentSmartChoiceTags().set(0, "Tag_2");
question.addSmartChoiceTag(0);
question.getCurrentSmartChoiceTags().set(0, "TAg_2");
question.addSmartChoiceTag(0);
assertThat(questionDetail.getAnswerChoices().get(0).getTags().size(), is(2));
}
Aggregations