DataClientClassicApi implements DataClientWrapper { @Override public org.apache.hadoop.hbase.client.ResultScanner readRows(Query request) { final ResultScanner<FlatRow> bigtableResultScanner = delegate.readFlatRows(request.toProto(requestContext)); return new AbstractClientScanner() { @Override public Result next() throws IOException { FlatRow flatRow = bigtableResultScanner.next(); if (flatRow == null) { return null; } return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRow); } @Override public void close() { try { bigtableResultScanner.close(); } catch (IOException e) { throw new RuntimeException(e); } } public boolean renewLease() { throw new UnsupportedOperationException("renewLease"); } }; } 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();  }
@Test public void testReadRows() throws Exception { Query query = Query.create(TABLE_ID); when(delegate.readFlatRows(query.toProto(REQUEST_CONTEXT))).thenReturn(mockFlatRowScanner); when(mockFlatRowScanner.next()) .thenReturn(SAMPLE_FLAT_ROW) .thenReturn(SAMPLE_FLAT_ROW) .thenReturn(SAMPLE_FLAT_ROW) .thenReturn(null); doNothing().when(mockFlatRowScanner).close(); try (org.apache.hadoop.hbase.client.ResultScanner actualResult = dataClientWrapper.readRows(query)) { assertArrayEquals( FLAT_ROW_ADAPTER.adaptResponse(SAMPLE_FLAT_ROW).rawCells(), actualResult.next().rawCells()); assertEquals(2, actualResult.next(5).length); } verify(mockFlatRowScanner, times(4)).next(); verify(mockFlatRowScanner).close(); verify(delegate).readFlatRows(query.toProto(REQUEST_CONTEXT)); }