ConstraintViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException> { public Response toResponse(final ConstraintViolationException exception) { return ErrorResponseBuilder .from(exception) .build(); }  Response toResponse(final ConstraintViolationException exception);  }
@Test public void testToResponse() { Set<ConstraintViolation<Application>> violations = new HashSet<>(); ConstraintViolation m = Mockito.mock(ConstraintViolation.class); Mockito.when(m.getMessage()).thenReturn("test 1"); violations.add(m); ConstraintViolationExceptionMapper mapper = new ConstraintViolationExceptionMapper(); ConstraintViolationException e = new ConstraintViolationException("message", violations); Response r = mapper.toResponse(e); ErrorResponse er = (ErrorResponse) r.getEntity(); assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus()); assertEquals(Status.BAD_REQUEST, er.getHttpStatus()); assertEquals("test 1", er.getErrorDescription()); }