BigtableDataClientWrapper implements IBigtableDataClient { @Override public ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation) { final CheckAndMutateRowRequest request = conditionalRowMutation.toProto(requestContext); final ListenableFuture<CheckAndMutateRowResponse> response = delegate.checkAndMutateRowAsync(request); return ApiFutureUtil.transformAndAdapt( response, new Function<CheckAndMutateRowResponse, Boolean>() { @Override public Boolean apply(CheckAndMutateRowResponse checkAndMutateRowResponse) { return checkAndMutateRowResponse.getPredicateMatched(); } }); } BigtableDataClientWrapper(
      BigtableDataClient bigtableDataClient, RequestContext requestContext); @Override void mutateRow(RowMutation rowMutation); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override Row readModifyWriteRow(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Row> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override IBulkMutation createBulkMutationBatcher(String tableId); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override Boolean checkAndMutateRow(ConditionalRowMutation conditionalRowMutation); @Override List<KeyOffset> sampleRowKeys(String tableId); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ResultScanner<Row> readRows(Query request); @Override ApiFuture<List<Row>> readRowsAsync(Query request); @Override List<FlatRow> readFlatRowsList(Query request); @Override ResultScanner<FlatRow> readFlatRows(Query request); @Override ApiFuture<List<FlatRow>> readFlatRowsAsync(Query request); @Override void readFlatRowsAsync(Query request, StreamObserver<FlatRow> observer);  }
@Test public void testCheckMutateRowAsync() throws Exception { Mutation mutation = Mutation.create(); mutation.setCell("family", "qualifier", "some other value"); ConditionalRowMutation conditonalMutation = ConditionalRowMutation.create(TABLE_ID, "first" + "-row" + "-key").then(mutation); CheckAndMutateRowRequest request = conditonalMutation.toProto(REQUEST_CONTEXT); CheckAndMutateRowResponse response = CheckAndMutateRowResponse.newBuilder().setPredicateMatched(true).build(); ListenableFuture<CheckAndMutateRowResponse> future = Futures.immediateFuture(response); when(client.checkAndMutateRowAsync(request)).thenReturn(future); Future<Boolean> actual = clientWrapper.checkAndMutateRowAsync(conditonalMutation); verify(client).checkAndMutateRowAsync(request); assertTrue(actual.get()); }
@Test public void testCheckMutateRowAsyncWhenNoPredicateMatch() throws Exception { Mutation mutation = Mutation.create(); mutation.setCell("family", "qualifier", "some other value"); ConditionalRowMutation conditonalMutation = ConditionalRowMutation.create(TABLE_ID, "first" + "-row" + "-key").then(mutation); CheckAndMutateRowRequest request = conditonalMutation.toProto(REQUEST_CONTEXT); CheckAndMutateRowResponse response = CheckAndMutateRowResponse.newBuilder().setPredicateMatched(false).build(); ListenableFuture<CheckAndMutateRowResponse> future = Futures.immediateFuture(response); when(client.checkAndMutateRowAsync(request)).thenReturn(future); Future<Boolean> actual = clientWrapper.checkAndMutateRowAsync(conditonalMutation); verify(client).checkAndMutateRowAsync(request); assertFalse(actual.get()); }