@Test
  public void testConflictingSnapshotVersionUpdate() throws Exception {
    accountService = mockHelixAccountServiceFactory.getAccountService();
    // write two accounts (1, "a") and (2, "b")
    writeAccountsForConflictTest();
    Account expectedAccount = accountService.getAccountById((short) 1);
    int currentSnapshotVersion = expectedAccount.getSnapshotVersion();
    for (int snapshotVersionOffset : new int[]{-2, -1, 1}) {
      int snapshotVersionToUse = currentSnapshotVersion + snapshotVersionOffset;
      Collection<Account> conflictAccounts = Collections.singleton(
          new AccountBuilder((short) 1, "c", AccountStatus.INACTIVE).snapshotVersion(snapshotVersionToUse).build());
      assertUpdateAccountsFails(conflictAccounts, AccountServiceErrorCode.ResourceConflict, accountService);
      assertEquals("Wrong account number in HelixAccountService", 2, accountService.getAllAccounts().size());
      Account account = accountService.getAccountById((short) 1);
      assertEquals("Account should not have been updated", expectedAccount, account);
      assertEquals("Snapshot version should not have been updated", currentSnapshotVersion,
          account.getSnapshotVersion());
    }
    Collection<Account> validAccounts = Collections.singleton(
        new AccountBuilder((short) 1, "c", AccountStatus.INACTIVE).snapshotVersion(currentSnapshotVersion).build());
    updateAccountsAndAssertAccountExistence(validAccounts, 2, true);
  }
Test updating an account with a conflicting expected snapshot version.
ambry-account/src/test/java/com/github/ambry/account/HelixAccountServiceTest.java