Search in sources :

Example 21 with CheckAndMutateRowRequest

use of com.google.bigtable.v2.CheckAndMutateRowRequest in project gapic-generator-java by googleapis.

the class BaseBigtableDataClientTest method checkAndMutateRowTest3.

@Test
public void checkAndMutateRowTest3() throws Exception {
    CheckAndMutateRowResponse expectedResponse = CheckAndMutateRowResponse.newBuilder().setPredicateMatched(true).build();
    mockBigtable.addResponse(expectedResponse);
    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";
    CheckAndMutateRowResponse actualResponse = client.checkAndMutateRow(tableName, rowKey, predicateFilter, trueMutations, falseMutations, appProfileId);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtable.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CheckAndMutateRowRequest actualRequest = ((CheckAndMutateRowRequest) actualRequests.get(0));
    Assert.assertEquals(tableName.toString(), actualRequest.getTableName());
    Assert.assertEquals(rowKey, actualRequest.getRowKey());
    Assert.assertEquals(predicateFilter, actualRequest.getPredicateFilter());
    Assert.assertEquals(trueMutations, actualRequest.getTrueMutationsList());
    Assert.assertEquals(falseMutations, actualRequest.getFalseMutationsList());
    Assert.assertEquals(appProfileId, actualRequest.getAppProfileId());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : TableName(com.google.bigtable.v2.TableName) RowFilter(com.google.bigtable.v2.RowFilter) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) CheckAndMutateRowResponse(com.google.bigtable.v2.CheckAndMutateRowResponse) ArrayList(java.util.ArrayList) Mutation(com.google.bigtable.v2.Mutation) ByteString(com.google.protobuf.ByteString) CheckAndMutateRowRequest(com.google.bigtable.v2.CheckAndMutateRowRequest) Test(org.junit.Test)

Example 22 with CheckAndMutateRowRequest

use of com.google.bigtable.v2.CheckAndMutateRowRequest in project gapic-generator-java by googleapis.

the class SyncCheckAndMutateRow method syncCheckAndMutateRow.

public static void syncCheckAndMutateRow() throws Exception {
    // It may require modifications to work in your environment.
    try (BaseBigtableDataClient baseBigtableDataClient = BaseBigtableDataClient.create()) {
        CheckAndMutateRowRequest request = CheckAndMutateRowRequest.newBuilder().setTableName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).setAppProfileId("appProfileId704923523").setRowKey(ByteString.EMPTY).setPredicateFilter(RowFilter.newBuilder().build()).addAllTrueMutations(new ArrayList<Mutation>()).addAllFalseMutations(new ArrayList<Mutation>()).build();
        CheckAndMutateRowResponse response = baseBigtableDataClient.checkAndMutateRow(request);
    }
}
Also used : ArrayList(java.util.ArrayList) CheckAndMutateRowResponse(com.google.bigtable.v2.CheckAndMutateRowResponse) Mutation(com.google.bigtable.v2.Mutation) BaseBigtableDataClient(com.google.cloud.bigtable.data.v2.BaseBigtableDataClient) CheckAndMutateRowRequest(com.google.bigtable.v2.CheckAndMutateRowRequest)

Aggregations

CheckAndMutateRowRequest (com.google.bigtable.v2.CheckAndMutateRowRequest)21 Test (org.junit.Test)18 Mutation (com.google.bigtable.v2.Mutation)10 RowFilter (com.google.bigtable.v2.RowFilter)8 CheckAndMutateRowResponse (com.google.bigtable.v2.CheckAndMutateRowResponse)7 ArrayList (java.util.ArrayList)7 ByteString (com.google.protobuf.ByteString)6 AbstractMessage (com.google.protobuf.AbstractMessage)4 TableName (com.google.bigtable.v2.TableName)2 BaseBigtableDataClient (com.google.cloud.bigtable.data.v2.BaseBigtableDataClient)2 RowMutations (org.apache.hadoop.hbase.client.RowMutations)2 HeaderTracerUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.HeaderTracerUnaryCallable)1 StatsHeadersUnaryCallable (com.google.cloud.bigtable.data.v2.stub.metrics.StatsHeadersUnaryCallable)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 Delete (org.apache.hadoop.hbase.client.Delete)1 Put (org.apache.hadoop.hbase.client.Put)1 CompareOp (org.apache.hadoop.hbase.filter.CompareFilter.CompareOp)1