Search in sources :

Example 1 with AtlasTypeDefGraphStoreV1

use of org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1 in project 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) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Example 2 with AtlasTypeDefGraphStoreV1

use of org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1 in project atlas by apache.

the class RestUtilsTest method convertToJsonAndBack.

private AtlasAttributeDef convertToJsonAndBack(AtlasTypeRegistry registry, AtlasStructDef structDef, AtlasAttributeDef attributeDef, boolean compositeExpected) throws AtlasBaseException {
    AtlasTypeDefGraphStoreV1 typeDefStore = makeTypeStore(registry);
    AtlasStructType structType = (AtlasStructType) registry.getType(structDef.getName());
    AtlasAttribute attribute = structType.getAttribute(attributeDef.getName());
    String attribJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute);
    Map attrInfo = AtlasType.fromJson(attribJson, Map.class);
    Assert.assertEquals(attrInfo.get("isComposite"), compositeExpected);
    return AtlasStructDefStoreV1.toAttributeDefFromJson(structDef, attrInfo, typeDefStore);
}
Also used : AtlasAttribute(org.apache.atlas.type.AtlasStructType.AtlasAttribute) AtlasTypeDefGraphStoreV1(org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1) AtlasStructType(org.apache.atlas.type.AtlasStructType)

Example 3 with AtlasTypeDefGraphStoreV1

use of org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1 in project incubator-atlas by apache.

the class RestUtilsTest method convertToJsonAndBack.

private AtlasAttributeDef convertToJsonAndBack(AtlasTypeRegistry registry, AtlasStructDef structDef, AtlasAttributeDef attributeDef, boolean compositeExpected) throws AtlasBaseException {
    AtlasTypeDefGraphStoreV1 typeDefStore = makeTypeStore(registry);
    AtlasStructType structType = (AtlasStructType) registry.getType(structDef.getName());
    AtlasAttribute attribute = structType.getAttribute(attributeDef.getName());
    String attribJson = AtlasStructDefStoreV1.toJsonFromAttribute(attribute);
    Map attrInfo = AtlasType.fromJson(attribJson, Map.class);
    Assert.assertEquals(attrInfo.get("isComposite"), compositeExpected);
    return AtlasStructDefStoreV1.toAttributeDefFromJson(structDef, attrInfo, typeDefStore);
}
Also used : AtlasAttribute(org.apache.atlas.type.AtlasStructType.AtlasAttribute) AtlasTypeDefGraphStoreV1(org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1) AtlasStructType(org.apache.atlas.type.AtlasStructType) Map(java.util.Map)

Example 4 with AtlasTypeDefGraphStoreV1

use of org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1 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

AtlasTypeDefGraphStoreV1 (org.apache.atlas.repository.store.graph.v1.AtlasTypeDefGraphStoreV1)4 AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)4 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)2 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)2 AtlasStructType (org.apache.atlas.type.AtlasStructType)2 TypeCategory (org.apache.atlas.typesystem.types.DataTypes.TypeCategory)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1