Search in sources :

Example 51 with QuestionDetail

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

Example 52 with QuestionDetail

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;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail)

Example 53 with QuestionDetail

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));
}
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 54 with QuestionDetail

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()));
}
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 55 with QuestionDetail

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

Aggregations

QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)72 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)55 Test (org.junit.Test)44 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)24 Question (org.mifos.platform.questionnaire.ui.model.Question)16 ChoiceDto (org.mifos.platform.questionnaire.service.dtos.ChoiceDto)13 ArrayList (java.util.ArrayList)11 SystemException (org.mifos.framework.exceptions.SystemException)11 QuestionEntity (org.mifos.platform.questionnaire.domain.QuestionEntity)9 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)8 ValidationException (org.mifos.platform.validations.ValidationException)5 QuestionForm (org.mifos.platform.questionnaire.ui.model.QuestionForm)4 Matchers.anyString (org.mockito.Matchers.anyString)4 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)3 SectionQuestion (org.mifos.platform.questionnaire.domain.SectionQuestion)3 BadNumericResponseException (org.mifos.platform.questionnaire.exceptions.BadNumericResponseException)3 QuestionChoicesMatcher (org.mifos.platform.questionnaire.matchers.QuestionChoicesMatcher)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 QuestionGroupForm (org.mifos.platform.questionnaire.ui.model.QuestionGroupForm)3 QuestionGroupDetails (org.mifos.platform.questionnaire.service.QuestionGroupDetails)2