@Test
  public void testContainerBuilder() {
    for (int i = 0; i < CONTAINER_COUNT; i++) {
      // build a container with arguments supplied
      Container containerFromBuilder = buildContainerWithOtherFields(
          new ContainerBuilder(refContainerIds.get(i), refContainerNames.get(i), refContainerStatuses.get(i),
              refContainerDescriptions.get(i), refAccountId), refContainers.get(i));
      assertContainer(containerFromBuilder, i);

      // build a container from existing container
      Container anotherContainerFromBuilder = new ContainerBuilder(containerFromBuilder).build();
      assertContainer(anotherContainerFromBuilder, i);
      assertEquals("Two container should be equal", containerFromBuilder, anotherContainerFromBuilder);

      boolean previouslyEncrypted = containerFromBuilder.wasPreviouslyEncrypted();
      // turn off encryption, check that previouslyEncrypted is the same as the previous value.
      containerFromBuilder = new ContainerBuilder(containerFromBuilder).setEncrypted(false).build();
      assertEncryptionSettings(containerFromBuilder, false, previouslyEncrypted);
      // turn off encryption, by turning it on and off again.
      containerFromBuilder = new ContainerBuilder(containerFromBuilder).setEncrypted(true).setEncrypted(false).build();
      assertEncryptionSettings(containerFromBuilder, false, previouslyEncrypted);
      // turn it back on, previouslyEncrypted should be set.
      containerFromBuilder = new ContainerBuilder(containerFromBuilder).setEncrypted(true).build();
      assertEncryptionSettings(containerFromBuilder, true, true);
      // turn off again, previouslyEncrypted should still be set.
      containerFromBuilder = new ContainerBuilder(containerFromBuilder).setEncrypted(false).build();
      assertEncryptionSettings(containerFromBuilder, false, true);
    }
  }
Tests building a {@link Container} using {@link ContainerBuilder}.
ambry-api/src/test/java/com/github/ambry/account/AccountContainerTest.java