Search in sources :

Example 11 with InstanceName

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()));
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) CreateClusterRequest(com.google.bigtable.admin.v2.CreateClusterRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Cluster(com.google.bigtable.admin.v2.Cluster) Operation(com.google.longrunning.Operation) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 12 with InstanceName

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.
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 13 with InstanceName

use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method listClustersExceptionTest.

@Test
public void listClustersExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
        client.listClusters(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 14 with InstanceName

use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method deleteInstanceExceptionTest.

@Test
public void deleteInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
        client.deleteInstance(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 15 with InstanceName

use of com.google.bigtable.admin.v2.InstanceName in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method getInstanceExceptionTest.

@Test
public void getInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
        client.getInstance(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 InstanceName (com.google.bigtable.admin.v2.InstanceName)20 ByteString (com.google.protobuf.ByteString)13 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)10 AbstractMessage (com.google.protobuf.AbstractMessage)10 StatusRuntimeException (io.grpc.StatusRuntimeException)10 Table (com.google.bigtable.admin.v2.Table)7 AppProfile (com.google.bigtable.admin.v2.AppProfile)3 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)3 Operation (com.google.longrunning.Operation)3 HashMap (java.util.HashMap)3 ExecutionException (java.util.concurrent.ExecutionException)3 Cluster (com.google.bigtable.admin.v2.Cluster)2 CreateTableFromSnapshotRequest (com.google.bigtable.admin.v2.CreateTableFromSnapshotRequest)2 DeleteInstanceRequest (com.google.bigtable.admin.v2.DeleteInstanceRequest)2 ListAppProfilesRequest (com.google.bigtable.admin.v2.ListAppProfilesRequest)2 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)2 ListAppProfilesPagedResponse (com.google.cloud.bigtable.admin.v2.BaseBigtableInstanceAdminClient.ListAppProfilesPagedResponse)2 ApiFuture (com.google.api.core.ApiFuture)1 CreateAppProfileRequest (com.google.bigtable.admin.v2.CreateAppProfileRequest)1