Search in sources :

Example 11 with StatusRuntimeException

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

the class SubscriptionAdminClientTest method createSubscriptionExceptionTest.

@Test
@SuppressWarnings("all")
public void createSubscriptionExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SubscriptionName name = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
        TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
        PushConfig pushConfig = PushConfig.newBuilder().build();
        int ackDeadlineSeconds = 2135351438;
        client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : PushConfig(com.google.pubsub.v1.PushConfig) StatusRuntimeException(io.grpc.StatusRuntimeException) SubscriptionName(com.google.pubsub.v1.SubscriptionName) TopicName(com.google.pubsub.v1.TopicName) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 12 with StatusRuntimeException

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

the class GroupServiceClientTest method getGroupExceptionTest.

@Test
@SuppressWarnings("all")
public void getGroupExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockGroupService.addException(exception);
    try {
        GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
        client.getGroup(name);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : GroupName(com.google.monitoring.v3.GroupName) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 13 with StatusRuntimeException

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

the class MetricServiceClientTest method createMetricDescriptorExceptionTest.

@Test
@SuppressWarnings("all")
public void createMetricDescriptorExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricService.addException(exception);
    try {
        ProjectName name = ProjectName.create("[PROJECT]");
        MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
        client.createMetricDescriptor(name, metricDescriptor);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : MetricDescriptor(com.google.api.MetricDescriptor) ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 14 with StatusRuntimeException

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

the class MetricServiceClientTest method getMonitoredResourceDescriptorExceptionTest.

@Test
@SuppressWarnings("all")
public void getMonitoredResourceDescriptorExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricService.addException(exception);
    try {
        MonitoredResourceDescriptorName name = MonitoredResourceDescriptorName.create("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]");
        client.getMonitoredResourceDescriptor(name);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : MonitoredResourceDescriptorName(com.google.monitoring.v3.MonitoredResourceDescriptorName) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 15 with StatusRuntimeException

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

the class MetricServiceClientTest method listMetricDescriptorsExceptionTest.

@Test
@SuppressWarnings("all")
public void listMetricDescriptorsExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockMetricService.addException(exception);
    try {
        ProjectName name = ProjectName.create("[PROJECT]");
        client.listMetricDescriptors(name);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : ProjectName(com.google.monitoring.v3.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) 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