PropertyValueExceptionMapper implements ExceptionMapper<PropertyValueException> { public Response toResponse(final PropertyValueException exception) { String message = String.format("Property \"%s\" is invalid.", exception.getPropertyName()); return ErrorResponseBuilder .from(Status.BAD_REQUEST, message) .build(); }  Response toResponse(final PropertyValueException exception);  }
@Test public void testToResponse() { PropertyValueExceptionMapper mapper = new PropertyValueExceptionMapper(); PropertyValueException e = new PropertyValueException("test", "thing", "name"); Response r = mapper.toResponse(e); ErrorResponse er = (ErrorResponse) r.getEntity(); assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus()); assertEquals(Status.BAD_REQUEST, er.getHttpStatus()); assertEquals("Property \"name\" is invalid.", er.getErrorDescription()); }