use of com.google.bigtable.admin.v2.GetSnapshotRequest in project gapic-generator-java 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.GetSnapshotRequest in project gapic-generator-java by googleapis.
the class SyncGetSnapshot method syncGetSnapshot.
public static void syncGetSnapshot() throws Exception {
// It may require modifications to work in your environment.
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
GetSnapshotRequest request = GetSnapshotRequest.newBuilder().setSnapshot(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).build();
Snapshot response = subscriptionAdminClient.getSnapshot(request);
}
}
use of com.google.bigtable.admin.v2.GetSnapshotRequest in project gapic-generator-java by googleapis.
the class AsyncGetSnapshot method asyncGetSnapshot.
public static void asyncGetSnapshot() throws Exception {
// It may require modifications to work in your environment.
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
GetSnapshotRequest request = GetSnapshotRequest.newBuilder().setSnapshot(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString()).build();
ApiFuture<Snapshot> future = subscriptionAdminClient.getSnapshotCallable().futureCall(request);
// Do something.
Snapshot response = future.get();
}
}
use of com.google.bigtable.admin.v2.GetSnapshotRequest in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method getSnapshotTest2.
@Test
public void getSnapshotTest2() throws Exception {
Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
mockBigtableTableAdmin.addResponse(expectedResponse);
String name = "name3373707";
Snapshot actualResponse = client.getSnapshot(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.GetSnapshotRequest in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method getSnapshotTest.
@Test
public void getSnapshotTest() throws Exception {
Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
mockBigtableTableAdmin.addResponse(expectedResponse);
SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
Snapshot actualResponse = client.getSnapshot(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSnapshotRequest actualRequest = ((GetSnapshotRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations