diff options
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/components/path')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java | 29 | ||||
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java | 2 | ||||
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java | 2 | ||||
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java | 216 | ||||
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java | 211 | ||||
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/JanusGraphTestSetup.java (renamed from catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java) | 32 | ||||
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java | 44 |
7 files changed, 271 insertions, 265 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java index 0af5915c21..095463b9ca 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java @@ -6,14 +6,14 @@ import org.junit.Before; import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic; -import org.openecomp.sdc.be.components.path.beans.TitanGraphTestSetup; +import org.openecomp.sdc.be.components.path.beans.JanusGraphTestSetup; import org.openecomp.sdc.be.components.path.utils.GraphTestUtils; import org.openecomp.sdc.be.dao.api.ActionStatus; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.jsongraph.TitanDao; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; -import org.openecomp.sdc.be.dao.titan.TitanGraphClient; -import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; @@ -25,7 +25,7 @@ import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.category.CategoryDefinition; -import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; import org.openecomp.sdc.be.tosca.CapabilityRequirementConverter; @@ -48,7 +48,7 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme private ForwardingPathDataDefinition forwardingPathDataDefinition; @Autowired - protected TitanGraphClient titanGraphClient; + protected JanusGraphClient janusGraphClient; @Autowired protected CapabilityRequirementConverter capabiltyRequirementConvertor; @@ -66,11 +66,11 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme protected ComponentInstanceBusinessLogic componentInstanceBusinessLogic; @javax.annotation.Resource - protected TitanDao titanDao; + protected JanusGraphDao janusGraphDao; @Before - public void initTitan() { - TitanGraphTestSetup.createGraph(titanGraphClient.getGraph().left().value()); + public void initJanusGraph() { + JanusGraphTestSetup.createGraph(janusGraphClient.getGraph().left().value()); categoryDefinition = new CategoryDefinition(); categoryDefinition.setName(CATEGORY_NAME); } @@ -105,12 +105,13 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); props.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, "org.openecomp.resource.abstract.nodes.service"); - GraphTestUtils.createServiceVertex(titanDao, props); + GraphTestUtils.createServiceVertex(janusGraphDao, props); - GraphVertex resourceVertex = GraphTestUtils.createResourceVertex(titanDao, props, ResourceTypeEnum.PNF); + GraphVertex resourceVertex = GraphTestUtils.createResourceVertex(janusGraphDao, props, ResourceTypeEnum.PNF); resourceVertex.setJsonMetadataField(JsonPresentationFields.VERSION, "0.1"); - Either<GraphVertex, TitanOperationStatus> vertexTitanOperationStatusEither = titanDao.updateVertex(resourceVertex); - assertTrue(vertexTitanOperationStatusEither.isLeft()); + Either<GraphVertex, JanusGraphOperationStatus> vertexJanusGraphOperationStatusEither = janusGraphDao + .updateVertex(resourceVertex); + assertTrue(vertexJanusGraphOperationStatusEither.isLeft()); } private Service createTestService() { @@ -153,7 +154,7 @@ public abstract class BaseForwardingPathTest extends BeConfDependentTest impleme cat.setMetadataProperties(metadataProperties); cat.updateMetadataJsonWithCurrentMetadataProperties(); - Either<GraphVertex, TitanOperationStatus> catRes = titanDao.createVertex(cat); + Either<GraphVertex, JanusGraphOperationStatus> catRes = janusGraphDao.createVertex(cat); assertTrue(catRes.isLeft()); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java index fd9e25f475..eca9986209 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/ForwardingPathValidatorTest.java @@ -14,7 +14,7 @@ import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.Service; -import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.exception.ResponseFormat; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java index 09e1a72b44..3656caf904 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java @@ -4,7 +4,7 @@ import fj.data.Either; import org.openecomp.sdc.be.impl.ForwardingPathUtils; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.Resource; -import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; @org.springframework.stereotype.Component("tosca-operation-facade") diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java new file mode 100644 index 0000000000..10bd1ab6ca --- /dev/null +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryJanusGraphClient.java @@ -0,0 +1,216 @@ +package org.openecomp.sdc.be.components.path.beans; + + +import org.janusgraph.core.*; +import org.janusgraph.core.schema.ConsistencyModifier; +import org.janusgraph.core.schema.JanusGraphIndex; +import org.janusgraph.core.schema.JanusGraphManagement; +import org.janusgraph.core.util.JanusGraphCleanup; +import org.janusgraph.diskstorage.BackendException; +import org.janusgraph.diskstorage.ResourceUnavailableException; +import org.janusgraph.diskstorage.locking.PermanentLockingException; +import org.janusgraph.graphdb.database.idassigner.IDPoolExhaustedException; +import fj.data.Either; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.openecomp.sdc.be.dao.JanusGraphClientStrategy; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; +import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.util.ArrayList; +import java.util.HashMap; + +@Component("janusgraph-client") +public class InMemoryJanusGraphClient extends JanusGraphClient { + + + private static final Logger logger = LoggerFactory.getLogger(InMemoryJanusGraphClient.class); + + private static final String OK = "GOOD"; + + public InMemoryJanusGraphClient() { + } + + + private JanusGraph graph; + JanusGraphClientStrategy janusGraphClientStrategy; + + public InMemoryJanusGraphClient(JanusGraphClientStrategy janusGraphClientStrategy) { + super(); + this.janusGraphClientStrategy = janusGraphClientStrategy; + logger.info("** JanusGraphClient created"); + } + + @PostConstruct + public JanusGraphOperationStatus createGraph() { + + logger.info("** createGraph started **"); + graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open(); + createJanusGraphSchema(); + + logger.info("** in memory graph created"); + return JanusGraphOperationStatus.OK; + + } + + + public void cleanupGraph() { + if (graph != null) { + // graph.shutdown(); + graph.close(); + try { + JanusGraphFactory.drop(graph); + } catch (BackendException e) { + e.printStackTrace(); + } + } + } + + public JanusGraphOperationStatus createGraph(String janusGraphCfgFile) { + logger.info("** open graph with {} started", janusGraphCfgFile); + try { + logger.info("openGraph : try to load file {}", janusGraphCfgFile); + graph = JanusGraphFactory.open(janusGraphCfgFile); + if (graph.isClosed()) { + logger.error("janusgraph graph was not initialized"); + return JanusGraphOperationStatus.NOT_CREATED; + } + + } catch (Exception e) { + this.graph = null; + logger.info("createGraph : failed to open JanusGraph graph with configuration file: {}", janusGraphCfgFile, e); + return JanusGraphOperationStatus.NOT_CONNECTED; + } + + logger.info("** JanusGraph graph created "); + + return JanusGraphOperationStatus.OK; + } + + + public Either<JanusGraph, JanusGraphOperationStatus> getGraph() { + if (graph != null) { + return Either.left(graph); + } else { + return Either.right(JanusGraphOperationStatus.NOT_CREATED); + } + } + + public JanusGraphOperationStatus commit() { + if (graph != null) { + try { + graph.tx().commit(); + return JanusGraphOperationStatus.OK; + } catch (Exception e) { + return handleJanusGraphException(e); + } + } else { + return JanusGraphOperationStatus.NOT_CREATED; + } + } + + public JanusGraphOperationStatus rollback() { + if (graph != null) { + try { + // graph.rollback(); + graph.tx().rollback(); + return JanusGraphOperationStatus.OK; + } catch (Exception e) { + return handleJanusGraphException(e); + } + } else { + return JanusGraphOperationStatus.NOT_CREATED; + } + } + + public static JanusGraphOperationStatus handleJanusGraphException(Exception e) { + if (e instanceof JanusGraphConfigurationException) { + return JanusGraphOperationStatus.JANUSGRAPH_CONFIGURATION; + } + if (e instanceof SchemaViolationException) { + return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION; + } + if (e instanceof PermanentLockingException) { + return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION; + } + if (e instanceof IDPoolExhaustedException) { + return JanusGraphOperationStatus.GENERAL_ERROR; + } + if (e instanceof InvalidElementException) { + return JanusGraphOperationStatus.INVALID_ELEMENT; + } + if (e instanceof InvalidIDException) { + return JanusGraphOperationStatus.INVALID_ID; + } + if (e instanceof QueryException) { + return JanusGraphOperationStatus.INVALID_QUERY; + } + if (e instanceof ResourceUnavailableException) { + return JanusGraphOperationStatus.RESOURCE_UNAVAILABLE; + } + if (e instanceof IllegalArgumentException) { + // TODO check the error message?? + return JanusGraphOperationStatus.ILLEGAL_ARGUMENT; + } + + return JanusGraphOperationStatus.GENERAL_ERROR; + } + + public boolean getHealth() { + return true; + } + + private boolean isGraphOpen() { + return true; + } + + + private static final String JANUSGRAPH_HEALTH_CHECK_STR = "janusGraphHealthCheck"; + + + private void createJanusGraphSchema() { + + JanusGraphManagement graphMgt = graph.openManagement(); + JanusGraphIndex index = null; + for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) { + PropertyKey propKey = null; + if (!graphMgt.containsPropertyKey(prop.getProperty())) { + Class<?> clazz = prop.getClazz(); + if (!ArrayList.class.getName().equals(clazz.getName()) && !HashMap.class.getName().equals(clazz.getName())) { + propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make(); + } + } else { + propKey = graphMgt.getPropertyKey(prop.getProperty()); + } + if (prop.isIndexed()) { + if (!graphMgt.containsGraphIndex(prop.getProperty())) { + if (prop.isUnique()) { + index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex(); + + graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK); // Ensures + // only + // one + // name + // per + // vertex + graphMgt.setConsistency(index, ConsistencyModifier.LOCK); // Ensures + // name + // uniqueness + // in + // the + // graph + + } else { + graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex(); + } + } + } + } + graphMgt.commit(); + } + +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java deleted file mode 100644 index 96899b49c2..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/InMemoryTitanGraphClient.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.openecomp.sdc.be.components.path.beans; - - -import com.thinkaurelius.titan.core.*; -import com.thinkaurelius.titan.core.schema.ConsistencyModifier; -import com.thinkaurelius.titan.core.schema.TitanGraphIndex; -import com.thinkaurelius.titan.core.schema.TitanManagement; -import com.thinkaurelius.titan.core.util.TitanCleanup; -import com.thinkaurelius.titan.diskstorage.ResourceUnavailableException; -import com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException; -import com.thinkaurelius.titan.graphdb.database.idassigner.IDPoolExhaustedException; -import fj.data.Either; -import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.openecomp.sdc.be.dao.TitanClientStrategy; -import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; -import org.openecomp.sdc.be.dao.titan.TitanGraphClient; -import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.util.ArrayList; -import java.util.HashMap; - -@Component("titan-client") -public class InMemoryTitanGraphClient extends TitanGraphClient { - - - private static final Logger logger = LoggerFactory.getLogger(InMemoryTitanGraphClient.class); - - private static final String OK = "GOOD"; - - public InMemoryTitanGraphClient() { - } - - - private TitanGraph graph; - TitanClientStrategy titanClientStrategy; - - public InMemoryTitanGraphClient(TitanClientStrategy titanClientStrategy) { - super(); - this.titanClientStrategy = titanClientStrategy; - logger.info("** TitanGraphClient created"); - } - - @PostConstruct - public TitanOperationStatus createGraph() { - - logger.info("** createGraph started **"); - graph = TitanFactory.build().set("storage.backend", "inmemory").open(); - createTitanSchema(); - - logger.info("** in memory graph created"); - return TitanOperationStatus.OK; - - } - - - public void cleanupGraph() { - if (graph != null) { - // graph.shutdown(); - graph.close(); - TitanCleanup.clear(graph); - } - } - - public TitanOperationStatus createGraph(String titanCfgFile) { - logger.info("** open graph with {} started", titanCfgFile); - try { - logger.info("openGraph : try to load file {}", titanCfgFile); - graph = TitanFactory.open(titanCfgFile); - if (graph.isClosed()) { - logger.error("titan graph was not initialized"); - return TitanOperationStatus.NOT_CREATED; - } - - } catch (Exception e) { - this.graph = null; - logger.info("createGraph : failed to open Titan graph with configuration file: {}", titanCfgFile, e); - return TitanOperationStatus.NOT_CONNECTED; - } - - logger.info("** Titan graph created "); - - return TitanOperationStatus.OK; - } - - - public Either<TitanGraph, TitanOperationStatus> getGraph() { - if (graph != null) { - return Either.left(graph); - } else { - return Either.right(TitanOperationStatus.NOT_CREATED); - } - } - - public TitanOperationStatus commit() { - if (graph != null) { - try { - graph.tx().commit(); - return TitanOperationStatus.OK; - } catch (Exception e) { - return handleTitanException(e); - } - } else { - return TitanOperationStatus.NOT_CREATED; - } - } - - public TitanOperationStatus rollback() { - if (graph != null) { - try { - // graph.rollback(); - graph.tx().rollback(); - return TitanOperationStatus.OK; - } catch (Exception e) { - return handleTitanException(e); - } - } else { - return TitanOperationStatus.NOT_CREATED; - } - } - - public static TitanOperationStatus handleTitanException(Exception e) { - if (e instanceof TitanConfigurationException) { - return TitanOperationStatus.TITAN_CONFIGURATION; - } - if (e instanceof SchemaViolationException) { - return TitanOperationStatus.TITAN_SCHEMA_VIOLATION; - } - if (e instanceof PermanentLockingException) { - return TitanOperationStatus.TITAN_SCHEMA_VIOLATION; - } - if (e instanceof IDPoolExhaustedException) { - return TitanOperationStatus.GENERAL_ERROR; - } - if (e instanceof InvalidElementException) { - return TitanOperationStatus.INVALID_ELEMENT; - } - if (e instanceof InvalidIDException) { - return TitanOperationStatus.INVALID_ID; - } - if (e instanceof QueryException) { - return TitanOperationStatus.INVALID_QUERY; - } - if (e instanceof ResourceUnavailableException) { - return TitanOperationStatus.RESOURCE_UNAVAILABLE; - } - if (e instanceof IllegalArgumentException) { - // TODO check the error message?? - return TitanOperationStatus.ILLEGAL_ARGUMENT; - } - - return TitanOperationStatus.GENERAL_ERROR; - } - - public boolean getHealth() { - return true; - } - - private boolean isGraphOpen() { - return true; - } - - - private static final String TITAN_HEALTH_CHECK_STR = "titanHealthCheck"; - - - private void createTitanSchema() { - - TitanManagement graphMgt = graph.openManagement(); - TitanGraphIndex index = null; - for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) { - PropertyKey propKey = null; - if (!graphMgt.containsPropertyKey(prop.getProperty())) { - Class<?> clazz = prop.getClazz(); - if (!ArrayList.class.getName().equals(clazz.getName()) && !HashMap.class.getName().equals(clazz.getName())) { - propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make(); - } - } else { - propKey = graphMgt.getPropertyKey(prop.getProperty()); - } - if (prop.isIndexed()) { - if (!graphMgt.containsGraphIndex(prop.getProperty())) { - if (prop.isUnique()) { - index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex(); - - graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK); // Ensures - // only - // one - // name - // per - // vertex - graphMgt.setConsistency(index, ConsistencyModifier.LOCK); // Ensures - // name - // uniqueness - // in - // the - // graph - - } else { - graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex(); - } - } - } - } - graphMgt.commit(); - } - -} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/JanusGraphTestSetup.java index 7a7eff879a..0a11c45a6c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/TitanGraphTestSetup.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/JanusGraphTestSetup.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.be.components.path.beans; -import com.thinkaurelius.titan.core.PropertyKey; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanGraphQuery; -import com.thinkaurelius.titan.core.schema.ConsistencyModifier; -import com.thinkaurelius.titan.core.schema.TitanGraphIndex; -import com.thinkaurelius.titan.core.schema.TitanManagement; +import org.janusgraph.core.PropertyKey; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphQuery; +import org.janusgraph.core.schema.ConsistencyModifier; +import org.janusgraph.core.schema.JanusGraphIndex; +import org.janusgraph.core.schema.JanusGraphManagement; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum; @@ -25,24 +25,24 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -public class TitanGraphTestSetup { +public class JanusGraphTestSetup { - private static final Logger logger = LoggerFactory.getLogger(TitanGraphTestSetup.class); + private static final Logger logger = LoggerFactory.getLogger(JanusGraphTestSetup.class); - private static TitanGraph graph; + private static JanusGraph graph; - public static boolean createGraph( TitanGraph graph) { - TitanGraphTestSetup.graph = graph; + public static boolean createGraph( JanusGraph graph) { + JanusGraphTestSetup.graph = graph; createIndexesAndDefaults(); - logger.info("** Titan graph created "); + logger.info("** JanusGraph graph created "); return true; } private static boolean isVertexExist(Map<String, Object> properties) { - TitanGraphQuery query = graph.query(); + JanusGraphQuery query = graph.query(); if (properties != null && !properties.isEmpty()) { for (Map.Entry<String, Object> entry : properties.entrySet()) { @@ -96,8 +96,8 @@ public class TitanGraphTestSetup { private static void createVertexIndixes() { logger.info("** createVertexIndixes started"); - TitanManagement graphMgt = graph.openManagement(); - TitanGraphIndex index = null; + JanusGraphManagement graphMgt = graph.openManagement(); + JanusGraphIndex index = null; for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) { PropertyKey propKey = null; if (!graphMgt.containsPropertyKey(prop.getProperty())) { @@ -139,7 +139,7 @@ public class TitanGraphTestSetup { private static void createEdgeIndixes() { logger.info("** createEdgeIndixes started"); - TitanManagement graphMgt = graph.openManagement(); + JanusGraphManagement graphMgt = graph.openManagement(); for (GraphEdgePropertiesDictionary prop : GraphEdgePropertiesDictionary.values()) { if (!graphMgt.containsGraphIndex(prop.getProperty())) { PropertyKey propKey = graphMgt.makePropertyKey(prop.getProperty()).dataType(prop.getClazz()).make(); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java index 78f4964b7e..0ae1d8c80c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/utils/GraphTestUtils.java @@ -20,15 +20,15 @@ package org.openecomp.sdc.be.components.path.utils; -import com.thinkaurelius.titan.core.TitanGraph; -import com.thinkaurelius.titan.core.TitanVertex; +import org.janusgraph.core.JanusGraph; +import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; import org.apache.tinkerpop.gremlin.structure.io.IoCore; +import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; -import org.openecomp.sdc.be.dao.jsongraph.TitanDao; +import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils; -import org.openecomp.sdc.be.dao.titan.TitanOperationStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; @@ -44,21 +44,21 @@ import java.util.UUID; public final class GraphTestUtils { - public static GraphVertex createRootCatalogVertex(TitanDao titanDao) { + public static GraphVertex createRootCatalogVertex(JanusGraphDao janusGraphDao) { GraphVertex catalogRootVertex = new GraphVertex(VertexTypeEnum.CATALOG_ROOT); catalogRootVertex.setUniqueId(IdBuilderUtils.generateUniqueId()); - return titanDao.createVertex(catalogRootVertex) + return janusGraphDao.createVertex(catalogRootVertex) .either(v -> v, s -> null); } - public static GraphVertex createRootArchiveVertex(TitanDao titanDao) { + public static GraphVertex createRootArchiveVertex(JanusGraphDao janusGraphDao) { GraphVertex archiveRootVertex = new GraphVertex(VertexTypeEnum.ARCHIVE_ROOT); archiveRootVertex.setUniqueId(IdBuilderUtils.generateUniqueId()); - return titanDao.createVertex(archiveRootVertex) + return janusGraphDao.createVertex(archiveRootVertex) .either(v -> v, s -> null); } - public static GraphVertex createResourceVertex(TitanDao titanDao, Map<GraphPropertyEnum,Object> metadataProps, ResourceTypeEnum type) { + public static GraphVertex createResourceVertex(JanusGraphDao janusGraphDao, Map<GraphPropertyEnum,Object> metadataProps, ResourceTypeEnum type) { GraphVertex vertex = new GraphVertex(); if (type == ResourceTypeEnum.VF) { vertex.setLabel(VertexTypeEnum.TOPOLOGY_TEMPLATE); @@ -77,12 +77,12 @@ public final class GraphTestUtils { for (Map.Entry<GraphPropertyEnum, Object> prop : metadataProps.entrySet()) { vertex.addMetadataProperty(prop.getKey(), prop.getValue()); } - titanDao.createVertex(vertex); - titanDao.commit(); + janusGraphDao.createVertex(vertex); + janusGraphDao.commit(); return vertex; } - public static GraphVertex createServiceVertex(TitanDao titanDao, Map<GraphPropertyEnum, Object> metadataProps){ + public static GraphVertex createServiceVertex(JanusGraphDao janusGraphDao, Map<GraphPropertyEnum, Object> metadataProps){ GraphVertex vertex = new GraphVertex(VertexTypeEnum.TOPOLOGY_TEMPLATE); String uuid = UUID.randomUUID().toString(); @@ -95,27 +95,27 @@ public final class GraphTestUtils { for (Map.Entry<GraphPropertyEnum, Object> prop : metadataProps.entrySet()) { vertex.addMetadataProperty(prop.getKey(), prop.getValue()); } - titanDao.createVertex(vertex); - titanDao.commit(); + janusGraphDao.createVertex(vertex); + janusGraphDao.commit(); return vertex; } - public static void clearGraph(TitanDao titanDao) { - Either<TitanGraph, TitanOperationStatus> graphResult = titanDao.getGraph(); - TitanGraph graph = graphResult.left().value(); + public static void clearGraph(JanusGraphDao janusGraphDao) { + Either<JanusGraph, JanusGraphOperationStatus> graphResult = janusGraphDao.getGraph(); + JanusGraph graph = graphResult.left().value(); - Iterable<TitanVertex> vertices = graph.query().vertices(); + Iterable<JanusGraphVertex> vertices = graph.query().vertices(); if (vertices != null) { - Iterator<TitanVertex> iterator = vertices.iterator(); + Iterator<JanusGraphVertex> iterator = vertices.iterator(); while (iterator.hasNext()) { - TitanVertex vertex = iterator.next(); + JanusGraphVertex vertex = iterator.next(); vertex.remove(); } } - titanDao.commit(); + janusGraphDao.commit(); } - public static String exportGraphMl(TitanGraph graph, String outputDirectory) { + public static String exportGraphMl(JanusGraph graph, String outputDirectory) { String result = null; String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".graphml"; try { |