use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.
the class TaxonomyResourceDefinitionTest method testGetPropertyDefinitions.
@Test
public void testGetPropertyDefinitions() {
ResourceDefinition taxonomyDefinition = new TaxonomyResourceDefinition();
Collection<AttributeDefinition> propertyDefinitions = taxonomyDefinition.getPropertyDefinitions();
assertEquals(propertyDefinitions.size(), 3);
Set<String> defNames = new HashSet<>();
for (AttributeDefinition def : propertyDefinitions) {
defNames.add(def.name);
}
assertTrue(defNames.contains("name"));
assertTrue(defNames.contains("description"));
}
use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.
the class EntityTagResourceDefinitionTest method testGetPropertyDefinitions.
@Test
public void testGetPropertyDefinitions() {
ResourceDefinition entityTagDefinition = new EntityTagResourceDefinition();
Collection<AttributeDefinition> propertyDefinitions = entityTagDefinition.getPropertyDefinitions();
assertEquals(propertyDefinitions.size(), 1);
Set<String> defNames = new HashSet<>();
for (AttributeDefinition def : propertyDefinitions) {
defNames.add(def.name);
}
assertTrue(defNames.contains("name"));
}
use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.
the class TypeConverterUtil method entityToTypesDef.
private static TypesDef entityToTypesDef(AtlasEntityType entityType, AtlasTypeRegistry registry) throws AtlasBaseException {
String typeName = entityType.getEntityDef().getName();
String typeDesc = entityType.getEntityDef().getDescription();
String typeVersion = entityType.getEntityDef().getTypeVersion();
ImmutableSet superTypes = ImmutableSet.copyOf(entityType.getEntityDef().getSuperTypes());
AttributeDefinition[] attributes = getAttributes(entityType, registry);
HierarchicalTypeDefinition<ClassType> classType = TypesUtil.createClassTypeDef(typeName, typeDesc, typeVersion, superTypes, attributes);
TypesDef ret = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(classType));
return ret;
}
use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.
the class FieldMappingTest method testOutputReferenceableInstance.
@Test
public void testOutputReferenceableInstance() throws Exception {
// ATLAS-645: verify that FieldMapping.output(IReferenceableInstance)
// does not infinitely recurse when ITypedReferenceableInstance's reference each other.
HierarchicalTypeDefinition<ClassType> valueDef = TypesUtil.createClassTypeDef("Value", ImmutableSet.<String>of(), new AttributeDefinition("owner", "Owner", Multiplicity.OPTIONAL, false, null));
// Define class type with reference, where the value is a class reference to Value.
HierarchicalTypeDefinition<ClassType> ownerDef = TypesUtil.createClassTypeDef("Owner", ImmutableSet.<String>of(), new AttributeDefinition("value", "Value", Multiplicity.OPTIONAL, false, null));
TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(ownerDef, valueDef));
TypeSystem typeSystem = TypeSystem.getInstance();
typeSystem.defineTypes(typesDef);
ClassType ownerType = typeSystem.getDataType(ClassType.class, "Owner");
// Prior to fix for ATLAS-645, this call would throw a StackOverflowError
try {
ownerType.toString();
} catch (StackOverflowError e) {
Assert.fail("Infinite recursion in ClassType.toString() caused StackOverflowError");
}
ClassType valueType = typeSystem.getDataType(ClassType.class, "Value");
// Create instances of Owner and Value that reference each other.
ITypedReferenceableInstance ownerInstance = ownerType.createInstance();
ITypedReferenceableInstance valueInstance = valueType.createInstance();
// Set Owner.value reference to Value instance.
ownerInstance.set("value", valueInstance);
// Set Value.owner reference on Owner instance.
valueInstance.set("owner", ownerInstance);
// Prior to fix for ATLAS-645, this call would throw a StackOverflowError
try {
ownerInstance.fieldMapping().output(ownerInstance, new StringBuilder(), "", new HashSet<IReferenceableInstance>());
} catch (StackOverflowError e) {
Assert.fail("Infinite recursion in FieldMapping.output() caused StackOverflowError");
}
}
use of org.apache.atlas.typesystem.types.AttributeDefinition in project incubator-atlas by apache.
the class RestUtilsTest method testBidirectonalNonCompositeMappingConsistent.
@Test(enabled = false)
public // in "table" attribute in "database". See ATLAS-1528.
void testBidirectonalNonCompositeMappingConsistent() throws AtlasBaseException {
HierarchicalTypeDefinition<ClassType> dbV1Type = TypesUtil.createClassTypeDef("database", ImmutableSet.<String>of(), new AttributeDefinition("tables", DataTypes.arrayTypeName("table"), Multiplicity.OPTIONAL, false, "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[] { false, false });
}
Aggregations