Search in sources :

Example 11 with FakeStatusCode

use of com.google.api.gax.rpc.testing.FakeStatusCode in project gax-java by googleapis.

the class OpencensusTracerTest method testErrorConversion.

@Test
public void testErrorConversion() {
    for (Code code : Code.values()) {
        ApiException error = new ApiException("fake message", null, new FakeStatusCode(code), false);
        Status opencensusStatus = OpencensusTracer.convertErrorToStatus(error);
        assertThat(opencensusStatus.getDescription()).isEqualTo("fake message");
        assertThat(opencensusStatus.getCanonicalCode().toString()).isEqualTo(code.toString());
    }
}
Also used : Status(io.opencensus.trace.Status) FakeStatusCode(com.google.api.gax.rpc.testing.FakeStatusCode) FakeStatusCode(com.google.api.gax.rpc.testing.FakeStatusCode) CanonicalCode(io.opencensus.trace.Status.CanonicalCode) Code(com.google.api.gax.rpc.StatusCode.Code) ApiException(com.google.api.gax.rpc.ApiException) Test(org.junit.Test)

Aggregations

FakeStatusCode (com.google.api.gax.rpc.testing.FakeStatusCode)11 Test (org.junit.Test)11 ApiException (com.google.api.gax.rpc.ApiException)5 DeadlineExceededException (com.google.api.gax.rpc.DeadlineExceededException)4 NotFoundException (com.google.api.gax.rpc.NotFoundException)2 Status (io.opencensus.trace.Status)2 ServerStreamingAttemptException (com.google.api.gax.retrying.ServerStreamingAttemptException)1 CancelledException (com.google.api.gax.rpc.CancelledException)1 Code (com.google.api.gax.rpc.StatusCode.Code)1 CanonicalCode (io.opencensus.trace.Status.CanonicalCode)1