MetaV2Proxy implements IMetaProxy { @Override public void cleanupOldMetaFiles() { logger.info("Deleting any old META_V2 files if any"); IOFileFilter fileNameFilter = FileFilterUtils.and( FileFilterUtils.prefixFileFilter(MetaFileInfo.META_FILE_PREFIX), FileFilterUtils.or( FileFilterUtils.suffixFileFilter(MetaFileInfo.META_FILE_SUFFIX), FileFilterUtils.suffixFileFilter( MetaFileInfo.META_FILE_SUFFIX + ".tmp"))); Collection<File> files = FileUtils.listFiles(metaFileDirectory.toFile(), fileNameFilter, null); files.stream() .filter(File::isFile) .forEach( file -> { logger.debug( "Deleting old META_V2 file found: {}", file.getAbsolutePath()); file.delete(); }); } @Inject  MetaV2Proxy(
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            Provider<AbstractBackupPath> abstractBackupPathProvider); @Override Path getLocalMetaFileDirectory(); @Override String getMetaPrefix(DateUtil.DateRange dateRange); @Override Iterator<AbstractBackupPath> getIncrementals(DateUtil.DateRange dateRange); @Override List<AbstractBackupPath> findMetaFiles(DateUtil.DateRange dateRange); @Override Path downloadMetaFile(AbstractBackupPath meta); @Override void cleanupOldMetaFiles(); @Override List<String> getSSTFilesFromMeta(Path localMetaPath); @Override BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath);  }
@Test public void testCleanupOldMetaFiles() throws IOException { generateDummyMetaFiles(); Path dataDir = Paths.get(configuration.getDataFileLocation()); Assert.assertEquals(4, dataDir.toFile().listFiles().length); metaProxy.cleanupOldMetaFiles(); Assert.assertEquals(1, dataDir.toFile().listFiles().length); Path dummy = Paths.get(dataDir.toString(), "dummy.tmp"); Assert.assertTrue(dummy.toFile().exists()); }