BulkMutationVeneerApi implements BulkMutationWrapper { @Override public synchronized ApiFuture<Void> add(RowMutationEntry rowMutation) { Preconditions.checkNotNull(rowMutation, "mutation details cannot be null"); return bulkMutateBatcher.add(rowMutation); } BulkMutationVeneerApi(Batcher<RowMutationEntry, Void> bulkMutateBatcher); @Override synchronized ApiFuture<Void> add(RowMutationEntry rowMutation); @Override void sendUnsent(); @Override void flush(); @Override void close();  }
@Test public void testAdd() { SettableApiFuture<Void> future = SettableApiFuture.create(); when(batcher.add(rowMutation)).thenReturn(future); ApiFuture<Void> result = bulkMutationWrapper.add(rowMutation); assertFalse(result.isDone()); future.set(null); assertTrue(result.isDone()); verify(batcher).add(rowMutation); }
@Test public void testAddFailure() { RuntimeException exception = new RuntimeException("can not perform mutation"); SettableApiFuture<Void> future = SettableApiFuture.create(); when(batcher.add(rowMutation)).thenReturn(future); future.setException(exception); try { bulkMutationWrapper.add(rowMutation).get(); fail("should throw an exception"); } catch (Exception actualException) { assertEquals(exception, actualException.getCause()); } verify(batcher).add(rowMutation); }