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]);
}
}
}
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 });
}
Aggregations