private void updateAccountsAndAssertAccountExistence(Collection<Account> accounts, int expectedAccountCount,
      boolean shouldUpdateSucceed) throws Exception {
    try {
      accountService.updateAccounts(accounts);
    } catch (AccountServiceException ase) {
      if (shouldUpdateSucceed) {
        // Wasn't expecting this, rethrow.
        throw ase;
      }
    }
    if (shouldUpdateSucceed) {
      assertAccountsInAccountService(accounts, expectedAccountCount, accountService);
      if (helixConfigProps.containsKey(HelixAccountServiceConfig.BACKUP_DIRECTORY_KEY)) {
        Path newBackupFilePath = Files.list(accountBackupDir)
            .filter(path -> BackupFileManager.versionFilenamePattern.matcher(path.getFileName().toString()).find())
            .max(new Comparator<Path>() {
              @Override
              public int compare(Path o1, Path o2) {
                Matcher m1 = BackupFileManager.versionFilenamePattern.matcher(o1.getFileName().toString());
                Matcher m2 = BackupFileManager.versionFilenamePattern.matcher(o2.getFileName().toString());
                m1.find();
                m2.find();
                int v1 = Integer.parseInt(m1.group(1));
                int v2 = Integer.parseInt(m2.group(1));
                return v1 - v2;
              }
            })
            .get();
        checkBackupFileWithVersion(accountService.getAllAccounts(), newBackupFilePath);
      }
    } else {
      assertEquals("Wrong number of accounts in accountService", expectedAccountCount,
          accountService.getAllAccounts().size());
    }
  }
Updates a collection of {@link Account}s through {@link HelixAccountService}, and verifies that the
{@link Account}s have been successfully updated, so they can be queried through {@link HelixAccountService}.
@param accounts A collection of {@link Account}s to update through {@link HelixAccountService}.
ambry-account/src/test/java/com/github/ambry/account/HelixAccountServiceTest.java