BigtableAsyncBufferedMutator implements AsyncBufferedMutator { @Override public List<CompletableFuture<Void>> mutate(List<? extends Mutation> mutations) { return helper.mutate(mutations).stream() .map(apiFuture -> toCompletableFuture(apiFuture).thenApply(r -> (Void) null)) .collect(Collectors.toList()); } BigtableAsyncBufferedMutator(
      BigtableApi bigtableApi, BigtableHBaseSettings settings, HBaseRequestAdapter adapter); @Override void close(); @Override void flush(); @Override Configuration getConfiguration(); @Override TableName getName(); @Override long getWriteBufferSize(); @Override List<CompletableFuture<Void>> mutate(List<? extends Mutation> mutations); @Override CompletableFuture<Void> mutate(final Mutation mutation);  }
@Test public void testMutate() throws ExecutionException, InterruptedException { Put put = new Put(Bytes.toBytes("rowKey")); RowMutationEntry entry = RowMutationEntry.create("rowKey"); when(mockRequestAdapter.adaptEntry(put)).thenReturn(entry); when(mockBulkMutation.add(entry)).thenReturn(ApiFutures.immediateFuture(null)); asyncBufferedMutator.mutate(put).get(); verify(mockRequestAdapter).adaptEntry(put); verify(mockBulkMutation).add(entry); }
@Test public void testMutateWithList() { Put put = new Put(Bytes.toBytes("rowKey")); Delete delete = new Delete(Bytes.toBytes("to-be-deleted-row")); Append append = new Append(Bytes.toBytes("appended-row")); RowMutationEntry rowEntryForPut = RowMutationEntry.create("rowKey"); RowMutationEntry rowEntryForDelete = RowMutationEntry.create("to-be-deleted-row"); ReadModifyWriteRow readModifyWriteRow = ReadModifyWriteRow.create(TABLE_ID, "appended-row"); when(mockRequestAdapter.adaptEntry(put)).thenReturn(rowEntryForPut); when(mockRequestAdapter.adaptEntry(delete)).thenReturn(rowEntryForDelete); when(mockRequestAdapter.adapt(append)).thenReturn(readModifyWriteRow); when(mockBulkMutation.add(rowEntryForPut)).thenReturn(ApiFutures.immediateFuture(null)); when(mockBulkMutation.add(rowEntryForDelete)).thenReturn(ApiFutures.immediateFuture(null)); when(mockDataClient.readModifyWriteRowAsync(readModifyWriteRow)) .thenReturn(ApiFutures.immediateFuture(Result.EMPTY_RESULT)); asyncBufferedMutator .mutate(Arrays.asList(put, delete, append)) .forEach( future -> { try { future.get(); } catch (InterruptedException | ExecutionException e) { throw new AssertionError("BigtableAsyncBufferedMutator#mutate test failed"); } }); verify(mockRequestAdapter).adaptEntry(put); verify(mockRequestAdapter).adaptEntry(delete); verify(mockRequestAdapter).adapt(append); verify(mockBulkMutation).add(rowEntryForPut); verify(mockBulkMutation).add(rowEntryForDelete); verify(mockDataClient).readModifyWriteRowAsync(readModifyWriteRow); }