public void doTestDeleteAll(boolean sync, boolean error) throws Exception {
TableWriteFunction<String, String> writeFn = mock(TableWriteFunction.class);
RemoteTable<String, String> table = getTable("testDeleteAll-" + sync + error,
mock(TableReadFunction.class), writeFn, false);
CompletableFuture<Void> future;
if (error) {
future = new CompletableFuture();
future.completeExceptionally(new RuntimeException("Test exception"));
} else {
future = CompletableFuture.completedFuture(null);
}
doReturn(future).when(writeFn).deleteAllAsync(any());
List<String> keys = Arrays.asList("foo1", "foo2");
ArgumentCaptor<List> argCaptor = ArgumentCaptor.forClass(List.class);
if (sync) {
table.deleteAll(keys);
} else {
table.deleteAllAsync(keys).get();
}
verify(writeFn, times(1)).deleteAllAsync(argCaptor.capture());
Assert.assertEquals(keys, argCaptor.getValue());
verify(table.writeRateLimiter, times(1)).throttle(anyCollection());
}