@Test public void testToResponse() { DataConstraintViolationException ex = new DataConstraintViolationException(null); DataConstraintViolationExceptionMapper mapper = new DataConstraintViolationExceptionMapper(); Response response = mapper.toResponse(ex); int statusCode = Response.Status.CONFLICT.getStatusCode(); assertThat(response).isNotNull(); assertThat(response.getStatus()).isEqualTo(statusCode); assertThat(response.getEntity()).isInstanceOf(APIResponse.class); APIResponse apiResponse = (APIResponse) response.getEntity(); assertThat(apiResponse.getStatus()).isEqualTo(statusCode); }
@Override public Response toResponse(DataConstraintViolationException exception) { String title = "constraint violation exception"; LOG.error(title, exception); Response.Status status = Response.Status.CONFLICT; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }
DataConstraintViolationExceptionMapper implements ExceptionMapper<DataConstraintViolationException> { @Override public Response toResponse(DataConstraintViolationException exception) { String title = "constraint violation exception"; LOG.error(title, exception); Response.Status status = Response.Status.CONFLICT; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); } }
DataConstraintViolationExceptionMapper implements ExceptionMapper<DataConstraintViolationException> { @Override public Response toResponse(DataConstraintViolationException exception) { String title = "constraint violation exception"; LOG.error(title, exception); Response.Status status = Response.Status.CONFLICT; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  }
DataConstraintViolationExceptionMapper implements ExceptionMapper<DataConstraintViolationException> { @Override public Response toResponse(DataConstraintViolationException exception) { String title = "constraint violation exception"; LOG.error(title, exception); Response.Status status = Response.Status.CONFLICT; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  @Override Response toResponse(DataConstraintViolationException exception); }
DataConstraintViolationExceptionMapper implements ExceptionMapper<DataConstraintViolationException> { @Override public Response toResponse(DataConstraintViolationException exception) { String title = "constraint violation exception"; LOG.error(title, exception); Response.Status status = Response.Status.CONFLICT; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  @Override Response toResponse(DataConstraintViolationException exception);  }