Search in sources :

Example 96 with Instance

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

the class BaseBigtableInstanceAdminClientTest method partialUpdateInstanceExceptionTest.

@Test
public void partialUpdateInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        Instance instance = Instance.newBuilder().build();
        FieldMask updateMask = FieldMask.newBuilder().build();
        client.partialUpdateInstanceAsync(instance, updateMask).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) Instance(com.google.bigtable.admin.v2.Instance) StatusRuntimeException(io.grpc.StatusRuntimeException) ExecutionException(java.util.concurrent.ExecutionException) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 97 with Instance

use of com.google.bigtable.admin.v2.Instance 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 98 with Instance

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

the class BaseBigtableInstanceAdminClientTest method partialUpdateClusterTest.

@Test
public void partialUpdateClusterTest() 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("partialUpdateClusterTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableInstanceAdmin.addResponse(resultOperation);
    Cluster cluster = Cluster.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    Cluster actualResponse = client.partialUpdateClusterAsync(cluster, updateMask).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    PartialUpdateClusterRequest actualRequest = ((PartialUpdateClusterRequest) actualRequests.get(0));
    Assert.assertEquals(cluster, actualRequest.getCluster());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : PartialUpdateClusterRequest(com.google.bigtable.admin.v2.PartialUpdateClusterRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Cluster(com.google.bigtable.admin.v2.Cluster) Operation(com.google.longrunning.Operation) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 99 with Instance

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

the class BaseBigtableInstanceAdminClientTest method getAppProfileTest2.

@Test
public void getAppProfileTest2() throws Exception {
    AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    AppProfile actualResponse = client.getAppProfile(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetAppProfileRequest actualRequest = ((GetAppProfileRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : GetAppProfileRequest(com.google.bigtable.admin.v2.GetAppProfileRequest) AbstractMessage(com.google.protobuf.AbstractMessage) AppProfile(com.google.bigtable.admin.v2.AppProfile) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 100 with Instance

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

the class BaseBigtableInstanceAdminClientTest method createAppProfileTest.

@Test
public void createAppProfileTest() throws Exception {
    AppProfile expectedResponse = AppProfile.newBuilder().setName(AppProfileName.of("[PROJECT]", "[INSTANCE]", "[APP_PROFILE]").toString()).setEtag("etag3123477").setDescription("description-1724546052").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
    String appProfileId = "appProfileId704923523";
    AppProfile appProfile = AppProfile.newBuilder().build();
    AppProfile actualResponse = client.createAppProfile(parent, appProfileId, appProfile);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateAppProfileRequest actualRequest = ((CreateAppProfileRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
    Assert.assertEquals(appProfile, actualRequest.getAppProfile());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) AbstractMessage(com.google.protobuf.AbstractMessage) AppProfile(com.google.bigtable.admin.v2.AppProfile) CreateAppProfileRequest(com.google.bigtable.admin.v2.CreateAppProfileRequest) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)108 AbstractMessage (com.google.protobuf.AbstractMessage)55 ByteString (com.google.protobuf.ByteString)49 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)37 StatusRuntimeException (io.grpc.StatusRuntimeException)37 InstanceName (com.google.bigtable.admin.v2.InstanceName)20 Operation (com.google.longrunning.Operation)19 HashMap (java.util.HashMap)16 Table (com.google.bigtable.admin.v2.Table)15 TableName (com.google.bigtable.admin.v2.TableName)15 ClusterName (com.google.bigtable.admin.v2.ClusterName)14 Cluster (com.google.bigtable.admin.v2.Cluster)13 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)13 ExecutionException (java.util.concurrent.ExecutionException)13 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 Instance (com.google.bigtable.admin.v2.Instance)10 SnapshotName (com.google.bigtable.admin.v2.SnapshotName)8 Empty (com.google.protobuf.Empty)8 Backup (com.google.bigtable.admin.v2.Backup)7