### Question:
SolrIndexReloader implements IndexReloader { @Override public void reloadIndex(IndexConfiguration indexConfiguration) { Preconditions.checkNotNull(solrServer); boolean indexExists = checkIndexExists(indexConfiguration); if (indexExists) { reloadIndex(indexConfiguration.getName()); } else { createIndex(indexConfiguration); } }  @Override void reloadIndex(IndexConfiguration indexConfiguration); void setSolrServer(SolrServer solrServer);  }### Answer:
@Test public void reloadIndex_EXISTING() throws SolrServerException, IOException { when(solrServer.request(any())).thenReturn(buildSuccessResponse()); when(solrServer.request(isCheckStatus())).thenReturn(buildCheckStatusResponse()); IndexConfiguration indexConfiguration = new IndexConfiguration(); indexConfiguration.setName(EXISTING_INDEX_NAME); indexConfiguration.setInstanceDir("indexDirectory"); indexReloader.reloadIndex(indexConfiguration); ArgumentCaptor<SolrRequest> solrRequestArg = ArgumentCaptor.forClass(SolrRequest.class); verify(solrServer, times(2)).request(solrRequestArg.capture()); SolrRequest actualCheckRequest = solrRequestArg.getAllValues().get(0); SolrRequest actualReloadRequest = solrRequestArg.getAllValues().get(1); assertStatusRequest(actualCheckRequest); assertReloadRequest(actualReloadRequest, EXISTING_INDEX_NAME); }
@Test public void reloadIndex_NOT_EXISTING() throws SolrServerException, IOException { when(solrServer.request(any())).thenReturn(buildSuccessResponse()); when(solrServer.request(isCheckStatus())).thenReturn(buildCheckStatusResponse()); IndexConfiguration indexConfiguration = new IndexConfiguration(); indexConfiguration.setName(NOT_EXISTING_INDEX_NAME); indexConfiguration.setInstanceDir("indexDirectory"); indexReloader.reloadIndex(indexConfiguration); ArgumentCaptor<SolrRequest> solrRequestArg = ArgumentCaptor.forClass(SolrRequest.class); verify(solrServer, times(2)).request(solrRequestArg.capture()); SolrRequest actualCheckRequest = solrRequestArg.getAllValues().get(0); SolrRequest actualCreateRequest = solrRequestArg.getAllValues().get(1); assertStatusRequest(actualCheckRequest); assertCreateRequest(actualCreateRequest, NOT_EXISTING_INDEX_NAME, "indexDirectory"); }