Search in sources :

Example 6 with JsonSchemaValidationException

use of uk.gov.justice.services.core.json.JsonSchemaValidationException in project microservice_framework by CJSCommonPlatform.

the class BadRequestExceptionMapperTest method shouldAddJsonValidationErrorsToResponse.

@Test
public void shouldAddJsonValidationErrorsToResponse() {
    final ValidationException validationException = new ValidationException(schema, "Test Json");
    final JsonSchemaValidationException jsonSchemaValidationException = new JsonSchemaValidationException(validationException.getMessage(), validationException);
    final BadRequestException badRequestException = new BadRequestException(TEST_ERROR_MESSAGE, jsonSchemaValidationException);
    final Response response = exceptionMapper.toResponse(badRequestException);
    final String body = response.getEntity().toString();
    assertThat(body, hasJsonPath("$.validationErrors.message", equalTo("#: Test Json")));
}
Also used : Response(javax.ws.rs.core.Response) ValidationException(org.everit.json.schema.ValidationException) JsonSchemaValidationException(uk.gov.justice.services.core.json.JsonSchemaValidationException) JsonSchemaValidationException(uk.gov.justice.services.core.json.JsonSchemaValidationException) BadRequestException(uk.gov.justice.services.adapter.rest.exception.BadRequestException) Test(org.junit.Test)

Aggregations

JsonSchemaValidationException (uk.gov.justice.services.core.json.JsonSchemaValidationException)6 Test (org.junit.Test)3 MediaType (uk.gov.justice.services.core.mapping.MediaType)3 BadRequestException (uk.gov.justice.services.adapter.rest.exception.BadRequestException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 TextMessage (javax.jms.TextMessage)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)1 Response (javax.ws.rs.core.Response)1 ValidationException (org.everit.json.schema.ValidationException)1 InvalidMediaTypeException (uk.gov.justice.services.messaging.exception.InvalidMediaTypeException)1