### Question:
BufferedSolrInputDocumentWriter implements SolrInputDocumentWriter { @Override public void add(int shard, Map<String, SolrInputDocument> inputDocumentMap) throws SolrServerException, IOException { try { writeBuffers.get(shard).putAll(inputDocumentMap); } catch (ExecutionException e) { throw new RuntimeException("cacheloader error", e); } adds += inputDocumentMap.size(); if (adds >= bufferSize) { flush(); } } 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 testAdd() throws SolrServerException, IOException { SolrInputDocument doc = mock(SolrInputDocument.class); bufferedWriter.add(-1, ImmutableMap.of("a", doc)); verify(delegateWriter, never()).add(eq(-1), anyMap()); }
@Test public void testAdd_PastFlush() throws SolrServerException, IOException { SolrInputDocument docA = mock(SolrInputDocument.class); SolrInputDocument docB = mock(SolrInputDocument.class); SolrInputDocument docC = mock(SolrInputDocument.class); bufferedWriter.add(-1, ImmutableMap.of("a", docA)); bufferedWriter.add(-1, ImmutableMap.of("b", docB)); bufferedWriter.add(-1, ImmutableMap.of("c", docC)); verify(delegateWriter).add(eq(-1), eq(ImmutableMap.of("a", docA, "b", docB, "c", docC))); }