Search in sources :

Example 41 with StatusRuntimeException

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

the class GroupServiceClientTest method createGroupExceptionTest.

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

Example 42 with StatusRuntimeException

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

the class GroupServiceClientTest method updateGroupExceptionTest.

@Test
@SuppressWarnings("all")
public void updateGroupExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockGroupService.addException(exception);
    try {
        Group group = Group.newBuilder().build();
        client.updateGroup(group);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : Group(com.google.monitoring.v3.Group) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 43 with StatusRuntimeException

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

the class ConfigClientTest method updateSinkExceptionTest.

@Test
@SuppressWarnings("all")
public void updateSinkExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        SinkNameOneof sinkName = SinkNameOneof.from(SinkName.create("[PROJECT]", "[SINK]"));
        LogSink sink = LogSink.newBuilder().build();
        client.updateSink(sinkName, sink);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : LogSink(com.google.logging.v2.LogSink) SinkNameOneof(com.google.logging.v2.SinkNameOneof) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 44 with StatusRuntimeException

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

the class ConfigClientTest method deleteSinkExceptionTest.

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

Example 45 with StatusRuntimeException

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

the class ConfigClientTest method createSinkExceptionTest.

@Test
@SuppressWarnings("all")
public void createSinkExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        ParentNameOneof parent = ParentNameOneof.from(ProjectName.create("[PROJECT]"));
        LogSink sink = LogSink.newBuilder().build();
        client.createSink(parent, sink);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : LogSink(com.google.logging.v2.LogSink) ParentNameOneof(com.google.logging.v2.ParentNameOneof) 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