Search in sources :

Example 41 with SystemException

use of org.mifos.framework.exceptions.SystemException 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 SystemException

use of org.mifos.framework.exceptions.SystemException 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 43 with SystemException

use of org.mifos.framework.exceptions.SystemException 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)

Example 44 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class QuestionnaireValidatorTest method shouldThrowExceptionWhenQuestionTitleIsProvided.

@Test
public void shouldThrowExceptionWhenQuestionTitleIsProvided() {
    try {
        questionnaireValidator.validateForDefineQuestion(new QuestionDetail(null, QuestionType.FREETEXT));
        fail("Should have thrown the validation exception");
    } catch (SystemException e) {
        assertEquals(QUESTION_TEXT_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 45 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class QuestionnaireValidatorTest method shouldNotThrowExceptionForNumericQuestionTypeWhenOnlyMinBoundGiven.

@Test
public void shouldNotThrowExceptionForNumericQuestionTypeWhenOnlyMinBoundGiven() {
    try {
        QuestionDetail questionDetail = new QuestionDetail("Title", QuestionType.NUMERIC);
        questionDetail.setNumericMin(10);
        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)

Aggregations

SystemException (org.mifos.framework.exceptions.SystemException)53 Test (org.junit.Test)21 ApplicationException (org.mifos.framework.exceptions.ApplicationException)13 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)10 HibernateException (org.hibernate.HibernateException)7 Session (org.hibernate.Session)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 HibernateProcessException (org.mifos.framework.exceptions.HibernateProcessException)7 ReportException (org.mifos.reports.exceptions.ReportException)7 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 IOException (java.io.IOException)3 ResultSet (java.sql.ResultSet)3 Statement (java.sql.Statement)3 ArrayList (java.util.ArrayList)3 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 PreparedStatement (java.sql.PreparedStatement)2