Search in sources :

Example 1 with ListSnapshotsPagedResponse

use of com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method listSnapshotsTest.

@Test
public void listSnapshotsTest() throws Exception {
    Snapshot responsesElement = Snapshot.newBuilder().build();
    ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
    ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(parent);
    List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.bigtable.admin.v2.Snapshot) ListSnapshotsRequest(com.google.bigtable.admin.v2.ListSnapshotsRequest) ListSnapshotsResponse(com.google.bigtable.admin.v2.ListSnapshotsResponse) ListSnapshotsPagedResponse(com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ClusterName(com.google.bigtable.admin.v2.ClusterName) Test(org.junit.Test)

Example 2 with ListSnapshotsPagedResponse

use of com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method listSnapshotsTest2.

@Test
public void listSnapshotsTest2() throws Exception {
    Snapshot responsesElement = Snapshot.newBuilder().build();
    ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(parent);
    List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Snapshot(com.google.bigtable.admin.v2.Snapshot) ListSnapshotsRequest(com.google.bigtable.admin.v2.ListSnapshotsRequest) ListSnapshotsResponse(com.google.bigtable.admin.v2.ListSnapshotsResponse) ListSnapshotsPagedResponse(com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

ListSnapshotsRequest (com.google.bigtable.admin.v2.ListSnapshotsRequest)2 ListSnapshotsResponse (com.google.bigtable.admin.v2.ListSnapshotsResponse)2 Snapshot (com.google.bigtable.admin.v2.Snapshot)2 ListSnapshotsPagedResponse (com.google.cloud.bigtable.admin.v2.BaseBigtableTableAdminClient.ListSnapshotsPagedResponse)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 ClusterName (com.google.bigtable.admin.v2.ClusterName)1 ByteString (com.google.protobuf.ByteString)1