@VisibleForTesting
  void setFactory(JniDBFactory fact) {
    this.factory = fact;
  }
@Test
  void testLevelDbRepair() throws IOException {
    RollingLevelDBTimelineStore store = new RollingLevelDBTimelineStore();
    JniDBFactory factory = Mockito.mock(JniDBFactory.class);
    Mockito.when(factory.open(Mockito.any(File.class), Mockito.any(Options.class)))
        .thenThrow(new IOException()).thenCallRealMethod();
    store.setFactory(factory);

    //Create the LevelDb in a different location
    File path = new File("target", this.getClass().getSimpleName() + "-tmpDir2").getAbsoluteFile();
    Configuration conf = new Configuration(this.config);
    conf.set(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_PATH, path.getAbsolutePath());
    try {
      store.init(conf);
      Mockito.verify(factory, Mockito.times(1))
          .repair(Mockito.any(File.class), Mockito.any(Options.class));
      FilenameFilter fileFilter = WildcardFileFilter.builder()
              .setWildcards("*" + RollingLevelDBTimelineStore.BACKUP_EXT + "*")
              .get();
      assertTrue(new File(path.getAbsolutePath(), RollingLevelDBTimelineStore.FILENAME)
          .list(fileFilter).length > 0);
    } finally {
      store.close();
      fsContext.delete(new Path(path.getAbsolutePath()), true);
    }
  }