@Test public void mapEntityNotFoundExceptionToResponse() { Response entityNotFoundResponse = mapper.toResponse( new EntityNotFoundException("Entity Not Found Message")); assertEquals(entityNotFoundResponse.getStatus(), Status.NOT_FOUND.getStatusCode()); assertEquals(entityNotFoundResponse.getEntity(), "Entity Not Found 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);  }