Search in sources :

Example 21 with SnapshotName

use of com.google.bigtable.admin.v2.SnapshotName in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method createSnapshotExceptionTest2.

@Test
public void createSnapshotExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SnapshotName name = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
        String subscription = "subscription341203229";
        client.createSnapshot(name, subscription);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Example 22 with SnapshotName

use of com.google.bigtable.admin.v2.SnapshotName in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method getSnapshotExceptionTest.

@Test
public void getSnapshotExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
        client.getSnapshot(snapshot);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Example 23 with SnapshotName

use of com.google.bigtable.admin.v2.SnapshotName in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method createSnapshotExceptionTest.

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

Example 24 with SnapshotName

use of com.google.bigtable.admin.v2.SnapshotName in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method getSnapshotTest.

@Test
public void getSnapshotTest() throws Exception {
    Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString()).setExpireTime(Timestamp.newBuilder().build()).putAllLabels(new HashMap<String, String>()).build();
    mockSubscriber.addResponse(expectedResponse);
    SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
    Snapshot actualResponse = client.getSnapshot(snapshot);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
    Assert.assertEquals(snapshot.toString(), actualRequest.getSnapshot());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.pubsub.v1.Snapshot) AbstractMessage(com.google.protobuf.AbstractMessage) HashMap(java.util.HashMap) GetSnapshotRequest(com.google.pubsub.v1.GetSnapshotRequest) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Example 25 with SnapshotName

use of com.google.bigtable.admin.v2.SnapshotName in project java-pubsub by googleapis.

the class SubscriptionAdminClientTest method deleteSnapshotExceptionTest.

@Test
public void deleteSnapshotExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SnapshotName snapshot = SnapshotName.of("[PROJECT]", "[SNAPSHOT]");
        client.deleteSnapshot(snapshot);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) SnapshotName(com.google.pubsub.v1.SnapshotName) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)28 SnapshotName (com.google.pubsub.v1.SnapshotName)24 StatusRuntimeException (io.grpc.StatusRuntimeException)14 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)12 AbstractMessage (com.google.protobuf.AbstractMessage)12 Snapshot (com.google.pubsub.v1.Snapshot)10 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 ByteString (com.google.protobuf.ByteString)8 HashMap (java.util.HashMap)8 SubscriptionName (com.google.pubsub.v1.SubscriptionName)7 CreateSnapshotRequest (com.google.pubsub.v1.CreateSnapshotRequest)5 SubscriptionAdminClient (com.google.cloud.pubsub.v1.SubscriptionAdminClient)4 Empty (com.google.protobuf.Empty)4 DeleteSnapshotRequest (com.google.pubsub.v1.DeleteSnapshotRequest)3 ApiException (com.google.api.gax.grpc.ApiException)2 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)2 CreateTableFromSnapshotRequest (com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest)2 DeleteSnapshotRequest (com.google.bigtable.admin.v2.DeleteSnapshotRequest)2 InstanceName (com.google.bigtable.admin.v2.InstanceName)2 Table (com.google.bigtable.admin.v2.Table)2