@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(delegate.checkAndMutateRowAsync(request)).thenReturn(future); Future<Boolean> actual = dataClientWrapper.checkAndMutateRowAsync(conditonalMutation); verify(delegate).checkAndMutateRowAsync(request); assertFalse(actual.get()); }
@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(); } }); }
DataClientClassicApi implements DataClientWrapper { @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(); } }); } }
DataClientClassicApi implements DataClientWrapper { @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(); } }); } DataClientClassicApi(BigtableSession session, RequestContext requestContext); }
DataClientClassicApi implements DataClientWrapper { @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(); } }); } DataClientClassicApi(BigtableSession session, RequestContext requestContext); @Override BulkMutationWrapper createBulkMutation(String tableId); @Override BulkReadWrapper createBulkRead(String tableId); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override ApiFuture<Result> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter); @Override org.apache.hadoop.hbase.client.ResultScanner readRows(Query request); @Override ApiFuture<List<Result>> readRowsAsync(Query request); @Override void readRowsAsync(Query request, final StreamObserver<Result> observer); @Override void close(); }
DataClientClassicApi implements DataClientWrapper { @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(); } }); } DataClientClassicApi(BigtableSession session, RequestContext requestContext); @Override BulkMutationWrapper createBulkMutation(String tableId); @Override BulkReadWrapper createBulkRead(String tableId); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override ApiFuture<Result> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter); @Override org.apache.hadoop.hbase.client.ResultScanner readRows(Query request); @Override ApiFuture<List<Result>> readRowsAsync(Query request); @Override void readRowsAsync(Query request, final StreamObserver<Result> observer); @Override void close();  }