GrpcStatus { public static HttpStatus grpcCodeToHttpStatus(Status.Code grpcStatusCode) { switch (grpcStatusCode) { case OK: return HttpStatus.OK; case CANCELLED: return HttpStatus.CLIENT_CLOSED_REQUEST; case UNKNOWN: case INTERNAL: case DATA_LOSS: return HttpStatus.INTERNAL_SERVER_ERROR; case INVALID_ARGUMENT: case FAILED_PRECONDITION: case OUT_OF_RANGE: return HttpStatus.BAD_REQUEST; case DEADLINE_EXCEEDED: return HttpStatus.GATEWAY_TIMEOUT; case NOT_FOUND: return HttpStatus.NOT_FOUND; case ALREADY_EXISTS: case ABORTED: return HttpStatus.CONFLICT; case PERMISSION_DENIED: return HttpStatus.FORBIDDEN; case UNAUTHENTICATED: return HttpStatus.UNAUTHORIZED; case RESOURCE_EXHAUSTED: return HttpStatus.TOO_MANY_REQUESTS; case UNIMPLEMENTED: return HttpStatus.NOT_IMPLEMENTED; case UNAVAILABLE: return HttpStatus.SERVICE_UNAVAILABLE; default: return HttpStatus.UNKNOWN; } } private  GrpcStatus(); static Status fromThrowable(Throwable t); static HttpStatus grpcCodeToHttpStatus(Status.Code grpcStatusCode); static Status httpStatusToGrpcStatus(int httpStatusCode); static ThrowableProto serializeThrowable(Throwable t); static void reportStatus(HttpHeaders headers,
                                    HttpStreamReader reader,
                                    TransportStatusListener transportStatusListener);  }
@Test void grpcCodeToHttpStatus() { for (Status.Code code : Status.Code.values()) { assertThat(GrpcStatus.grpcCodeToHttpStatus(code).code()) .as("gRPC code: {}", code) .isEqualTo(GrpcStatusCode.of(code).getCode().getHttpStatusCode()); } }