BigtableDataGCJClient implements IBigtableDataClient, AutoCloseable { @Override public ApiFuture<List<FlatRow>> readFlatRowsAsync(Query request) { return delegate.readRowsCallable(new FlatRowAdapter()).all().futureCall(request); } BigtableDataGCJClient(BigtableDataClient delegate); @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 Boolean checkAndMutateRow(ConditionalRowMutation conditionalRowMutation); @Override ApiFuture<Boolean> checkAndMutateRowAsync(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); @Override void close();  }
@Test public void testReadFlatRowsAsync() throws Exception { UnaryCallable<Query, List<FlatRow>> unaryCallable = mock(UnaryCallable.class); when(dataClientV2.readRowsCallable(any(FlatRowAdapter.class))).thenReturn(serverStreaming); when(serverStreaming.all()).thenReturn(unaryCallable); when(unaryCallable.futureCall(request)).thenReturn(immediateFuture(flatRows)); ApiFuture<List<FlatRow>> actualFlatRows = dataGCJClient.readFlatRowsAsync(request); assertEquals(flatRows, actualFlatRows.get()); verify(dataClientV2).readRowsCallable(any(FlatRowAdapter.class)); verify(serverStreaming).all(); verify(unaryCallable).futureCall(request); }
@Test public void testReadFlatRowsAsyncWithStream() { StreamObserver<FlatRow> streamOb = mock(StreamObserver.class); when(dataClientV2.readRowsCallable(any(FlatRowAdapter.class))).thenReturn(serverStreaming); doNothing().when(serverStreaming).call(any(Query.class), any(ResponseObserver.class)); dataGCJClient.readFlatRowsAsync(request, streamOb); streamOb.onNext(flatRows.get(0)); verify(dataClientV2).readRowsCallable(any(FlatRowAdapter.class)); verify(serverStreaming).call(any(Query.class), any(ResponseObserver.class)); }