GraphBackedTypeStore implements ITypeStore { @Override @GraphTransaction public TypesDef restore() throws AtlasException { Iterator vertices = graph.query().has(Constants.VERTEX_TYPE_PROPERTY_KEY, VERTEX_TYPE).vertices().iterator(); return getTypesFromVertices(vertices); } @Inject  GraphBackedTypeStore(AtlasGraph atlasGraph); @Override @GraphTransaction void store(TypeSystem typeSystem, ImmutableList<String> typeNames); @Override @GraphTransaction TypesDef restore(); @Override @GraphTransaction TypesDef restoreType(String typeName); static final String VERTEX_TYPE; static final String SUPERTYPE_EDGE_LABEL; }
@Test(dependsOnMethods = "testStore") public void testRestore() throws Exception { TypesDef types = typeStore.restore(); 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); List<StructTypeDefinition> structTypes = types.structTypesAsJavaList(); Assert.assertEquals(1, structTypes.size()); verifyRestoredClassType(types, "Manager"); 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); ts.reset(); ts.defineTypes(types); }