@Test
  public void testAccountAndContainerSerDeWithoutIdAndName() throws IOException {
    assumeTrue(Container.getCurrentJsonVersion() == JSON_VERSION_2);
    // remove account id
    String serializedAccountStr = objectMapper.writeValueAsString(refAccount);
    ObjectNode newRefAccountJsonNode = (ObjectNode) objectMapper.readTree(serializedAccountStr);
    newRefAccountJsonNode.remove(ACCOUNT_ID_KEY);

    try {
      objectMapper.readValue(objectMapper.writeValueAsString(newRefAccountJsonNode), Account.class);
      fail("Missing account id should fail");
    } catch (ValueInstantiationException e) {
      assertTrue(e.getCause() instanceof IllegalStateException);
    }

    serializedAccountStr = objectMapper.writeValueAsString(refAccount);
    newRefAccountJsonNode = (ObjectNode) objectMapper.readTree(serializedAccountStr);
    newRefAccountJsonNode.remove(ACCOUNT_NAME_KEY);
    try {
      objectMapper.readValue(objectMapper.writeValueAsString(newRefAccountJsonNode), Account.class);
      fail("Missing account name should fail");
    } catch (ValueInstantiationException e) {
      assertTrue(e.getCause() instanceof IllegalStateException);
    }

    serializedAccountStr = objectMapper.writeValueAsString(refAccount);
    newRefAccountJsonNode = (ObjectNode) objectMapper.readTree(serializedAccountStr);
    ObjectNode containerJsonNode = (ObjectNode) newRefAccountJsonNode.get(CONTAINERS_KEY).get(0);
    containerJsonNode.remove(CONTAINER_ID_KEY);

    try {
      objectMapper.readValue(objectMapper.writeValueAsString(newRefAccountJsonNode), Account.class);
      fail("Missing container id should fail");
    } catch (ValueInstantiationException e) {
      assertTrue(e.getCause() instanceof IllegalStateException);
    }

    serializedAccountStr = objectMapper.writeValueAsString(refAccount);
    newRefAccountJsonNode = (ObjectNode) objectMapper.readTree(serializedAccountStr);
    containerJsonNode = (ObjectNode) newRefAccountJsonNode.get(CONTAINERS_KEY).get(0);
    containerJsonNode.remove(CONTAINER_NAME_KEY);

    try {
      objectMapper.readValue(objectMapper.writeValueAsString(newRefAccountJsonNode), Account.class);
      fail("Missing container name should fail");
    } catch (ValueInstantiationException e) {
      assertTrue(e.getCause() instanceof IllegalStateException);
    }
  }
Test container serialization and deserialization without the new fields
@throws IOException
ambry-api/src/test/java/com/github/ambry/account/AccountContainerTest.java