ThresholdBatcher { public static <E> Builder<E> newBuilder() { return new Builder<>(); } private  ThresholdBatcher(Builder<E> builder); static Builder<E> newBuilder(); void add(E e); @VisibleForTesting ApiFuture<Void> pushCurrentBatch();  }
@Test public void testExceptionWithNullFlowController() { try { ThresholdBatcher.<SimpleBatch>newBuilder() .setThresholds(BatchingThresholds.<SimpleBatch>create(100)) .setExecutor(EXECUTOR) .setMaxDelay(Duration.ofMillis(10000)) .setReceiver( new AccumulatingBatchReceiver<SimpleBatch>(ApiFutures.<Void>immediateFuture(null))) .setBatchMerger(new SimpleBatchMerger()) .build(); Assert.fail("ThresholdBatcher should have thrown an exception"); } catch (NullPointerException expected) { assertThat(expected).isInstanceOf(NullPointerException.class); } }