Upgrade SDC from Titan to Janus Graph
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / jsonjanusgraph / operations / ExternalReferencesOperationTest.java
@@ -1,4 +1,4 @@
-package org.openecomp.sdc.be.model.jsontitan.operations;
+package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
 
 import fj.data.Either;
 import org.junit.Before;
@@ -7,15 +7,15 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
+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.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
 import org.openecomp.sdc.be.datatypes.elements.MapComponentInstanceExternalRefs;
 import org.openecomp.sdc.be.model.ModelTestBase;
-import org.openecomp.sdc.be.model.jsontitan.utils.GraphTestUtils;
-import org.openecomp.sdc.be.model.jsontitan.utils.IdMapper;
+import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils;
+import org.openecomp.sdc.be.model.jsonjanusgraph.utils.IdMapper;
 import org.openecomp.sdc.be.model.operations.StorageException;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -49,7 +49,7 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
     private ExternalReferencesOperation externalReferenceOperation;
 
     @Resource
-    private TitanDao titanDao;
+    private JanusGraphDao janusGraphDao;
 
     private boolean isInitialized;
 
@@ -74,7 +74,7 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
         this.externalReferenceOperation.setIdMapper(idMapper);
         when(idMapper.mapComponentNameToUniqueId(Mockito.anyString(), Mockito.any(GraphVertex.class))).thenReturn(COMPONENT_ID);
         if (!isInitialized) {
-            GraphTestUtils.clearGraph(titanDao);
+            GraphTestUtils.clearGraph(janusGraphDao);
             initGraphForTest();
             isInitialized = true;
         }
@@ -85,9 +85,9 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
         Either<String, ActionStatus> addResult = externalReferenceOperation.addExternalReference(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_4);
         assertThat(addResult.isLeft()).isEqualTo(true);
 
-        //commit changes to titan
-        final TitanOperationStatus commit = this.titanDao.commit();
-        assertThat(commit).isEqualTo(TitanOperationStatus.OK);
+        //commit changes to janusgraph
+        final JanusGraphOperationStatus commit = this.janusGraphDao.commit();
+        assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK);
 
         assertThat(getServiceExternalRefs()).contains(REF_1, REF_2, REF_3, REF_4);
     }
@@ -152,9 +152,9 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
         Either<String, ActionStatus> deleteStatus = externalReferenceOperation.deleteExternalReference(this.serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
         assertThat(deleteStatus.isLeft()).isEqualTo(true);
 
-        //commit changes to titan
-        final TitanOperationStatus commit = this.titanDao.commit();
-        assertThat(commit).isEqualTo(TitanOperationStatus.OK);
+        //commit changes to janusgraph
+        final JanusGraphOperationStatus commit = this.janusGraphDao.commit();
+        assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK);
 
         //Check that ref does not exist anymore
         assertThat(getServiceExternalRefs()).doesNotContain(REF_5).contains(REF_1, REF_2, REF_3);
@@ -170,9 +170,9 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
 
         assertThat(updateResult.isLeft()).isEqualTo(true);
 
-        //commit changes to titan
-        final TitanOperationStatus commit = this.titanDao.commit();
-        assertThat(commit).isEqualTo(TitanOperationStatus.OK);
+        //commit changes to janusgraph
+        final JanusGraphOperationStatus commit = this.janusGraphDao.commit();
+        assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK);
 
         //Check that ref does not exist anymore
         assertThat(getServiceExternalRefs()).doesNotContain(REF_5).contains(REF_1, REF_2, REF_3, REF_4);
@@ -180,7 +180,8 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
 
     private List<String> getServiceExternalRefs(){
         //Get service vertex
-        final Either<GraphVertex, TitanOperationStatus> externalRefsVertexResult = this.titanDao.getChildVertex(this.serviceVertex, EdgeLabelEnum.EXTERNAL_REFS, JsonParseFlagEnum.ParseJson);
+        final Either<GraphVertex, JanusGraphOperationStatus> externalRefsVertexResult = this.janusGraphDao
+            .getChildVertex(this.serviceVertex, EdgeLabelEnum.EXTERNAL_REFS, JsonParseFlagEnum.ParseJson);
         assertThat(externalRefsVertexResult.isLeft()).isEqualTo(true);
 
         GraphVertex externalRefVertex = externalRefsVertexResult.left().value();
@@ -200,7 +201,7 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
 
     private void initGraphForTest() {
         //create a service
-        this.serviceVertex = GraphTestUtils.createServiceVertex(titanDao, new HashMap<>());
+        this.serviceVertex = GraphTestUtils.createServiceVertex(janusGraphDao, new HashMap<>());
         this.serviceVertexUuid = this.serviceVertex.getUniqueId();
 
         //monitoring references
@@ -213,14 +214,14 @@ public class ExternalReferencesOperationTest extends ModelTestBase {
         externalReferenceOperation.addExternalReference(serviceVertexUuid, COMPONENT_ID, WORKFLOW_OBJECT_TYPE, REF_6);
 
         //create a service without refs
-        serviceVertex2 = GraphTestUtils.createServiceVertex(titanDao, new HashMap<>());
+        serviceVertex2 = GraphTestUtils.createServiceVertex(janusGraphDao, new HashMap<>());
         serviceVertex2Uuid = serviceVertex2.getUniqueId();
 
         //create a service for adding all references
-        serviceVertex3 = GraphTestUtils.createServiceVertex(titanDao, new HashMap<>());
+        serviceVertex3 = GraphTestUtils.createServiceVertex(janusGraphDao, new HashMap<>());
         serviceVertex3Uuid = serviceVertex3.getUniqueId();
 
-        final TitanOperationStatus commit = this.titanDao.commit();
-        assertThat(commit).isEqualTo(TitanOperationStatus.OK);
+        final JanusGraphOperationStatus commit = this.janusGraphDao.commit();
+        assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK);
     }
 }
\ No newline at end of file