BackupFilesManager { public List<File> getRolledBackupFiles() { return newArrayList(new File(baseDir).listFiles(new PatternFilenameFilter(TIMESTAMPED_BACKUP_FILE_PATTERN))); } 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 shouldReadBackupFilesList() throws IOException { BackupFilesManager backupFilesManager = new BackupFilesManager(tempDir.getAbsolutePath(), clock); File timestampedBackup1 = new File(tempDir, "hermes-buffer-v3-001.dat"); File timestampedBackup2 = new File(tempDir, "hermes-buffer-v3-002.dat"); File customBackup = new File(tempDir, "hermes-buffer-v3-old.dat"); timestampedBackup1.createNewFile(); timestampedBackup2.createNewFile(); customBackup.createNewFile(); List<File> backups = backupFilesManager.getRolledBackupFiles(); assertThat(backups).containsOnly(timestampedBackup1, timestampedBackup2); }
@Test public void shouldReadEmptyBackupFileList() { BackupFilesManager backupFilesManager = new BackupFilesManager(tempDir.getAbsolutePath(), clock); List<File> backups = backupFilesManager.getRolledBackupFiles(); assertThat(backups).isEmpty(); }