BackupFilesManager { public List<File> getTemporaryBackupV2Files(String temporaryDir) { try { Path dir = Paths.get(temporaryDir); return Files.list(dir) .filter(file -> file.getFileName().toString().startsWith(OLD_V2_BACKUP_PREFIX)) .filter(file -> file.getFileName().toString().endsWith(OLD_V2_BACKUP_SUFFIX)) .map(Path::toFile) .collect(toList()); } catch (IOException e) { logger.error("Error while scanning temporary backup v2 files from path.", backupFile.getAbsolutePath(), e); return Collections.emptyList(); } } BackupFilesManager(String baseDir, Clock clock); File getCurrentBackupFile(); Optional<File> rolloverBackupFileIfExists(); List<File> getTemporaryBackupV2Files(String temporaryDir); void delete(File file); List<File> getRolledBackupFiles();  }
@Test public void shouldLoadAllTemporaryBackupV2Files() throws IOException { BackupFilesManager backupFilesManager = new BackupFilesManager(tempDir.getAbsolutePath(), clock); File temporaryBackup1 = new File(tempDir, "hermes-buffer-v2-old.tmp"); File temporaryBackup2 = new File(tempDir, "hermes-buffer-002-v2-old.tmp"); File customBackup = new File(tempDir, "hermes-buffer.dat"); temporaryBackup1.createNewFile(); temporaryBackup2.createNewFile(); customBackup.createNewFile(); List<File> files = backupFilesManager.getTemporaryBackupV2Files(tempDir.getAbsolutePath()); assertThat(files.size()).isEqualTo(2); }