@Test
  public void testPersistAccountMapAndRecover() throws IOException {
    BackupFileManager backup =
        new BackupFileManager(accountServiceMetrics, config.backupDir, config.maxBackupFileCount);
    final int numberAccounts = maxBackupFile * 2;
    final Collection<Account> accounts = new ArrayList<>();
    final Stat stat = new Stat();
    final long interval = 1;
    long modifiedTime = System.currentTimeMillis() / 1000 - numberAccounts * 2;
    for (int i = 0; i < numberAccounts; i++) {
      Account account = createRandomAccount();
      accounts.add(account);
      stat.setVersion(i + 1);
      stat.setMtime(modifiedTime * 1000);
      backup.persistAccountMap(accounts, stat.getVersion(), stat.getMtime() / 1000);
      modifiedTime += interval;
    }

    for (int i = 0; i < 2; i++) {
      assertEquals("Number of backup file mismatch", maxBackupFile, backup.size());
      Collection<Account> obtained = backup.getLatestAccounts(0);
      assertEquals(accounts, obtained);
      File[] remaingingFiles = accountBackupDir.toFile().listFiles();
      assertEquals("Remaining backup mismatch", maxBackupFile, remaingingFiles.length);

      // Recover BackupFileManager from the same backup dir
      backup = new BackupFileManager(accountServiceMetrics, config.backupDir, config.maxBackupFileCount);
    }
  }
Test {@link BackupFileManager#persistAccountMap(Collection, int, long)} and then recover {@link BackupFileManager} from the same backup directory.
@throws IOException if I/O error occurs
ambry-account/src/test/java/com/github/ambry/account/BackupFileManagerTest.java