### Question:
LoaderUtils { public static void reloadFailureRecovery(@Nonnull File indexDir) throws IOException { File parentDir = indexDir.getParentFile(); File segmentBackupDir = new File(parentDir, indexDir.getName() + CommonConstants.Segment.SEGMENT_BACKUP_DIR_SUFFIX); if (segmentBackupDir.exists()) { LOGGER .info("Trying to recover index directory: {} from segment backup directory: {}", indexDir, segmentBackupDir); if (indexDir.exists()) { LOGGER.info("Deleting index directory: {}", indexDir); FileUtils.forceDelete(indexDir); } Preconditions.checkState(segmentBackupDir.renameTo(indexDir), "Failed to rename segment backup directory: %s to index directory: %s", segmentBackupDir, indexDir); } File segmentTempDir = new File(parentDir, indexDir.getName() + CommonConstants.Segment.SEGMENT_TEMP_DIR_SUFFIX); if (segmentTempDir.exists()) { LOGGER.info("Trying to delete segment temporary directory: {}", segmentTempDir); FileUtils.forceDelete(segmentTempDir); } } private  LoaderUtils(); static void writeIndexToV3Format(SegmentDirectory.Writer segmentWriter, String column, File indexFile,
      ColumnIndexType indexType); static List<String> getStringListFromSegmentProperties(String key, PropertiesConfiguration segmentProperties); static void reloadFailureRecovery(@Nonnull File indexDir);  }### Answer:
@Test public void testReloadFailureRecovery() throws IOException { String segmentName = "dummySegment"; String indexFileName = "dummyIndex"; File indexDir = new File(TEST_DIR, segmentName); File segmentBackupDir = new File(TEST_DIR, segmentName + CommonConstants.Segment.SEGMENT_BACKUP_DIR_SUFFIX); File segmentTempDir = new File(TEST_DIR, segmentName + CommonConstants.Segment.SEGMENT_TEMP_DIR_SUFFIX); Assert.assertTrue(indexDir.mkdir()); FileUtils.touch(new File(indexDir, indexFileName)); LoaderUtils.reloadFailureRecovery(indexDir); Assert.assertTrue(indexDir.exists()); Assert.assertTrue(new File(indexDir, indexFileName).exists()); Assert.assertFalse(segmentBackupDir.exists()); Assert.assertFalse(segmentTempDir.exists()); FileUtils.deleteDirectory(indexDir); Assert.assertTrue(segmentBackupDir.mkdir()); FileUtils.touch(new File(segmentBackupDir, indexFileName)); LoaderUtils.reloadFailureRecovery(indexDir); Assert.assertTrue(indexDir.exists()); Assert.assertTrue(new File(indexDir, indexFileName).exists()); Assert.assertFalse(segmentBackupDir.exists()); Assert.assertFalse(segmentTempDir.exists()); FileUtils.deleteDirectory(indexDir); Assert.assertTrue(indexDir.mkdir()); Assert.assertTrue(segmentBackupDir.mkdir()); FileUtils.touch(new File(segmentBackupDir, indexFileName)); LoaderUtils.reloadFailureRecovery(indexDir); Assert.assertTrue(indexDir.exists()); Assert.assertTrue(new File(indexDir, indexFileName).exists()); Assert.assertFalse(segmentBackupDir.exists()); Assert.assertFalse(segmentTempDir.exists()); FileUtils.deleteDirectory(indexDir); Assert.assertTrue(indexDir.mkdir()); FileUtils.touch(new File(indexDir, indexFileName)); Assert.assertTrue(segmentTempDir.mkdir()); LoaderUtils.reloadFailureRecovery(indexDir); Assert.assertTrue(indexDir.exists()); Assert.assertTrue(new File(indexDir, indexFileName).exists()); Assert.assertFalse(segmentBackupDir.exists()); Assert.assertFalse(segmentTempDir.exists()); FileUtils.deleteDirectory(indexDir); }