### Question:
BasicServer extends Server { @SuppressWarnings("deprecation") protected void checkRebuildHasRun(boolean firstRun) throws Exception { Connection conn = null; ConnectionPool cpm = SQLUtility.getConnectionPool(getConfig()); try { conn = cpm.getReadWriteConnection(); long mostRecentRebuildDate = SQLUtility.getMostRecentRebuild(conn); if (firstRun && mostRecentRebuildDate == -1) { SQLUtility.recordSuccessfulRebuild(conn, System.currentTimeMillis()); } else { boolean rebuildFinished = SQLUtility.getRebuildStatus(conn, mostRecentRebuildDate); if (!rebuildFinished) { throw new ServerInitializationException( "The SQL Rebuild attempted on " + new Date(mostRecentRebuildDate).toGMTString() + " did not finish successfully, which may compromise" + " the repo. Please re-run the SQL rebuild."); } } } finally { if (conn != null) cpm.free(conn); } } BasicServer(File fedoraHomeDir);  BasicServer(Element rootElement, File fedoraHomeDir);  BasicServer(Map<String,String> params, File fedoraHomeDir); @Override void initServer(); @Override String[] getRequiredModuleRoles(); @Override void postInitServer();  }### Answer:
@Test public void testFirstRunEmptyDatabase() throws Exception { when(SQLUtility.getMostRecentRebuild(mockRWConnection)) .thenReturn(-1L); test.checkRebuildHasRun(true); verifyStatic(); SQLUtility.recordSuccessfulRebuild( eq(mockRWConnection), any(Long.class)); }
@Test public void testFirstRunNonemptyDatabase() throws Exception { long now = System.currentTimeMillis(); when(SQLUtility.getMostRecentRebuild(mockRWConnection)) .thenReturn(now); when(SQLUtility.getRebuildStatus(mockRWConnection, now)).thenReturn(true); test.checkRebuildHasRun(true); verifyStatic(); SQLUtility.getRebuildStatus(mockRWConnection, now); }
@Test(expected = ServerInitializationException.class) public void testSubsequentRunEmptyDatabase() throws Exception { when(SQLUtility.getMostRecentRebuild(mockRWConnection)) .thenReturn(-1L); test.checkRebuildHasRun(false); }
@Test(expected = ServerInitializationException.class) public void testSubsequentRunBadRebuild() throws Exception { long now = System.currentTimeMillis(); when(SQLUtility.getMostRecentRebuild(mockRWConnection)) .thenReturn(now); when(SQLUtility.getRebuildStatus(eq(mockRWConnection), any(Long.class))) .thenReturn(false); test.checkRebuildHasRun(false); }
@Test public void testSubsequentRunGoodRebuild() throws Exception { long now = System.currentTimeMillis(); when(SQLUtility.getMostRecentRebuild(mockRWConnection)) .thenReturn(now); when(SQLUtility.getRebuildStatus(mockRWConnection, now)) .thenReturn(true); test.checkRebuildHasRun(false); verifyStatic(); SQLUtility.getRebuildStatus(mockRWConnection, now); }