### Question:
SolrUpdateDriver { public void addDocument(IndexDocumentBean idb) throws IndexingException { Map<String, Object> fields = idb.getFields(); for (String field : solrSettings.getRequiredFields()) { if (!fields.containsKey(field)) { throw new IndexingException("Required indexing field {" + field + "} was not present"); } } try { log.info("Queuing {} for full indexing", idb.getId()); idb.set_version_(0l); solrClient.addBean(idb); } catch (IOException e) { throw new IndexingException("Failed to add document to solr", e); } catch (SolrServerException e) { throw new IndexingException("Failed to add document to solr", e); } }  void init(); void addDocument(IndexDocumentBean idb); void updateDocument(IndexDocumentBean idb); void delete(PID pid); void delete(String pid); void deleteByQuery(String query); void commit(); int getAutoPushCount(); void setAutoPushCount(int autoPushCount); int getUpdateThreads(); void setUpdateThreads(int updateThreads); void setSolrClient(SolrClient solrClient); void setUpdateSolrClient(SolrClient updateSolrClient); void setSolrSettings(SolrSettings solrSettings);  }### Answer:
@Test(expected = IndexingException.class) public void testRequiredIndexingFieldsMissing() throws Exception { when(idb.getFields()).thenReturn(missingFields); driver.addDocument(idb); }
@Test public void testRequiredIndexingFieldsSet() throws Exception { for (String field : REQUIRED_INDEXING_FIELDS) { allFields.put(field, field); } when(idb.getFields()).thenReturn(allFields); driver.addDocument(idb); verify(solrClient).addBean(any(IndexDocumentBean.class)); }