Search in sources :

Example 16 with StatusRuntimeException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class MetricServiceClientTest method listTimeSeriesExceptionTest.

@Test
@SuppressWarnings("all")
public void listTimeSeriesExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricService.addException(exception);
    try {
        ProjectName name = ProjectName.create("[PROJECT]");
        String filter = "filter-1274492040";
        TimeInterval interval = TimeInterval.newBuilder().build();
        ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
        client.listTimeSeries(name, filter, interval, view);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : TimeInterval(com.google.monitoring.v3.TimeInterval) ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) TimeSeriesView(com.google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView) ListTimeSeriesRequest(com.google.monitoring.v3.ListTimeSeriesRequest) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 17 with StatusRuntimeException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method acknowledgeExceptionTest.

@Test
@SuppressWarnings("all")
public void acknowledgeExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
        List<String> ackIds = new ArrayList<>();
        client.acknowledge(subscription, ackIds);
        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) SubscriptionName(com.google.pubsub.v1.SubscriptionName) ByteString(com.google.protobuf.ByteString) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 18 with StatusRuntimeException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method createSnapshotExceptionTest.

@Test
@SuppressWarnings("all")
public void createSnapshotExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SnapshotName name = SnapshotName.create("[PROJECT]", "[SNAPSHOT]");
        SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
        client.createSnapshot(name, subscription);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) SubscriptionName(com.google.pubsub.v1.SubscriptionName) SnapshotName(com.google.pubsub.v1.SnapshotName) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 19 with StatusRuntimeException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method modifyAckDeadlineExceptionTest.

@Test
@SuppressWarnings("all")
public void modifyAckDeadlineExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
        List<String> ackIds = new ArrayList<>();
        int ackDeadlineSeconds = 2135351438;
        client.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds);
        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) SubscriptionName(com.google.pubsub.v1.SubscriptionName) ByteString(com.google.protobuf.ByteString) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 20 with StatusRuntimeException

use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.

the class TopicAdminClientTest method setIamPolicyExceptionTest.

@Test
@SuppressWarnings("all")
public void setIamPolicyExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockIAMPolicy.addException(exception);
    try {
        String formattedResource = TopicName.create("[PROJECT]", "[TOPIC]").toString();
        Policy policy = Policy.newBuilder().build();
        client.setIamPolicy(formattedResource, policy);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : Policy(com.google.iam.v1.Policy) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

StatusRuntimeException (io.grpc.StatusRuntimeException)240 Test (org.junit.Test)164 ApiException (com.google.api.gax.grpc.ApiException)74 Status (io.grpc.Status)25 StreamObserver (io.grpc.stub.StreamObserver)20 ByteString (com.google.protobuf.ByteString)18 ArrayList (java.util.ArrayList)18 Metadata (io.grpc.Metadata)14 SimpleServiceGrpc (io.grpc.testing.protobuf.SimpleServiceGrpc)13 ExecutionException (java.util.concurrent.ExecutionException)12 JanusGraphGrpcServerBaseTest (org.janusgraph.graphdb.grpc.JanusGraphGrpcServerBaseTest)12 Test (org.junit.jupiter.api.Test)12 SubscriptionName (com.google.pubsub.v1.SubscriptionName)9 ManagedChannel (io.grpc.ManagedChannel)9 StatusRuntimeException (org.apache.beam.vendor.grpc.v1p43p2.io.grpc.StatusRuntimeException)8 BStruct (org.ballerinalang.model.values.BStruct)8 SimpleRequest (io.grpc.testing.integration.Messages.SimpleRequest)7 ChannelCredentials (io.grpc.ChannelCredentials)6 ServerCredentials (io.grpc.ServerCredentials)6 TlsChannelCredentials (io.grpc.TlsChannelCredentials)6