Search in sources :

Example 81 with StatusRuntimeException

use of io.grpc.StatusRuntimeException in project android by JetBrains.

the class RpcNetworkRequestsModel method requestHttpResponseBody.

private void requestHttpResponseBody(long connectionId, @NotNull HttpData.Builder httpBuilder) {
    NetworkProfiler.HttpDetailsRequest request = NetworkProfiler.HttpDetailsRequest.newBuilder().setConnId(connectionId).setType(NetworkProfiler.HttpDetailsRequest.Type.RESPONSE_BODY).build();
    NetworkProfiler.HttpDetailsResponse response;
    try {
        response = myNetworkService.getHttpDetails(request);
    } catch (StatusRuntimeException e) {
        return;
    }
    String payloadId = response.getResponseBody().getPayloadId();
    httpBuilder.setResponsePayloadId(payloadId);
}
Also used : NetworkProfiler(com.android.tools.profiler.proto.NetworkProfiler) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf3jarjar.ByteString)

Example 82 with StatusRuntimeException

use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class LoggingClientTest method deleteLogExceptionTest.

@Test
@SuppressWarnings("all")
public void deleteLogExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockLoggingServiceV2.addException(exception);
    try {
        LogNameOneof logName = LogNameOneof.from(LogName.create("[PROJECT]", "[LOG]"));
        client.deleteLog(logName);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : LogNameOneof(com.google.logging.v2.LogNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 83 with StatusRuntimeException

use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class LoggingClientTest method listLogEntriesExceptionTest.

@Test
@SuppressWarnings("all")
public void listLogEntriesExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockLoggingServiceV2.addException(exception);
    try {
        List<String> resourceNames = new ArrayList<>();
        String filter = "filter-1274492040";
        String orderBy = "orderBy1234304744";
        client.listLogEntries(resourceNames, filter, orderBy);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 84 with StatusRuntimeException

use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class LoggingClientTest method listLogsExceptionTest.

@Test
@SuppressWarnings("all")
public void listLogsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockLoggingServiceV2.addException(exception);
    try {
        ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
        client.listLogs(parent);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : ParentNameOneof(com.google.logging.v2.ParentNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 85 with StatusRuntimeException

use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class MetricsClientTest method updateLogMetricExceptionTest.

@Test
@SuppressWarnings("all")
public void updateLogMetricExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricsServiceV2.addException(exception);
    try {
        MetricNameOneof metricName = MetricNameOneof.from(MetricName.create("[PROJECT]", "[METRIC]"));
        LogMetric metric = LogMetric.newBuilder().build();
        client.updateLogMetric(metricName, metric);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : LogMetric(com.google.logging.v2.LogMetric) MetricNameOneof(com.google.logging.v2.MetricNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

StatusRuntimeException (io.grpc.StatusRuntimeException)131 Test (org.junit.Test)110 ApiException (com.google.api.gax.grpc.ApiException)74 ByteString (com.google.protobuf.ByteString)12 Status (io.grpc.Status)12 ArrayList (java.util.ArrayList)11 Metadata (io.grpc.Metadata)10 SubscriptionName (com.google.pubsub.v1.SubscriptionName)9 ProjectName (com.google.monitoring.v3.ProjectName)6 TopicName (com.google.pubsub.v1.TopicName)6 StreamObserver (io.grpc.stub.StreamObserver)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Document (com.google.cloud.language.v1beta2.Document)5 ParentNameOneof (com.google.logging.v2.ParentNameOneof)5 IOException (java.io.IOException)5 ExecutionException (java.util.concurrent.ExecutionException)5 Document (com.google.cloud.language.v1.Document)4 EncodingType (com.google.cloud.language.v1beta2.EncodingType)4 HelloReply (io.grpc.examples.helloworld.HelloReply)4 HelloRequest (io.grpc.examples.helloworld.HelloRequest)4