BulkReadClassicApi implements BulkReadWrapper { @Override public ApiFuture<Result> add(ByteString rowKey, Filters.Filter filter) { Preconditions.checkState(!isClosed, "can't add request when the bulk read is closed."); Query query = Query.create(tableId).rowKey(rowKey); if (filter != null) { query.filter(filter); } return ApiFutures.transform( delegate.add(query), new ApiFunction<FlatRow, Result>() { @Override public Result apply(FlatRow flatRow) { return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRow); } }, MoreExecutors.directExecutor()); } BulkReadClassicApi(@Nonnull BulkRead delegate, @Nonnull String tableId); @Override ApiFuture<Result> add(ByteString rowKey, Filters.Filter filter); @Override void sendOutstanding();  }
@Test public void testAdd() throws ExecutionException, InterruptedException { when(delegate.add(Query.create(TABLE_ID).rowKey("row-key"))) .thenReturn(ApiFutures.immediateFuture(FLAT_ROW)); Result result = bulkReadWrapper.add(ByteString.copyFromUtf8("row-key"), null).get(); assertArrayEquals(FLAT_ROW.getRowKey().toByteArray(), result.getRow()); assertArrayEquals(FLAT_ROW_ADAPTER.adaptResponse(FLAT_ROW).rawCells(), result.rawCells()); verify(delegate).add(Query.create(TABLE_ID).rowKey("row-key")); }
@Test public void testAddWithFilter() throws ExecutionException, InterruptedException { Filters.Filter filter = Filters.FILTERS.family().regex("cf"); Query query = Query.create(TABLE_ID).rowKey("row-key").filter(filter); when(delegate.add(query)).thenReturn(ApiFutures.immediateFuture(FLAT_ROW)); Result result = bulkReadWrapper.add(ByteString.copyFromUtf8("row-key"), filter).get(); assertArrayEquals(FLAT_ROW.getRowKey().toByteArray(), result.getRow()); assertArrayEquals(FLAT_ROW_ADAPTER.adaptResponse(FLAT_ROW).rawCells(), result.rawCells()); verify(delegate).add(query); }