use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createTableFromSnapshotExceptionTest2.
@Test
public void createTableFromSnapshotExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String tableId = "tableId-1552905847";
String sourceSnapshot = "sourceSnapshot-1078634753";
client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createClusterExceptionTest.
@Test
public void createClusterExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String clusterId = "clusterId561939637";
Cluster cluster = Cluster.newBuilder().build();
client.createClusterAsync(parent, clusterId, cluster).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method getInstanceTest.
@Test
public void getInstanceTest() throws Exception {
Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
mockBigtableInstanceAdmin.addResponse(expectedResponse);
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance actualResponse = client.getInstance(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetInstanceRequest actualRequest = ((GetInstanceRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method createClusterTest.
@Test
public void createClusterTest() 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();
Operation resultOperation = Operation.newBuilder().setName("createClusterTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableInstanceAdmin.addResponse(resultOperation);
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String clusterId = "clusterId561939637";
Cluster cluster = Cluster.newBuilder().build();
Cluster actualResponse = client.createClusterAsync(parent, clusterId, cluster).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateClusterRequest actualRequest = ((CreateClusterRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(clusterId, actualRequest.getClusterId());
Assert.assertEquals(cluster, actualRequest.getCluster());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClientTest method listAppProfilesExceptionTest.
@Test
public void listAppProfilesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableInstanceAdmin.addException(exception);
try {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
client.listAppProfiles(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations