@Test
  public void testLRUCacheForNotFoundContainers() throws Exception {

    // Add new account on account service
    short accountId = 101;
    String accountName = "a1";
    Container container = new ContainerBuilder((short) 1, "c1", ContainerStatus.ACTIVE, DESCRIPTION, accountId).build();
    Account account = new AccountBuilder(accountId, accountName, Account.AccountStatus.ACTIVE).containers(
        Collections.singletonList(container)).build();
    mySqlAccountService.updateAccounts(Collections.singletonList(account));

    // Look up container "c2" in account service
    assertNull("Container must not be present in account service",
        mySqlAccountService.getContainerByName(accountName, "c2"));
    // verify call to query container from mysql db
    verify(mySqlAccountStore).getContainerByName(eq((int) accountId), eq("c2"));
    // verify container name "a1:c2" is added to LRU cache
    assertTrue("container a1:c2 must be present in LRU cache",
        mySqlAccountService.getRecentNotFoundContainersCache().contains("a1" + CachedAccountService.SEPARATOR + "c2"));

    // Look up container "c2" again in account service
    assertNull("Container must not be present in account service",
        mySqlAccountService.getContainerByName(accountName, "c2"));
    // verify mysql is not queried this time
    verify(mySqlAccountStore, times(1)).getContainerByName(anyInt(), anyString());

    // Add container "c2" to account service
    mySqlAccountService.updateContainers(accountName, Collections.singletonList(
        new ContainerBuilder((short) -1, "c2", ContainerStatus.ACTIVE, DESCRIPTION, accountId).build()));

    // verify container "c2" is removed from not-found LRU cache
    assertFalse("Added container a1:c2 must no longer be present in LRU cache",
        mySqlAccountService.getRecentNotFoundContainersCache().contains("a1" + CachedAccountService.SEPARATOR + "c2"));
  }
Test LRU cache for containers not found recently.
ambry-account/src/integration-test/java/com/github/ambry/account/MySqlAccountServiceIntegrationTest.java