@Test public void testToResponse() { BadRequestException ex = new BadRequestException("testing"); int badRequestCode = Response.Status.BAD_REQUEST.getStatusCode(); BadRequestExceptionMapper mapper = new BadRequestExceptionMapper(); Response response = mapper.toResponse(ex); assertThat(response).isNotNull(); assertThat(response.getStatus()).isEqualTo(badRequestCode); assertThat(response.getEntity()).isInstanceOf(APIResponse.class); APIResponse apiResponse = (APIResponse) response.getEntity(); assertThat(apiResponse.getStatus()).isEqualTo(badRequestCode); }
@Override public Response toResponse(BadRequestException exception) { String title = "Bad request error"; LOG.error(title, exception); Response.Status status = Response.Status.BAD_REQUEST; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }
BadRequestExceptionMapper implements ExceptionMapper<BadRequestException> { @Override public Response toResponse(BadRequestException exception) { String title = "Bad request error"; LOG.error(title, exception); Response.Status status = Response.Status.BAD_REQUEST; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); } }
BadRequestExceptionMapper implements ExceptionMapper<BadRequestException> { @Override public Response toResponse(BadRequestException exception) { String title = "Bad request error"; LOG.error(title, exception); Response.Status status = Response.Status.BAD_REQUEST; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  }
BadRequestExceptionMapper implements ExceptionMapper<BadRequestException> { @Override public Response toResponse(BadRequestException exception) { String title = "Bad request error"; LOG.error(title, exception); Response.Status status = Response.Status.BAD_REQUEST; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  @Override Response toResponse(BadRequestException exception); }
BadRequestExceptionMapper implements ExceptionMapper<BadRequestException> { @Override public Response toResponse(BadRequestException exception) { String title = "Bad request error"; LOG.error(title, exception); Response.Status status = Response.Status.BAD_REQUEST; APIResponse response = new APIResponse(status, exception, title); return Response.status(status).entity(response).build(); }  @Override Response toResponse(BadRequestException exception);  }