Search in sources :

Example 41 with QuestionDetail

use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method shouldThrowExceptionWhenQuestionTypeNotProvided.

@Test
public void shouldThrowExceptionWhenQuestionTypeNotProvided() {
    try {
        questionnaireValidator.validateForDefineQuestion(new QuestionDetail("Title 123", QuestionType.INVALID));
        fail("Should have thrown the validation exception");
    } catch (SystemException e) {
        assertEquals(ANSWER_TYPE_NOT_PROVIDED, e.getKey());
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 42 with QuestionDetail

use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method getSection.

private SectionDetail getSection(String name) {
    SectionDetail section = new SectionDetail();
    section.setName(name);
    section.addQuestion(new SectionQuestionDetail(new QuestionDetail(12, "Q1", QuestionType.INVALID, true, true), true, null));
    return section;
}
Also used : SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail)

Example 43 with QuestionDetail

use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method shouldNotThrowExceptionWhenANumericQuestionWithNoBoundsHasAnswer.

@SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" })
@Test
public void shouldNotThrowExceptionWhenANumericQuestionWithNoBoundsHasAnswer() {
    QuestionDetail questionDetail = getNumericQuestionDetail("Numeric Question", null, null);
    SectionDetail sectionWithOneQuestion = getSectionWithOneQuestion("Sec1", questionDetail, "121");
    QuestionGroupDetail questionGroupDetail = getQuestionGroupDetail(0, "Title", "Create", "Client", asList(sectionWithOneQuestion));
    try {
        questionnaireValidator.validateForQuestionGroupResponses(asList(questionGroupDetail));
    } catch (ValidationException e) {
        fail("Should not have thrown the validation exception");
    }
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ValidationException(org.mifos.platform.validations.ValidationException) SectionDetail(org.mifos.platform.questionnaire.service.SectionDetail) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 44 with QuestionDetail

use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method shouldNotThrowExceptionForNumericQuestionType.

@Test
public void shouldNotThrowExceptionForNumericQuestionType() {
    try {
        QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
        questionnaireValidator.validateForDefineQuestion(questionDetail);
    } catch (SystemException e) {
        fail("Should not have thrown the exception");
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 45 with QuestionDetail

use of org.mifos.platform.questionnaire.service.QuestionDetail in project head by mifos.

the class QuestionnaireValidatorTest method shouldThrowExceptionForNumericQuestionTypeWhenInvalidBoundsGiven.

@Test
public void shouldThrowExceptionForNumericQuestionTypeWhenInvalidBoundsGiven() {
    try {
        QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
        questionDetail.setNumericMin(100);
        questionDetail.setNumericMax(10);
        questionnaireValidator.validateForDefineQuestion(questionDetail);
        fail("Should have thrown the exception");
    } catch (SystemException e) {
        assertEquals(INVALID_NUMERIC_BOUNDS, e.getKey());
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) 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