use of com.google.bigtable.admin.v2.Cluster in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method deleteSnapshotTest.
@Test
public void deleteSnapshotTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableTableAdmin.addResponse(expectedResponse);
SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
client.deleteSnapshot(name);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteSnapshotRequest actualRequest = ((DeleteSnapshotRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.Cluster in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createBackupTest2.
@Test
public void createBackupTest2() throws Exception {
Backup expectedResponse = Backup.newBuilder().setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]").toString()).setSourceTable("sourceTable-95372173").setExpireTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setSizeBytes(-1796325715).setEncryptionInfo(EncryptionInfo.newBuilder().build()).build();
Operation resultOperation = Operation.newBuilder().setName("createBackupTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
String parent = "parent-995424086";
String backupId = "backupId2121930365";
Backup backup = Backup.newBuilder().build();
Backup actualResponse = client.createBackupAsync(parent, backupId, backup).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateBackupRequest actualRequest = ((CreateBackupRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertEquals(backupId, actualRequest.getBackupId());
Assert.assertEquals(backup, actualRequest.getBackup());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.Cluster in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method listSnapshotsExceptionTest.
@Test
public void listSnapshotsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
client.listSnapshots(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.admin.v2.Cluster 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()));
}
use of com.google.bigtable.admin.v2.Cluster in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method deleteBackupTest.
@Test
public void deleteBackupTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableTableAdmin.addResponse(expectedResponse);
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
client.deleteBackup(name);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations