@Test(dependsOnMethods = "testStore")
  public void testRestore() throws Exception {
    TypesDef types = typeStore.restore();

    // validate enum
    List<EnumTypeDefinition> enumTypes = types.enumTypesAsJavaList();
    Assert.assertEquals(1, enumTypes.size());
    EnumTypeDefinition orgLevel = enumTypes.get(0);
    Assert.assertEquals(orgLevel.name, "OrgLevel");
    Assert.assertEquals(orgLevel.description, "OrgLevel" + DESCRIPTION);
    Assert.assertEquals(orgLevel.enumValues.length, 2);
    EnumValue enumValue = orgLevel.enumValues[0];
    Assert.assertEquals(enumValue.value, "L1");
    Assert.assertEquals(enumValue.ordinal, 1);

    // validate class
    List<StructTypeDefinition> structTypes = types.structTypesAsJavaList();
    Assert.assertEquals(1, structTypes.size());

    verifyRestoredClassType(types, "Manager");

    // validate trait
    List<HierarchicalTypeDefinition<TraitType>> traitTypes = types.traitTypesAsJavaList();
    Assert.assertEquals(1, traitTypes.size());
    HierarchicalTypeDefinition<TraitType> trait = traitTypes.get(0);
    Assert.assertEquals("SecurityClearance", trait.typeName);
    Assert.assertEquals(trait.typeName + DESCRIPTION, trait.typeDescription);
    Assert.assertEquals(1, trait.attributeDefinitions.length);
    AttributeDefinition attribute = trait.attributeDefinitions[0];
    Assert.assertEquals("level", attribute.name);
    Assert.assertEquals(DataTypes.INT_TYPE.getName(), attribute.dataTypeName);

    // validate the new types
    ts.reset();
    ts.defineTypes(types);
  }
  @Test(dependsOnMethods = "testStore")
  public void testTypeUpdate() throws Exception {
    // Add enum value
    String _description = "_description_updated";
    EnumTypeDefinition orgLevelEnum =
        new EnumTypeDefinition(
            "OrgLevel",
            "OrgLevel" + _description,
            new EnumValue("L1", 1),
            new EnumValue("L2", 2),
            new EnumValue("L3", 3));

    // Add attribute
    StructTypeDefinition addressDetails =
        createStructTypeDef(
            "Address",
            createRequiredAttrDef("street", DataTypes.STRING_TYPE),
            createRequiredAttrDef("city", DataTypes.STRING_TYPE),
            createOptionalAttrDef("state", DataTypes.STRING_TYPE));

    HierarchicalTypeDefinition<ClassType> deptTypeDef =
        createClassTypeDef(
            "Department",
            "Department" + _description,
            ImmutableSet.<String>of(),
            createRequiredAttrDef("name", DataTypes.STRING_TYPE),
            new AttributeDefinition(
                "employees",
                String.format("array<%s>", "Person"),
                Multiplicity.OPTIONAL,
                true,
                "department"));
    TypesDef typesDef =
        TypesUtil.getTypesDef(
            ImmutableList.of(orgLevelEnum),
            ImmutableList.of(addressDetails),
            ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
            ImmutableList.of(deptTypeDef));

    Map<String, IDataType> typesAdded = ts.updateTypes(typesDef);
    typeStore.store(ts, ImmutableList.copyOf(typesAdded.keySet()));

    verifyEdges();

    // Validate the updated types
    TypesDef types = typeStore.restore();
    ts.reset();
    ts.defineTypes(types);

    // Assert new enum value
    EnumType orgLevel = ts.getDataType(EnumType.class, orgLevelEnum.name);
    Assert.assertEquals(orgLevel.name, orgLevelEnum.name);
    Assert.assertEquals(orgLevel.description, orgLevelEnum.description);
    Assert.assertEquals(orgLevel.values().size(), orgLevelEnum.enumValues.length);
    Assert.assertEquals(orgLevel.fromValue("L3").ordinal, 3);

    // Assert new attribute
    StructType addressType = ts.getDataType(StructType.class, addressDetails.typeName);
    Assert.assertEquals(addressType.numFields, 3);
    Assert.assertEquals(
        addressType.fieldMapping.fields.get("state").dataType(), DataTypes.STRING_TYPE);

    // Updating the definition again shouldn't add another edge
    typesDef =
        TypesUtil.getTypesDef(
            ImmutableList.<EnumTypeDefinition>of(),
            ImmutableList.<StructTypeDefinition>of(),
            ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(),
            ImmutableList.of(deptTypeDef));
    typesAdded = ts.updateTypes(typesDef);
    typeStore.store(ts, ImmutableList.copyOf(typesAdded.keySet()));
    verifyEdges();
  }