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));
}
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));
}
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));
}
}
Aggregations