Search in sources :

Example 6 with TableName

use of com.google.cloud.bigquery.storage.v1beta2.TableName in project gapic-generator-java by googleapis.

the class BaseBigtableDataClientTest method readModifyWriteRowTest3.

@Test
public void readModifyWriteRowTest3() throws Exception {
    ReadModifyWriteRowResponse expectedResponse = ReadModifyWriteRowResponse.newBuilder().setRow(Row.newBuilder().build()).build();
    mockBigtable.addResponse(expectedResponse);
    TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
    ByteString rowKey = ByteString.EMPTY;
    List<ReadModifyWriteRule> rules = new ArrayList<>();
    String appProfileId = "appProfileId704923523";
    ReadModifyWriteRowResponse actualResponse = client.readModifyWriteRow(tableName, rowKey, rules, appProfileId);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtable.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ReadModifyWriteRowRequest actualRequest = ((ReadModifyWriteRowRequest) actualRequests.get(0));
    Assert.assertEquals(tableName.toString(), actualRequest.getTableName());
    Assert.assertEquals(rowKey, actualRequest.getRowKey());
    Assert.assertEquals(rules, actualRequest.getRulesList());
    Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : TableName(com.google.bigtable.v2.TableName) AbstractMessage(com.google.protobuf.AbstractMessage) ReadModifyWriteRowRequest(com.google.bigtable.v2.ReadModifyWriteRowRequest) ByteString(com.google.protobuf.ByteString) ArrayList(java.util.ArrayList) ReadModifyWriteRule(com.google.bigtable.v2.ReadModifyWriteRule) ByteString(com.google.protobuf.ByteString) ReadModifyWriteRowResponse(com.google.bigtable.v2.ReadModifyWriteRowResponse) Test(org.junit.Test)

Example 7 with TableName

use of com.google.cloud.bigquery.storage.v1beta2.TableName in project gapic-generator-java by googleapis.

the class BaseBigtableDataClientTest method mutateRowTest.

@Test
public void mutateRowTest() throws Exception {
    MutateRowResponse expectedResponse = MutateRowResponse.newBuilder().build();
    mockBigtable.addResponse(expectedResponse);
    TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
    ByteString rowKey = ByteString.EMPTY;
    List<Mutation> mutations = new ArrayList<>();
    MutateRowResponse actualResponse = client.mutateRow(tableName, rowKey, mutations);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtable.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    MutateRowRequest actualRequest = ((MutateRowRequest) actualRequests.get(0));
    Assert.assertEquals(tableName.toString(), actualRequest.getTableName());
    Assert.assertEquals(rowKey, actualRequest.getRowKey());
    Assert.assertEquals(mutations, actualRequest.getMutationsList());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : CheckAndMutateRowRequest(com.google.bigtable.v2.CheckAndMutateRowRequest) MutateRowRequest(com.google.bigtable.v2.MutateRowRequest) TableName(com.google.bigtable.v2.TableName) CheckAndMutateRowResponse(com.google.bigtable.v2.CheckAndMutateRowResponse) MutateRowResponse(com.google.bigtable.v2.MutateRowResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) ArrayList(java.util.ArrayList) Mutation(com.google.bigtable.v2.Mutation) Test(org.junit.Test)

Example 8 with TableName

use of com.google.cloud.bigquery.storage.v1beta2.TableName in project gapic-generator-java by googleapis.

the class BaseBigtableDataClientTest method checkAndMutateRowExceptionTest.

@Test
public void checkAndMutateRowExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtable.addException(exception);
    try {
        TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
        ByteString rowKey = ByteString.EMPTY;
        RowFilter predicateFilter = RowFilter.newBuilder().build();
        List<Mutation> trueMutations = new ArrayList<>();
        List<Mutation> falseMutations = new ArrayList<>();
        client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : TableName(com.google.bigtable.v2.TableName) RowFilter(com.google.bigtable.v2.RowFilter) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) Mutation(com.google.bigtable.v2.Mutation) Test(org.junit.Test)

Example 9 with TableName

use of com.google.cloud.bigquery.storage.v1beta2.TableName in project gapic-generator-java by googleapis.

the class BaseBigtableDataClientTest method readModifyWriteRowExceptionTest3.

@Test
public void readModifyWriteRowExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtable.addException(exception);
    try {
        TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
        ByteString rowKey = ByteString.EMPTY;
        List<ReadModifyWriteRule> rules = new ArrayList<>();
        String appProfileId = "appProfileId704923523";
        client.readModifyWriteRow(tableName, rowKey, rules, appProfileId);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : TableName(com.google.bigtable.v2.TableName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) ReadModifyWriteRule(com.google.bigtable.v2.ReadModifyWriteRule) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 10 with TableName

use of com.google.cloud.bigquery.storage.v1beta2.TableName in project gapic-generator-java by googleapis.

the class BaseBigtableDataClientTest method checkAndMutateRowExceptionTest3.

@Test
public void checkAndMutateRowExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtable.addException(exception);
    try {
        TableName tableName = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
        ByteString rowKey = ByteString.EMPTY;
        RowFilter predicateFilter = RowFilter.newBuilder().build();
        List<Mutation> trueMutations = new ArrayList<>();
        List<Mutation> falseMutations = new ArrayList<>();
        String appProfileId = "appProfileId704923523";
        client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations, appProfileId);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : TableName(com.google.bigtable.v2.TableName) RowFilter(com.google.bigtable.v2.RowFilter) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) ArrayList(java.util.ArrayList) Mutation(com.google.bigtable.v2.Mutation) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)33 ByteString (com.google.protobuf.ByteString)28 ArrayList (java.util.ArrayList)20 TableName (com.google.bigtable.v2.TableName)18 TableName (com.google.bigtable.admin.v2.TableName)17 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)13 AbstractMessage (com.google.protobuf.AbstractMessage)13 StatusRuntimeException (io.grpc.StatusRuntimeException)13 Mutation (com.google.bigtable.v2.Mutation)12 JSONArray (org.json.JSONArray)9 JSONObject (org.json.JSONObject)9 ExecutionException (java.util.concurrent.ExecutionException)8 TableName (com.google.cloud.bigquery.storage.v1.TableName)7 ReadModifyWriteRule (com.google.bigtable.v2.ReadModifyWriteRule)6 RowFilter (com.google.bigtable.v2.RowFilter)6 BaseBigtableDataClient (com.google.cloud.bigtable.data.v2.BaseBigtableDataClient)6 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)5 CheckAndMutateRowResponse (com.google.bigtable.v2.CheckAndMutateRowResponse)4 ReadModifyWriteRowResponse (com.google.bigtable.v2.ReadModifyWriteRowResponse)4 FieldValueList (com.google.cloud.bigquery.FieldValueList)4