Search in sources :

Example 6 with ClusterName

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()));
}
Also used : GetClusterRequest(com.google.bigtable.admin.v2.GetClusterRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Cluster(com.google.bigtable.admin.v2.Cluster) ClusterName(com.google.bigtable.admin.v2.ClusterName) Test(org.junit.Test)

Example 7 with ClusterName

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

Example 8 with ClusterName

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

Example 9 with ClusterName

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()));
}
Also used : Empty(com.google.protobuf.Empty) DeleteClusterRequest(com.google.bigtable.admin.v2.DeleteClusterRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ClusterName(com.google.bigtable.admin.v2.ClusterName) Test(org.junit.Test)

Example 10 with ClusterName

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

Aggregations

ClusterName (com.google.bigtable.admin.v2.ClusterName)14 Test (org.junit.Test)14 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 AbstractMessage (com.google.protobuf.AbstractMessage)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ByteString (com.google.protobuf.ByteString)6 Backup (com.google.bigtable.admin.v2.Backup)3 Snapshot (com.google.bigtable.admin.v2.Snapshot)3 Operation (com.google.longrunning.Operation)3 ExecutionException (java.util.concurrent.ExecutionException)3 DeleteClusterRequest (com.google.bigtable.admin.v2.DeleteClusterRequest)2 SnapshotTableRequest (com.google.bigtable.admin.v2.SnapshotTableRequest)2 TableName (com.google.bigtable.admin.v2.TableName)2 Cluster (com.google.bigtable.admin.v2.Cluster)1 CreateBackupRequest (com.google.bigtable.admin.v2.CreateBackupRequest)1 GetClusterRequest (com.google.bigtable.admin.v2.GetClusterRequest)1 ListBackupsRequest (com.google.bigtable.admin.v2.ListBackupsRequest)1 ListBackupsResponse (com.google.bigtable.admin.v2.ListBackupsResponse)1 ListSnapshotsRequest (com.google.bigtable.admin.v2.ListSnapshotsRequest)1 ListSnapshotsResponse (com.google.bigtable.admin.v2.ListSnapshotsResponse)1