@Test public void testStore() throws AtlasException { ImmutableList<String> typeNames = ts.getTypeNames(); typeStore.store(ts, typeNames); dumpGraph(); }
@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(); }