SchemaValidationErrorMessageGenerator { public String generateErrorMessage(final ValidationException e) { final int violationCount = e.getViolationCount(); final String errorMessage = e.getErrorMessage(); final List<String> allMessages = e.getAllMessages(); final String id = e.getViolatedSchema().getId(); final String schemaLocation = e.getSchemaLocation(); return format(ERROR_MASSAGE_FORMAT, violationCount, errorMessage, allMessages, id, schemaLocation); }  String generateErrorMessage(final ValidationException e);  }
@Test public void shouldName() throws Exception { final Schema violatedSchema = mock(Schema.class); when(violatedSchema.getId()).thenReturn("schema id"); final ValidationException validationException = new ValidationException( violatedSchema, "error message", "don't care", "schemaLocation"); final String errorMessage = schemaValidationErrorMessageGenerator.generateErrorMessage(validationException); assertThat(errorMessage, is("Json validation failed with 1 violation(s): error message. Errors: [#: error message]. Violated schema id: 'schema id'. Location: 'schemaLocation'")); }