@Test public void testCleanup_NotEnoughBackupFilesWithVersion() throws IOException { final int startVersion = 1; final int endVersion = startVersion + maxBackupFile / 2; final long baseModifiedTime = System.currentTimeMillis() / 1000 - 100; final long interval = 2; final int backupFileNoVersionCount = maxBackupFile; createBackupFilesWithoutVersion(accountBackupDir, backupFileNoVersionCount, baseModifiedTime, interval, false); createBackupFilesWithoutVersion(accountBackupDir, backupFileNoVersionCount, baseModifiedTime, interval, true); createBackupFilesWithVersion(accountBackupDir, startVersion, endVersion, baseModifiedTime + 2 * backupFileNoVersionCount * interval, interval, true); String[] filenames = createBackupFilesWithVersion(accountBackupDir, startVersion, endVersion, baseModifiedTime + 2 * backupFileNoVersionCount * interval, interval, false); saveAccountsToFile(Collections.singleton(refAccount), accountBackupDir.resolve(filenames[filenames.length - 1])); BackupFileManager backup = new BackupFileManager(accountServiceMetrics, config.backupDir, config.maxBackupFileCount); assertEquals("Number of backup files mismatch", backup.size(), maxBackupFile); File[] remainingFiles = accountBackupDir.toFile().listFiles(); assertEquals("Number of backup files in storage mismatch", remainingFiles.length, maxBackupFile); int versionFileCount = 0; int nonVersionFileCount = 0; for (File file : remainingFiles) { if (BackupFileManager.versionFilenamePattern.matcher(file.getName()).find()) { versionFileCount++; } else { nonVersionFileCount++; } } assertEquals("Number of backup files with version mismatch", versionFileCount, endVersion - startVersion + 1); assertEquals("Number of backup files without version ", nonVersionFileCount, maxBackupFile - (endVersion - startVersion + 1)); }
int size() { return backupFileInfos.size(); }
BackupFileManager { int size() { return backupFileInfos.size(); } }
BackupFileManager { int size() { return backupFileInfos.size(); } BackupFileManager(AccountServiceMetrics accountServiceMetrics, String backupDir, int maxBackupFileCount); }
BackupFileManager { int size() { return backupFileInfos.size(); } BackupFileManager(AccountServiceMetrics accountServiceMetrics, String backupDir, int maxBackupFileCount); int getLatestVersion(); }
BackupFileManager { int size() { return backupFileInfos.size(); } BackupFileManager(AccountServiceMetrics accountServiceMetrics, String backupDir, int maxBackupFileCount); int getLatestVersion();  }