@Test
  public void testUpdateAndFetch() throws Exception {
    RouterStore store =
        new RouterStore(accountServiceMetrics, backup, helixStore, new AtomicReference<>(router), forBackfill,
            TOTAL_NUMBER_OF_VERSION_TO_KEEP, config);
    Map<Short, Account> idToRefAccountMap = new HashMap<>();
    Map<Short, Map<Short, Container>> idtoRefContainerMap = new HashMap<>();
    Set<Short> accountIDSet = new HashSet<>();
    // generate an new account and test update and fetch on this account
    AccountTestUtils.generateRefAccounts(idToRefAccountMap, idtoRefContainerMap, accountIDSet, 1, 1);
    assertUpdateAndFetch(store, idToRefAccountMap, idToRefAccountMap, 1, 1);
    Map<Short, Account> accountMapFirstVersion = new HashMap<>(idToRefAccountMap);

    // generate another new account and test update and fetch on this account
    Map<Short, Account> anotherIdToRefAccountMap = new HashMap<>();
    AccountTestUtils.generateRefAccounts(anotherIdToRefAccountMap, idtoRefContainerMap, accountIDSet, 1, 1);
    if (!forBackfill) {
      for (Map.Entry<Short, Account> entry : anotherIdToRefAccountMap.entrySet()) {
        idToRefAccountMap.put(entry.getKey(), entry.getValue());
      }
    } else {
      idToRefAccountMap = anotherIdToRefAccountMap;
    }
    // the version should be 2 now
    assertUpdateAndFetch(store, idToRefAccountMap, anotherIdToRefAccountMap, 2, 2);

    // Make sure we can get all the versions out
    List<Integer> versions = store.getAllVersions();
    assertNotNull(versions);
    Collections.sort(versions);
    assertEquals(versions.size(), 2);
    assertEquals((int) versions.get(0), 1);
    assertEquals((int) versions.get(1), 2);

    // Make sure we can still get the first version out
    Map<String, String> accountMap = store.fetchAccountMetadataAtVersion(1);
    assertAccountsEqual(accountMap, accountMapFirstVersion);
  }
Test basic operations of the {@link RouterStore}, update and fetch {@link Account} metadata.
@throws Exception Any unexpected Exception
ambry-account/src/test/java/com/github/ambry/account/RouterStoreTest.java