Search in sources :

Example 21 with AtlasAttribute

use of org.apache.atlas.type.AtlasStructType.AtlasAttribute in project incubator-atlas by apache.

the class RestUtilsTest method makeTypeStore.

private AtlasTypeDefGraphStoreV1 makeTypeStore(AtlasTypeRegistry reg) {
    AtlasTypeDefGraphStoreV1 result = mock(AtlasTypeDefGraphStoreV1.class);
    for (AtlasEntityType type : reg.getAllEntityTypes()) {
        String typeName = type.getTypeName();
        AtlasVertex typeVertex = mock(AtlasVertex.class);
        when(result.isTypeVertex(eq(typeVertex), any(TypeCategory.class))).thenReturn(true);
        when(typeVertex.getProperty(eq(Constants.TYPE_CATEGORY_PROPERTY_KEY), eq(TypeCategory.class))).thenReturn(TypeCategory.CLASS);
        String attributeListPropertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(typeName);
        when(typeVertex.getProperty(eq(attributeListPropertyKey), eq(List.class))).thenReturn(new ArrayList<>(type.getAllAttributes().keySet()));
        for (AtlasAttribute attribute : type.getAllAttributes().values()) {
            String attributeDefPropertyKey = AtlasGraphUtilsV1.getTypeDefPropertyKey(typeName, attribute.getName());
            String attributeJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute);
            when(typeVertex.getProperty(eq(attributeDefPropertyKey), eq(String.class))).thenReturn(attributeJson);
        }
        when(result.findTypeVertexByName(eq(typeName))).thenReturn(typeVertex);
    }
    return result;
}
Also used : AtlasAttribute(org.apache.atlas.type.AtlasStructType.AtlasAttribute) AtlasTypeDefGraphStoreV1(org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) TypeCategory(org.apache.atlas.typesystem.types.DataTypes.TypeCategory) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Aggregations

AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)21 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)6 AtlasType (org.apache.atlas.type.AtlasType)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ArrayList (java.util.ArrayList)3 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)3 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)3 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)3 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)3 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)3 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)3 List (java.util.List)2 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)2 AtlasTypeDefGraphStoreV1 (org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1)2 AtlasStructType (org.apache.atlas.type.AtlasStructType)2 ImmutableList (com.google.common.collect.ImmutableList)1 ScriptEngine (javax.script.ScriptEngine)1 ScriptException (javax.script.ScriptException)1 AtlasException (org.apache.atlas.AtlasException)1