Search in sources :

Example 26 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class RestUtilsTest method testV1toV2toV1Conversion.

private void testV1toV2toV1Conversion(List<HierarchicalTypeDefinition<ClassType>> typesToTest, boolean[] compositeExpected) throws AtlasBaseException {
    List<AtlasEntityDef> convertedEntityDefs = convertV1toV2(typesToTest);
    AtlasTypeRegistry registry = createRegistry(convertedEntityDefs);
    for (int i = 0; i < convertedEntityDefs.size(); i++) {
        AtlasEntityDef def = convertedEntityDefs.get(i);
        for (AtlasAttributeDef attrDef : def.getAttributeDefs()) {
            AtlasAttributeDef converted = convertToJsonAndBack(registry, def, attrDef, compositeExpected[i]);
            Assert.assertEquals(converted, attrDef);
        }
    }
    List<HierarchicalTypeDefinition<ClassType>> convertedBackTypeDefs = convertV2toV1(convertedEntityDefs);
    for (int i = 0; i < typesToTest.size(); i++) {
        HierarchicalTypeDefinition<ClassType> convertedBack = convertedBackTypeDefs.get(i);
        Assert.assertEquals(convertedBack, typesToTest.get(i));
        AttributeDefinition[] attributeDefinitions = convertedBack.attributeDefinitions;
        if (attributeDefinitions.length > 0) {
            Assert.assertEquals(attributeDefinitions[0].isComposite, compositeExpected[i]);
        }
    }
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasAttributeDef(org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType)

Example 27 with AttributeDefinition

use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.

the class RestUtilsTest method testBidirectonalCompositeMappingConsistent.

@Test(enabled = false)
public // in tables attribute in "database" type is lost.  See ATLAS-1528.
void testBidirectonalCompositeMappingConsistent() throws AtlasBaseException {
    HierarchicalTypeDefinition<ClassType> dbV1Type = TypesUtil.createClassTypeDef("database", ImmutableSet.<String>of(), new AttributeDefinition("tables", DataTypes.arrayTypeName("table"), Multiplicity.OPTIONAL, true, "containingDatabase"));
    HierarchicalTypeDefinition<ClassType> tableV1Type = TypesUtil.createClassTypeDef("table", ImmutableSet.<String>of(), new AttributeDefinition("containingDatabase", "database", Multiplicity.OPTIONAL, false, "tables"));
    testV1toV2toV1Conversion(Arrays.asList(dbV1Type, tableV1Type), new boolean[] { true, false });
}
Also used : AttributeDefinition(org.apache.atlas.typesystem.types.AttributeDefinition) ClassType(org.apache.atlas.typesystem.types.ClassType) Test(org.testng.annotations.Test)

Aggregations

AttributeDefinition (org.apache.atlas.typesystem.types.AttributeDefinition)27 ClassType (org.apache.atlas.typesystem.types.ClassType)17 Test (org.testng.annotations.Test)13 TraitType (org.apache.atlas.typesystem.types.TraitType)10 ArrayList (java.util.ArrayList)7 TypesDef (org.apache.atlas.typesystem.TypesDef)7 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)5 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)4 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)4 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)3 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)3 Referenceable (org.apache.atlas.typesystem.Referenceable)3 StructTypeDefinition (org.apache.atlas.typesystem.types.StructTypeDefinition)3 TypeSystem (org.apache.atlas.typesystem.types.TypeSystem)3 BeforeTest (org.testng.annotations.BeforeTest)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2 QueryParams (org.apache.atlas.query.QueryParams)2 JSONObject (org.codehaus.jettison.json.JSONObject)2 Callable (java.util.concurrent.Callable)1