@Test public void testToResponse() { MTException ex = new MTException("testing"); int internalErrorCode = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); MTExceptionMapper mapper = new MTExceptionMapper(); Response response = mapper.toResponse(ex); assertThat(response).isNotNull(); assertThat(response.getStatus()).isEqualTo(internalErrorCode); assertThat(response.getEntity()).isInstanceOf(APIResponse.class); APIResponse apiResponse = (APIResponse) response.getEntity(); assertThat(apiResponse.getStatus()).isEqualTo(internalErrorCode); }
@Override public Response toResponse(MTException exception) { String title = "Internal server error"; LOG.error(title, exception); Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }
MTExceptionMapper implements ExceptionMapper<MTException> { @Override public Response toResponse(MTException exception) { String title = "Internal server error"; LOG.error(title, exception); Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); } }
MTExceptionMapper implements ExceptionMapper<MTException> { @Override public Response toResponse(MTException exception) { String title = "Internal server error"; LOG.error(title, exception); Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  }
MTExceptionMapper implements ExceptionMapper<MTException> { @Override public Response toResponse(MTException exception) { String title = "Internal server error"; LOG.error(title, exception); Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  @Override Response toResponse(MTException exception); }
MTExceptionMapper implements ExceptionMapper<MTException> { @Override public Response toResponse(MTException exception) { String title = "Internal server error"; LOG.error(title, exception); Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  @Override Response toResponse(MTException exception);  }