### Question:
BufferedSolrInputDocumentWriter implements SolrInputDocumentWriter { public void flush() throws SolrServerException, IOException { if (adds > 0) { Map<Integer, Map<String, SolrInputDocument>> maps = writeBuffers.asMap(); for (Map.Entry<Integer, Map<String, SolrInputDocument>> entry : maps.entrySet()) { if (entry.getValue().size() > 0) { delegateWriter.add(entry.getKey(), ImmutableMap.copyOf(entry.getValue())); } } docOutputCounter.increment(adds); docBatchCounter.increment(1L); adds = 0; writeBuffers.invalidateAll(); } } BufferedSolrInputDocumentWriter(SolrInputDocumentWriter delegateWriter, int bufferSize,
            Counter documentOutputCounter, Counter documentBatchOutputCounter); @Override void add(int shard, Map<String, SolrInputDocument> inputDocumentMap); @Override void deleteById(int shard, List<String> idsToDelete); @Override void deleteByQuery(String deleteQuery); void flush(); @Override void close();  }### Answer:
@Test public void testFlush() throws SolrServerException, IOException { SolrInputDocument docA = mock(SolrInputDocument.class); SolrInputDocument docB = mock(SolrInputDocument.class); bufferedWriter.add(-1, ImmutableMap.of("a", docA)); bufferedWriter.flush(); verify(delegateWriter).add(eq(-1), eq(ImmutableMap.of("a", docA))); bufferedWriter.add(-1, ImmutableMap.of("b", docB)); bufferedWriter.flush(); verify(delegateWriter).add(eq(-1), eq(ImmutableMap.of("b", docB))); verify(docCounter, times(2)).increment(1L); }