### Question:
DirectSolrInputDocumentWriter implements SolrInputDocumentWriter { @Override public void deleteById(int shard, List<String> idsToDelete) throws SolrServerException, IOException { try { solrServer.deleteById(idsToDelete); indexDeleteMeter.mark(idsToDelete.size()); } catch (SolrException e) { if (isDocumentIssue(e)) { retryDeletesIndividually(idsToDelete); } else { solrDeleteErrorMeter.mark(idsToDelete.size()); throw e; } } catch (SolrServerException sse) { solrDeleteErrorMeter.mark(idsToDelete.size()); throw sse; } } DirectSolrInputDocumentWriter(String indexName, SolrClient solrServer); @Override void add(int shard, Map<String, SolrInputDocument> inputDocumentMap); @Override void deleteById(int shard, List<String> idsToDelete); @Override void deleteByQuery(String deleteQuery); @Override void close();  }### Answer:
@Test public void testDeleteById_NormalCase() throws SolrServerException, IOException { List<String> toDelete = Lists.newArrayList("idA", "idB"); solrWriter.deleteById(-1, toDelete); verify(solrServer).deleteById(toDelete); }
@Test(expected = IOException.class) public void testDeleteById_IOException() throws SolrServerException, IOException { List<String> idsToDelete = Lists.newArrayList("idA", "idB"); when(solrServer.deleteById(idsToDelete)).thenThrow(new IOException()); solrWriter.deleteById(-1, idsToDelete); }
@Test(expected = SolrException.class) public void testDeleteById_SolrExceptionCausedByIOException() throws SolrServerException, IOException { List<String> idsToDelete = Lists.newArrayList("idA", "idB"); when(solrServer.deleteById(idsToDelete)).thenThrow(new SolrException(ErrorCode.SERVER_ERROR, new IOException())); solrWriter.deleteById(-1, idsToDelete); }
@Test public void testDeleteById_BadRequest() throws SolrServerException, IOException { List<String> idsToDelete = Lists.newArrayList("idA", "idB"); when(solrServer.deleteById(idsToDelete)).thenThrow( new SolrException(ErrorCode.BAD_REQUEST, "should be swallowed and logged")); solrWriter.deleteById(-1, idsToDelete); }
@Test public void testDeleteById_RetryIndividually() throws SolrServerException, IOException { String badId = "badId"; String goodId = "goodId"; List<String> idsToDelete = Lists.newArrayList(badId, goodId); when(solrServer.deleteById(idsToDelete)).thenThrow(new SolrException(ErrorCode.BAD_REQUEST, "bad id")); when(solrServer.deleteById(badId)).thenThrow(new SolrException(ErrorCode.BAD_REQUEST, "bad id")); solrWriter.deleteById(-1, idsToDelete); verify(solrServer).deleteById(goodId); }