use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method getClusterTest.
@Test
public void getClusterTest() throws Exception {
Cluster expectedResponse = Cluster.newBuilder().setName(ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]").toString()).setLocation(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setServeNodes(-1288838783).setDefaultStorageType(StorageType.forNumber(0)).setEncryptionConfig(Cluster.EncryptionConfig.newBuilder().build()).build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
Cluster actualResponse = client.getCluster(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetClusterRequest actualRequest = ((GetClusterRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method getClusterExceptionTest.
@Test
public void getClusterExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
client.getCluster(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method deleteClusterExceptionTest.
@Test
public void deleteClusterExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
client.deleteCluster(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method deleteClusterTest.
@Test
public void deleteClusterTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
client.deleteCluster(name);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteClusterRequest actualRequest = ((DeleteClusterRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableTest3.
@Test
public void snapshotTableTest3() 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();
Operation resultOperation = Operation.newBuilder().setName("snapshotTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
String name = "name3373707";
ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
String snapshotId = "snapshotId-1113817601";
String description = "description-1724546052";
Snapshot actualResponse = client.snapshotTableAsync(name, cluster, snapshotId, description).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
SnapshotTableRequest actualRequest = ((SnapshotTableRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertEquals(cluster.toString(), actualRequest.getCluster());
Assert.assertEquals(snapshotId, actualRequest.getSnapshotId());
Assert.assertEquals(description, actualRequest.getDescription());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations