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