@Test public void mapGenericServiceExceptionToResponse() { Response serviceExceptionResponse = mapper.toResponse( new ServiceException("Generic Service Message")); assertEquals(serviceExceptionResponse.getStatus(), Status.INTERNAL_SERVER_ERROR.getStatusCode()); assertEquals(serviceExceptionResponse.getEntity(), "Generic Service Message"); }
@Override public Response toResponse(ServiceException exception) { ResponseBuilder response; if (exception instanceof EntityConflictException) { response = Response.status(Status.CONFLICT); } else if (exception instanceof EntityInvalidException) { response = Response.status(Status.BAD_REQUEST); } else if (exception instanceof EntityNotFoundException) { response = Response.status(Status.NOT_FOUND); } else { response = Response.status(Status.INTERNAL_SERVER_ERROR); } return response.type(MediaType.TEXT_PLAIN).entity(exception.getMessage()).build(); }
ServiceExceptionMapper implements ExceptionMapper<ServiceException> { @Override public Response toResponse(ServiceException exception) { ResponseBuilder response; if (exception instanceof EntityConflictException) { response = Response.status(Status.CONFLICT); } else if (exception instanceof EntityInvalidException) { response = Response.status(Status.BAD_REQUEST); } else if (exception instanceof EntityNotFoundException) { response = Response.status(Status.NOT_FOUND); } else { response = Response.status(Status.INTERNAL_SERVER_ERROR); } return response.type(MediaType.TEXT_PLAIN).entity(exception.getMessage()).build(); } }
ServiceExceptionMapper implements ExceptionMapper<ServiceException> { @Override public Response toResponse(ServiceException exception) { ResponseBuilder response; if (exception instanceof EntityConflictException) { response = Response.status(Status.CONFLICT); } else if (exception instanceof EntityInvalidException) { response = Response.status(Status.BAD_REQUEST); } else if (exception instanceof EntityNotFoundException) { response = Response.status(Status.NOT_FOUND); } else { response = Response.status(Status.INTERNAL_SERVER_ERROR); } return response.type(MediaType.TEXT_PLAIN).entity(exception.getMessage()).build(); }  }
ServiceExceptionMapper implements ExceptionMapper<ServiceException> { @Override public Response toResponse(ServiceException exception) { ResponseBuilder response; if (exception instanceof EntityConflictException) { response = Response.status(Status.CONFLICT); } else if (exception instanceof EntityInvalidException) { response = Response.status(Status.BAD_REQUEST); } else if (exception instanceof EntityNotFoundException) { response = Response.status(Status.NOT_FOUND); } else { response = Response.status(Status.INTERNAL_SERVER_ERROR); } return response.type(MediaType.TEXT_PLAIN).entity(exception.getMessage()).build(); }  @Override Response toResponse(ServiceException exception); }
ServiceExceptionMapper implements ExceptionMapper<ServiceException> { @Override public Response toResponse(ServiceException exception) { ResponseBuilder response; if (exception instanceof EntityConflictException) { response = Response.status(Status.CONFLICT); } else if (exception instanceof EntityInvalidException) { response = Response.status(Status.BAD_REQUEST); } else if (exception instanceof EntityNotFoundException) { response = Response.status(Status.NOT_FOUND); } else { response = Response.status(Status.INTERNAL_SERVER_ERROR); } return response.type(MediaType.TEXT_PLAIN).entity(exception.getMessage()).build(); }  @Override Response toResponse(ServiceException exception);  }