Search in sources :

Example 11 with Question

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

Example 12 with Question

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

Example 13 with Question

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

Example 14 with Question

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()));
}
Also used : SectionDetailForm(org.mifos.platform.questionnaire.ui.model.SectionDetailForm) QuestionGroupForm(org.mifos.platform.questionnaire.ui.model.QuestionGroupForm) Question(org.mifos.platform.questionnaire.ui.model.Question) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 15 with Question

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

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