@Test
  public void testAccountAndContainerSerDe() throws IOException {
    assumeTrue(Container.getCurrentJsonVersion() == JSON_VERSION_2);
    Account origin = refAccount;
    String serializedAccountStr = objectMapper.writeValueAsString(origin);
    Account deserializedAccount = objectMapper.readValue(serializedAccountStr, Account.class);
    assertEquals("Two accounts should be equal", origin, deserializedAccount);

    // Serialize the account without container
    @JsonIgnoreProperties({"containers"})
    abstract class AccountMixIn {
    }
    ObjectMapper newObjectMapper = new ObjectMapper();
    newObjectMapper.addMixIn(Account.class, AccountMixIn.class);
    serializedAccountStr = newObjectMapper.writeValueAsString(origin);
    deserializedAccount = objectMapper.readValue(serializedAccountStr, Account.class);
    assertTrue(deserializedAccount.equalsWithoutContainers(origin));

    Account originWithoutContainers = new AccountBuilder(origin).containers(Collections.EMPTY_LIST).build();
    assertEquals("Two accounts should be equal", originWithoutContainers, deserializedAccount);

    for (Container container : refContainers) {
      String serializedContainerStr = objectMapper.writeValueAsString(container);
      Container deserializedContainer =
          new ContainerBuilder(objectMapper.readValue(serializedContainerStr, Container.class)).setParentAccountId(
              container.getParentAccountId()).build();
      assertEquals("Two containers should be equal", container, deserializedContainer);
    }
  }
Tests {@link Account#equals(Object)} that checks equality of {@link Container}s.
ambry-api/src/test/java/com/github/ambry/account/AccountContainerTest.java