### Question:
BatchingReadPipe implements ReadPipe<List<T>> { @Override public void drainTo(final Collection<List<T>> output, final int maxElements) { final List<T> nextBatch = poll(); if (nextBatch != null) { output.add(nextBatch); } } BatchingReadPipe(
      final ReadPipe<T> input, final int maximumBatchSize, final Counter batchCounter); @Override boolean hasMore(); @Override boolean isAborted(); @Override List<T> get(); @Override List<T> poll(); @Override void drainTo(final Collection<List<T>> output, final int maxElements);  }### Answer:
@Test public void shouldAddAtMostOneItemWhenDraining() { source.put("a"); source.put("b"); source.put("c"); source.put("1"); source.put("2"); source.put("3"); final List<List<String>> output = new ArrayList<>(); batchingPipe.drainTo(output, 6); assertThat(output).containsExactly(asList("a", "b", "c")); }
@Test public void shouldCountBatchesReturnedFromDrainTo() { final List<List<String>> output = new ArrayList<>(); batchingPipe.drainTo(output, 3); verifyZeroInteractions(batchCounter); source.put("a"); batchingPipe.drainTo(output, 3); verify(batchCounter, times(1)).inc(); }