Search in sources :

Example 56 with ValidationException

use of org.mifos.platform.validations.ValidationException in project head by mifos.

the class ValidationExceptionTest method shouldPrintStackTraceOfChildExceptions.

@Test
public void shouldPrintStackTraceOfChildExceptions() {
    ValidationException validationException = generateValidationException();
    assertThat(validationException.hasChildExceptions(), is(true));
    String stackTraceString = validationException.getStackTraceString();
    assertThat(stackTraceString, is(notNullValue()));
    assertThat(stackTraceString.contains(TOP_LEVEL_EXCEPTION), is(true));
    assertThat(stackTraceString.contains(INSIDE_VALIDATION_METHOD1), is(true));
    assertThat(stackTraceString.contains(INSIDE_VALIDATION_METHOD2), is(true));
    assertThat(stackTraceString.contains(INSIDE_VALIDATION_METHOD3), is(true));
}
Also used : ValidationException(org.mifos.platform.validations.ValidationException) Test(org.junit.Test)

Example 57 with ValidationException

use of org.mifos.platform.validations.ValidationException in project head by mifos.

the class ValidationExceptionTest method shouldCopyChildExceptionsWithChildExceptions.

@Test
public void shouldCopyChildExceptionsWithChildExceptions() {
    ValidationException validationException1 = generateValidationException();
    ValidationException validationException2 = generateValidationException();
    validationException1.copyChildExceptions(validationException2);
    assertThat(validationException1.hasChildExceptions(), is(true));
    List<ValidationException> childExceptions = validationException1.getChildExceptions();
    assertThat(childExceptions.size(), is(6));
}
Also used : ValidationException(org.mifos.platform.validations.ValidationException) Test(org.junit.Test)

Example 58 with ValidationException

use of org.mifos.platform.validations.ValidationException in project head by mifos.

the class QuestionnaireServiceFacadeTest method testValidateResponse.

@Test
public void testValidateResponse() {
    List<QuestionDetail> questionDetails = asList(new QuestionDetail(12, "Question 1", QuestionType.FREETEXT, true, true));
    List<SectionDetail> sectionDetails = asList(getSectionDetailWithQuestions("Sec1", questionDetails, null, true));
    QuestionGroupDetail questionGroupDetail = new QuestionGroupDetail(1, "QG1", Arrays.asList(new EventSourceDto("Create", "Client", null)), sectionDetails, true);
    try {
        Mockito.doThrow(new MandatoryAnswerNotFoundException("Title")).when(questionnaireService).validateResponses(asList(questionGroupDetail));
        questionnaireServiceFacade.validateResponses(asList(questionGroupDetail));
        Assert.fail("Should not have thrown the validation exception");
    } catch (ValidationException e) {
        verify(questionnaireService, times(1)).validateResponses(asList(questionGroupDetail));
    }
}
Also used : ValidationException(org.mifos.platform.validations.ValidationException) MandatoryAnswerNotFoundException(org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto) Test(org.junit.Test)

Aggregations

ValidationException (org.mifos.platform.validations.ValidationException)58 Test (org.junit.Test)48 QuestionGroupDto (org.mifos.platform.questionnaire.service.dtos.QuestionGroupDto)30 Arrays.asList (java.util.Arrays.asList)27 List (java.util.List)27 BadNumericResponseException (org.mifos.platform.questionnaire.exceptions.BadNumericResponseException)8 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)7 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)6 MandatoryAnswerNotFoundException (org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException)6 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)5 SectionDetail (org.mifos.platform.questionnaire.service.SectionDetail)5 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)5 QuestionChoiceEntity (org.mifos.platform.questionnaire.domain.QuestionChoiceEntity)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 QuestionnaireServiceFacade (org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade)2 QuestionDto (org.mifos.platform.questionnaire.service.dtos.QuestionDto)2 MessageResolver (org.springframework.binding.message.MessageResolver)2 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionMessage (org.apache.struts.action.ActionMessage)1 Before (org.junit.Before)1