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.
}
}
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.
}
}
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.
}
}
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()));
}
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.
}
}
Aggregations