@Test
  public void testAccountBuilder() {
    // build an account with arguments supplied
    AccountBuilder accountBuilder =
        new AccountBuilder(refAccountId, refAccountName, refAccountStatus, refQuotaResourceType).snapshotVersion(
            refAccountSnapshotVersion).aclInheritedByContainer(refAccountAclInheritedByContainer);
    Account accountByBuilder = accountBuilder.build();
    assertAccountAgainstReference(accountByBuilder, false);

    // set containers
    for (int i = 0; i < CONTAINER_COUNT; i++) {
      Container container = new ContainerBuilder(refContainers.get(i)).setParentAccountId(refAccountId).build();
      accountBuilder.addOrUpdateContainer(container);
    }
    accountByBuilder = accountBuilder.build();
    assertAccountAgainstReference(accountByBuilder, true);

    // build an account from existing account
    accountBuilder = new AccountBuilder(accountByBuilder);
    Account account2ByBuilder = accountBuilder.build();
    assertAccountAgainstReference(account2ByBuilder, true);

    // clear containers
    Account account3ByBuilder = new AccountBuilder(account2ByBuilder).containers(null).build();
    assertAccountAgainstReference(account3ByBuilder, false);
    assertTrue("Container list should be empty.", account3ByBuilder.getAllContainers().isEmpty());
  }
Tests building an {@link Account} using {@link AccountBuilder}.
ambry-api/src/test/java/com/github/ambry/account/AccountContainerTest.java