### Question:
SolrStorageEngine implements StorageEngine { @Override public boolean isReady() { boolean ready = false; try { SolrPingResponse response = server.ping(); ready = (response != null && response.getStatus() == STATUS_OK); if (!ready) { if (response == null) { LOGGER.error("Search engine returned null response from ping()"); } else { LOGGER.error("Search engine is not ready: ", response.getResponse()); } } } catch (SolrServerException e) { LOGGER.error("Server exception from ping(): {}", e.getMessage()); } catch (IOException e) { LOGGER.error("IO exception when calling server: {}", e.getMessage()); } return ready; } SolrStorageEngine(SolrConfiguration config);   SolrStorageEngine(SolrConfiguration config, SolrClient server); @Override boolean isReady(); @Override void storeOntologyEntry(OntologyEntryBean entry); @Override void storeOntologyEntries(List<OntologyEntryBean> entries); @Override void setConfiguration(Map<String, Object> configuration); @Override void initialise();  }### Answer:
@Test public void isReady_serverThrowsSolrServerException() throws Exception { final SolrConfiguration config = mock(SolrConfiguration.class); SolrClient server = mock(SolrClient.class); when(server.ping()).thenThrow(new SolrServerException("Error")); StorageEngine engine = new SolrStorageEngine(config, server); assertFalse(engine.isReady()); verify(server).ping(); }
@Test public void isReady_serverThrowsIOException() throws Exception { final SolrConfiguration config = mock(SolrConfiguration.class); SolrClient server = mock(SolrClient.class); when(server.ping()).thenThrow(new IOException("Error")); StorageEngine engine = new SolrStorageEngine(config, server); assertFalse(engine.isReady()); verify(server).ping(); }
@Test public void isReady_serverReturnsNullResponse() throws Exception { final SolrConfiguration config = mock(SolrConfiguration.class); SolrClient server = mock(SolrClient.class); when(server.ping()).thenReturn(null); StorageEngine engine = new SolrStorageEngine(config, server); assertFalse(engine.isReady()); verify(server).ping(); }
@Test public void isReady_nonZeroResponseStatus() throws Exception { final SolrConfiguration config = mock(SolrConfiguration.class); SolrPingResponse response = mock(SolrPingResponse.class); when(response.getStatus()).thenReturn(1); SolrClient server = mock(SolrClient.class); when(server.ping()).thenReturn(response); StorageEngine engine = new SolrStorageEngine(config, server); assertFalse(engine.isReady()); verify(server).ping(); }
@Test public void isReady_zeroResponseStatus() throws Exception { final SolrConfiguration config = mock(SolrConfiguration.class); SolrPingResponse response = mock(SolrPingResponse.class); when(response.getStatus()).thenReturn(SolrStorageEngine.STATUS_OK); SolrClient server = mock(SolrClient.class); when(server.ping()).thenReturn(response); StorageEngine engine = new SolrStorageEngine(config, server); assertTrue(engine.isReady()); verify(server).ping(); }