Search in sources :

Example 21 with Cluster

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

Example 22 with Cluster

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

the class BaseBigtableTableAdminClientTest method createTableFromSnapshotExceptionTest.

@Test
public void createTableFromSnapshotExceptionTest() 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";
        SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
        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());
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) ExecutionException(java.util.concurrent.ExecutionException) SnapshotName(com.google.bigtable.admin.v2.SnapshotName) Test(org.junit.Test)

Example 23 with Cluster

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

the class BaseBigtableTableAdminClientTest method createBackupExceptionTest.

@Test
public void createBackupExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableTableAdmin.addException(exception);
    try {
        ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
        String backupId = "backupId2121930365";
        Backup backup = Backup.newBuilder().build();
        client.createBackupAsync(parent, backupId, backup).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());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) Backup(com.google.bigtable.admin.v2.Backup) StatusRuntimeException(io.grpc.StatusRuntimeException) ClusterName(com.google.bigtable.admin.v2.ClusterName) ByteString(com.google.protobuf.ByteString) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 24 with Cluster

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

the class BaseBigtableTableAdminClientTest method deleteBackupExceptionTest.

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

Example 25 with Cluster

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

the class BaseBigtableTableAdminClientTest method deleteSnapshotExceptionTest.

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

Aggregations

Test (org.junit.Test)74 AbstractMessage (com.google.protobuf.AbstractMessage)37 ByteString (com.google.protobuf.ByteString)28 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)23 StatusRuntimeException (io.grpc.StatusRuntimeException)23 ExecutionException (java.util.concurrent.ExecutionException)22 Operation (com.google.longrunning.Operation)18 Cluster (com.google.bigtable.admin.v2.Cluster)16 Cluster (com.google.cloud.dataproc.v1.Cluster)16 ArrayList (java.util.ArrayList)16 ClusterName (com.google.bigtable.admin.v2.ClusterName)14 ClusterOperationMetadata (com.google.cloud.dataproc.v1.ClusterOperationMetadata)13 HashMap (java.util.HashMap)13 Cluster (com.google.container.v1.Cluster)12 ClusterControllerClient (com.google.cloud.dataproc.v1.ClusterControllerClient)11 ClusterControllerSettings (com.google.cloud.dataproc.v1.ClusterControllerSettings)11 Cluster (io.envoyproxy.envoy.config.cluster.v3.Cluster)10 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 ClusterConfig (com.google.cloud.dataproc.v1.ClusterConfig)8 InstanceGroupConfig (com.google.cloud.dataproc.v1.InstanceGroupConfig)8