GrpcStatusCode implements StatusCode { static StatusCode.Code grpcCodeToStatusCode(Status.Code code) { switch (code) { case OK: return StatusCode.Code.OK; case CANCELLED: return StatusCode.Code.CANCELLED; case UNKNOWN: return StatusCode.Code.UNKNOWN; case INVALID_ARGUMENT: return StatusCode.Code.INVALID_ARGUMENT; case DEADLINE_EXCEEDED: return StatusCode.Code.DEADLINE_EXCEEDED; case NOT_FOUND: return StatusCode.Code.NOT_FOUND; case ALREADY_EXISTS: return StatusCode.Code.ALREADY_EXISTS; case PERMISSION_DENIED: return StatusCode.Code.PERMISSION_DENIED; case RESOURCE_EXHAUSTED: return StatusCode.Code.RESOURCE_EXHAUSTED; case FAILED_PRECONDITION: return StatusCode.Code.FAILED_PRECONDITION; case ABORTED: return StatusCode.Code.ABORTED; case OUT_OF_RANGE: return StatusCode.Code.OUT_OF_RANGE; case UNIMPLEMENTED: return StatusCode.Code.UNIMPLEMENTED; case INTERNAL: return StatusCode.Code.INTERNAL; case UNAVAILABLE: return StatusCode.Code.UNAVAILABLE; case DATA_LOSS: return StatusCode.Code.DATA_LOSS; case UNAUTHENTICATED: return StatusCode.Code.UNAUTHENTICATED; default: throw new IllegalStateException("Unrecognized status code: " + code); } }  static GrpcStatusCode of(Status.Code grpcCode); @Override StatusCode.Code getCode(); @Override abstract Status.Code getTransportCode();  }
@Test public void testGrpcCodeToStatusCode() { testCodes(StatusCode.Code.OK, Status.Code.OK); testCodes(StatusCode.Code.CANCELLED, Status.Code.CANCELLED); testCodes(StatusCode.Code.UNKNOWN, Status.Code.UNKNOWN); testCodes(StatusCode.Code.INVALID_ARGUMENT, Status.Code.INVALID_ARGUMENT); testCodes(StatusCode.Code.DEADLINE_EXCEEDED, Status.Code.DEADLINE_EXCEEDED); testCodes(StatusCode.Code.NOT_FOUND, Status.Code.NOT_FOUND); testCodes(StatusCode.Code.ALREADY_EXISTS, Status.Code.ALREADY_EXISTS); testCodes(StatusCode.Code.PERMISSION_DENIED, Status.Code.PERMISSION_DENIED); testCodes(StatusCode.Code.RESOURCE_EXHAUSTED, Status.Code.RESOURCE_EXHAUSTED); testCodes(StatusCode.Code.FAILED_PRECONDITION, Status.Code.FAILED_PRECONDITION); testCodes(StatusCode.Code.ABORTED, Status.Code.ABORTED); testCodes(StatusCode.Code.OUT_OF_RANGE, Status.Code.OUT_OF_RANGE); testCodes(StatusCode.Code.UNIMPLEMENTED, Status.Code.UNIMPLEMENTED); testCodes(StatusCode.Code.INTERNAL, Status.Code.INTERNAL); testCodes(StatusCode.Code.UNAVAILABLE, Status.Code.UNAVAILABLE); testCodes(StatusCode.Code.DATA_LOSS, Status.Code.DATA_LOSS); testCodes(StatusCode.Code.UNAUTHENTICATED, Status.Code.UNAUTHENTICATED); }