Search in sources :

Example 1 with GrpcStatus

use of io.servicetalk.grpc.api.GrpcStatus in project servicetalk by apple.

the class ProtocolCompatibilityTest method assertStatusRuntimeException.

private static void assertStatusRuntimeException(final StatusRuntimeException statusException, final boolean withStatus, final Status.Code expectStatusCode, @Nullable final String expectMessage) throws InvalidProtocolBufferException {
    final Status grpcStatus = statusException.getStatus();
    assertNotNull(grpcStatus);
    assertEquals(expectStatusCode.value(), grpcStatus.getCode().value());
    if (null != expectMessage) {
        assertEquals(expectMessage, grpcStatus.getDescription());
    }
    final com.google.rpc.Status status = StatusProto.fromThrowable(statusException);
    if (withStatus) {
        assertNotNull(status);
        assertEquals(grpcStatus.getCode().value(), status.getCode());
        assertStatus(status, expectStatusCode.value(), grpcStatus.getDescription());
    } else {
        if (null != status) {
            assertFallbackStatus(status, expectStatusCode.value(), grpcStatus.getDescription());
        }
    }
}
Also used : Status(io.grpc.Status) GrpcStatus(io.servicetalk.grpc.api.GrpcStatus)

Example 2 with GrpcStatus

use of io.servicetalk.grpc.api.GrpcStatus in project servicetalk by apple.

the class ProtocolCompatibilityTest method assertGrpcStatusException.

private static void assertGrpcStatusException(final GrpcStatusException statusException, final boolean withStatus, final GrpcStatusCode expectStatusCode, @Nullable final String expectMessage) throws InvalidProtocolBufferException {
    final GrpcStatus grpcStatus = statusException.status();
    assertNotNull(grpcStatus);
    assertEquals(expectStatusCode, grpcStatus.code(), "grpcStatus: " + grpcStatus);
    if (null != expectMessage) {
        assertEquals(expectMessage, grpcStatus.description());
    }
    final com.google.rpc.Status status = statusException.applicationStatus();
    if (withStatus) {
        assertNotNull(status);
        assertEquals(grpcStatus.code().value(), status.getCode());
        assertStatus(status, expectStatusCode.value(), grpcStatus.description());
    } else {
        if (null != status) {
            assertFallbackStatus(status, expectStatusCode.value(), grpcStatus.description());
        }
    }
}
Also used : GrpcStatus(io.servicetalk.grpc.api.GrpcStatus)

Aggregations

GrpcStatus (io.servicetalk.grpc.api.GrpcStatus)2 Status (io.grpc.Status)1