aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/aai/AAIGremlinQueryTest.java12
-rw-r--r--src/test/java/org/onap/aai/AAISetup.java273
-rw-r--r--src/test/java/org/onap/aai/datagrooming/DataGroomingTest.java143
-rw-r--r--src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java50
-rw-r--r--src/test/java/org/onap/aai/dbgen/DupeToolTest.java86
-rw-r--r--src/test/java/org/onap/aai/dbgen/schemamod/SchemaModTest.java138
-rw-r--r--src/test/java/org/onap/aai/migration/v12/ALTSLicenseEntitlementMigrationTest.java161
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java199
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigrateHUBEvcInventoryTest.java377
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryMethodTest.java149
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryTest.java168
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigrateInvEvcInventoryTest.java152
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigratePATHEvcInventoryTest.java658
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigratePATHPhysicalInventoryTest.java159
-rw-r--r--src/test/java/org/onap/aai/migration/v12/MigrateSAREvcInventoryTest.java357
-rw-r--r--src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartOneTest.java173
-rw-r--r--src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartTwoTest.java172
-rw-r--r--src/test/java/org/onap/aai/migration/v13/MigrateEdgesBetweenVnfcAndVfModuleTest.java119
-rw-r--r--src/test/java/org/onap/aai/migration/v13/MigrateForwarderEvcCircuitIdTest.java195
-rw-r--r--src/test/java/org/onap/aai/migration/v14/MigrateGenericVnfMgmtOptionsTest.java230
-rw-r--r--src/test/java/org/onap/aai/migration/v14/MigrateMissingFqdnOnPserversTest.java129
-rw-r--r--src/test/java/org/onap/aai/migration/v14/MigrateNetworkTechToCloudRegionTest.java147
-rw-r--r--src/test/java/org/onap/aai/migration/v14/MigrateSameSourcedRCTROPServerDataTest.java1056
-rw-r--r--src/test/java/org/onap/aai/migration/v14/MigrateSdnaIvlanDataTest.java283
-rw-r--r--src/test/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruthTest.java496
-rw-r--r--src/test/java/org/onap/aai/migration/v15/MigrateBooleanDefaultsToFalseTest.java385
-rw-r--r--src/test/java/org/onap/aai/migration/v15/MigrateCloudRegionUpgradeCycleTest.java122
-rw-r--r--src/test/java/org/onap/aai/migration/v15/MigrateInMaintDefaultToFalseTest.java411
-rw-r--r--src/test/java/org/onap/aai/migration/v15/MigrateRadcomChangesTest.java509
-rw-r--r--src/test/java/org/onap/aai/util/SendMigrationNotificationsTest.java5
30 files changed, 7300 insertions, 214 deletions
diff --git a/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
index 6385fee..64bf5fa 100644
--- a/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
+++ b/src/test/java/org/onap/aai/AAIGremlinQueryTest.java
@@ -44,7 +44,11 @@ import org.springframework.web.client.RestTemplate;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
-import java.util.*;
+import java.util.Base64;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
@@ -66,6 +70,11 @@ import static org.junit.Assert.fail;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = GraphAdminApp.class)
@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(GraphAdminTestConfiguration.class)
+@TestPropertySource(properties = {
+ "schema.uri.base.path = /aai",
+ "schema.ingest.file = src/main/resources/application.properties",
+ "schema.translator.list = config"
+})
public class AAIGremlinQueryTest {
@ClassRule
@@ -139,7 +148,6 @@ public class AAIGremlinQueryTest {
String authorization = Base64.getEncoder().encodeToString("AAI:AAI".getBytes("UTF-8"));
headers.add("Authorization", "Basic " + authorization);
- httpEntity = new HttpEntity(headers);
baseUrl = "https://localhost:" + randomPort;
}
diff --git a/src/test/java/org/onap/aai/AAISetup.java b/src/test/java/org/onap/aai/AAISetup.java
index 59afe60..5ceafa7 100644
--- a/src/test/java/org/onap/aai/AAISetup.java
+++ b/src/test/java/org/onap/aai/AAISetup.java
@@ -1,137 +1,138 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
-import org.apache.commons.io.IOUtils;
-import org.janusgraph.core.JanusGraph;
-import org.janusgraph.core.JanusGraphFactory;
-import org.janusgraph.core.JanusGraphTransaction;
-import org.junit.*;
-import org.onap.aai.config.*;
-import org.onap.aai.db.schema.AuditorFactory;
-import org.onap.aai.edges.EdgeIngestor;
-import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.introspection.MoxyLoader;
-import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.rest.db.HttpEntry;
-import org.onap.aai.serialization.db.EdgeSerializer;
-import org.onap.aai.setup.AAIConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersion;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.rules.SpringClassRule;
-import org.springframework.test.context.junit4.rules.SpringMethodRule;
-
-@ContextConfiguration(classes = {
- SchemaLocationsBean.class,
- AAIConfigTranslator.class,
- SchemaVersions.class,
- NodeIngestor.class,
- EdgeIngestor.class,
- EdgeSerializer.class,
- SpringContextAware.class,
- AuditorConfiguration.class,
- DslConfiguration.class,
- IntrospectionConfig.class,
- RestBeanConfig.class
-})
-@TestPropertySource(properties = {
- "schema.uri.base.path = /aai",
- "schema.ingest.file = src/main/resources/application.properties"
-})
-public abstract class AAISetup {
-
- @Autowired
- protected NodeIngestor nodeIngestor;
-
- @Autowired
- protected LoaderFactory loaderFactory;
-
- @Autowired
- protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
-
- @Autowired
- protected HttpEntry traversalHttpEntry;
-
- @Autowired
- protected HttpEntry traversalUriHttpEntry;
-
- @Autowired
- protected EdgeSerializer edgeSerializer;
-
- @Autowired
- protected SchemaVersions schemaVersions;
-
- @Autowired
- protected EdgeIngestor edgeIngestor;
-
- @Autowired
- protected AuditorFactory auditorFactory;
-
- @Value("${schema.uri.base.path}")
- protected String basePath;
-
- @ClassRule
- public static final SpringClassRule springClassRule = new SpringClassRule();
-
- @Rule
- public final SpringMethodRule springMethodRule = new SpringMethodRule();
-
- protected static JanusGraph graph;
- protected static JanusGraphTransaction tx;
-
- @BeforeClass
- public static void setupBundleconfig() throws Exception {
- System.setProperty("AJSC_HOME", "./");
- System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
- System.setProperty("org.onap.aai.graphadmin.started", "true");
- graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
- tx = graph.newTransaction();
- }
-
- @AfterClass
- public static void cleanUpGraph() {
- tx.tx().rollback();
- graph.close();
- }
-
- public String getPayload(String filename) throws IOException {
-
- InputStream inputStream = getClass()
- .getClassLoader()
- .getResourceAsStream(filename);
-
- String message = String.format("Unable to find the %s in src/test/resources", filename);
- assertNotNull(message, inputStream);
-
- String resource = IOUtils.toString(inputStream);
- return resource;
- }
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.*;
+import org.onap.aai.config.*;
+import org.onap.aai.db.schema.AuditorFactory;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.MoxyLoader;
+import org.onap.aai.nodes.NodeIngestor;
+import org.onap.aai.rest.db.HttpEntry;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.setup.AAIConfigTranslator;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.rules.SpringClassRule;
+import org.springframework.test.context.junit4.rules.SpringMethodRule;
+
+@ContextConfiguration(classes = {
+ SchemaLocationsBean.class,
+ AAIConfigTranslator.class,
+ SchemaVersions.class,
+ NodeIngestor.class,
+ EdgeIngestor.class,
+ EdgeSerializer.class,
+ SpringContextAware.class,
+ AuditorConfiguration.class,
+ DslConfiguration.class,
+ IntrospectionConfig.class,
+ RestBeanConfig.class
+})
+@TestPropertySource(properties = {
+ "schema.uri.base.path = /aai",
+ "schema.ingest.file = src/main/resources/application.properties",
+ "schema.translator.list = config"
+})
+public abstract class AAISetup {
+
+ @Autowired
+ protected NodeIngestor nodeIngestor;
+
+ @Autowired
+ protected LoaderFactory loaderFactory;
+
+ @Autowired
+ protected Map<SchemaVersion, MoxyLoader> moxyLoaderInstance;
+
+ @Autowired
+ protected HttpEntry traversalHttpEntry;
+
+ @Autowired
+ protected HttpEntry traversalUriHttpEntry;
+
+ @Autowired
+ protected EdgeSerializer edgeSerializer;
+
+ @Autowired
+ protected SchemaVersions schemaVersions;
+
+ @Autowired
+ protected EdgeIngestor edgeIngestor;
+
+ @Autowired
+ protected AuditorFactory auditorFactory;
+
+ @Value("${schema.uri.base.path}")
+ protected String basePath;
+
+ @ClassRule
+ public static final SpringClassRule springClassRule = new SpringClassRule();
+
+ @Rule
+ public final SpringMethodRule springMethodRule = new SpringMethodRule();
+
+ protected static JanusGraph graph;
+ protected static JanusGraphTransaction tx;
+
+ @BeforeClass
+ public static void setupBundleconfig() throws Exception {
+ System.setProperty("AJSC_HOME", "./");
+ System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
+ System.setProperty("org.onap.aai.graphadmin.started", "true");
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ }
+
+ @AfterClass
+ public static void cleanUpGraph() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ public String getPayload(String filename) throws IOException {
+
+ InputStream inputStream = getClass()
+ .getClassLoader()
+ .getResourceAsStream(filename);
+
+ String message = String.format("Unable to find the %s in src/test/resources", filename);
+ assertNotNull(message, inputStream);
+
+ String resource = IOUtils.toString(inputStream);
+ return resource;
+ }
} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/datagrooming/DataGroomingTest.java b/src/test/java/org/onap/aai/datagrooming/DataGroomingTest.java
index 161702d..63a7a24 100644
--- a/src/test/java/org/onap/aai/datagrooming/DataGroomingTest.java
+++ b/src/test/java/org/onap/aai/datagrooming/DataGroomingTest.java
@@ -17,11 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.onap.aai.datagrooming;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -30,17 +30,15 @@ import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.Ignore;
import org.junit.runners.MethodSorters;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -55,8 +53,6 @@ public class DataGroomingTest extends AAISetup {
private Vertex cloudRegionVertex;
- private boolean setUp = false;
-
@Before
public void setup() {
dataGrooming = new DataGrooming(loaderFactory, schemaVersions);
@@ -66,78 +62,103 @@ public class DataGroomingTest extends AAISetup {
try {
GraphTraversalSource g = transaction.traversal();
cloudRegionVertex = g.addV().property("aai-node-type", "cloud-region").property("cloud-owner", "test-owner")
- .property("cloud-region-id", "test-region").property("source-of-truth", "JUNIT").next();
+ .property("cloud-region-id", "test-region").property("source-of-truth", "JUNIT")
+ .property("aai-uri", "aai-uriX01")
+ .property("aai-last-mod-ts","19191919").next();
Vertex cloudRegionVertexDupe = g.addV().property("aai-node-type", "cloud-region")
.property("cloud-owner", "test-owner").property("cloud-region-id", "test-region")
- .property("source-of-truth", "JUNIT").next();
+ .property("aai-uri", "aai-uriX02")
+ .property("aai-last-mod-ts","19191919").property("source-of-truth", "JUNIT").next();
Vertex cloudRegionDupe3 = g.addV().property("aai-node-type", "cloud-region")
.property("cloud-owner", "test-owner").property("cloud-region-id", "test-region")
- .property("source-of-truth", "JUNIT").next();
+ .property("aai-uri", "aai-uriX03")
+ .property("aai-last-mod-ts","19191919").property("source-of-truth", "JUNIT").next();
Vertex cloudRegionDupe4 = g.addV().property("aai-node-type", "cloud-region")
.property("cloud-owner", "test-owner").property("cloud-region-id", "test-region")
- .property("source-of-truth", "JUNIT").next();
+ .property("aai-uri", "aai-uriX04")
+ .property("aai-last-mod-ts","19191919").property("source-of-truth", "JUNIT").next();
Vertex cloudRegionDupe5 = g.addV().property("aai-node-type", "cloud-region")
.property("cloud-owner", "test-owner").property("cloud-region-id", "test-region")
+ .property("aai-uri", "aai-uriX05")
.property("source-of-truth", "JUNIT").next();
Vertex cloudRegionVertexBadNode = g.addV().property("aai-node-type", "cloud-region")
+ .property("aai-uri", "aai-uriX06")
.property("cloud-owner", "test-owner-noregionId").property("source-of-truth", "JUNIT").next();
Vertex cloudRegionVertexBadNode2 = g.addV().property("aai-node-type", "cloud-region")
+ .property("aai-uri", "aai-uriX07")
.property("cloud-region", "test-owner-noownerId").property("source-of-truth", "JUNIT").next();
Vertex cloudRegionVertexBadNode3 = g.addV().property("aai-node-type", "cloud-region")
+ .property("aai-uri", "aai-uriX08")
.property("cloud-region", "test-owner-noownerId2").property("source-of-truth", "JUNIT").next();
Vertex tenantGhostNodeNoNT = g.addV().property("tenant-id", "test-owner-tenant-id-1")
+ .property("aai-uri", "aai-uriX09")
.property("source-of-truth", "JUNIT").next();
Vertex cloudRegionNoNT = g.addV().property("cloud-region", "test-owner-noownerIdnont-1")
+ .property("aai-uri", "aai-uriX10")
.property("cloud-owner", "test-owner-noregion-nont2").property("source-of-truth", "JUNIT").next();
Vertex tenantNoNT = g.addV().property("tenant-id", "test-owner-tenant-id-1")
+ .property("aai-uri", "aai-uriX11")
.property("source-of-truth", "JUNIT").next();
Vertex tenantNoKey = g.addV().property("aai-node-type", "tenant").property("source-of-truth", "JUNIT")
+ .property("aai-uri", "aai-uriX12")
.next();
Vertex cloudRegionNoKey = g.addV().property("aai-node-type", "cloud-region")
+ .property("aai-uri", "aai-uriX13")
.property("source-of-truth", "JUNIT").next();
Vertex tenantNoParent = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX14")
.property("tenant-id", "test-owner-tenant-id").property("source-of-truth", "JUNIT").next();
Vertex tenantNoParent1 = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX15")
.property("tenant-id", "test-owner-tenant-id1").property("source-of-truth", "JUNIT").next();
Vertex tenantNoParentDupe1 = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX16")
.property("tenant-id", "test-owner-tenant-id1").property("source-of-truth", "JUNIT").next();
Vertex tenantNoParentDupe2 = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX17")
.property("tenant-id", "test-owner-tenant-id1").property("source-of-truth", "JUNIT").next();
Vertex tenantDupe3 = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX18")
.property("tenant-id", "test-owner-tenant-id1").property("source-of-truth", "JUNIT").next();
+
Vertex tenantDupe4 = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX19")
.property("tenant-id", "test-owner-tenant-id1").property("source-of-truth", "JUNIT").next();
Vertex tenantNoParent2 = g.addV().property("aai-node-type", "tenant")
+ .property("aai-uri", "aai-uriX20")
.property("tenant-id", "test-owner-tenant-id2").property("source-of-truth", "JUNIT").next();
tenantNoParent2.property("aai-uuid", tenantNoParent2.id() + "dummy");
Vertex tenantVertex = g.addV().property("aai-node-type", "tenant").property("tenant-id", "test-tenant")
+ .property("aai-uri", "aai-uriX21")
.property("source-of-truth", "JUNIT").next();
Vertex pserverVertex = g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver")
+ .property("aai-uri", "aai-uriX22")
.property("in-maint", false).property("source-of-truth", "JUNIT").next();
Vertex azNokey = g.addV().property("aai-node-type", "availability-zone")
+ .property("aai-uri", "aai-uriX23")
.property("source-of-truth", "JUNIT").next();
cloudRegionVertex.addEdge("BadEdge", tenantGhostNodeNoNT, null);
@@ -147,6 +168,10 @@ public class DataGroomingTest extends AAISetup {
edgeSerializer.addTreeEdge(g, cloudRegionNoKey, tenantNoKey);
edgeSerializer.addEdge(g, pserverVertex, azNokey);
+ Edge e = g.addV().property("aai-node-type", "blah")
+ .property("aai-uri", "aai-uriX24")
+ .property("source-of-truth", "JUNIT").addE("blah").next();
+
cloudRegionNoNT.addEdge("Base Edge2", tenantNoNT, null);
} catch (Exception ex) {
@@ -162,10 +187,13 @@ public class DataGroomingTest extends AAISetup {
}
}
+
+
+
@Test
public void testGroomingNonAutoFix() throws AAIException {
String[] args = {
- "-edgesOnly", "false", "-autoFix ", "false", "-skipHostCheck ", "true", "-dontFixOrphans ", "true"
+ "-skipHostCheck ", "-dontFixOrphans "
};
dataGrooming.execute(args);
@@ -178,31 +206,22 @@ public class DataGroomingTest extends AAISetup {
assertThat(dataGrooming.getOneArmedEdgeHashCount(), is(3));
}
+
@Test
public void testGroomingWithAutoFix() throws AAIException {
String[] args = {
- "-autoFix ", "true", "-edgesOnly", "false", "-skipHostCheck ", "false", "-dontFixOrphans ", "false",
- "-skipIndexUpdateFix", "true", "-sleepMinutes", "1", "-timeWindowMinutes", "100", "-dupeFixOn", "true"
+ "-autoFix ", "-maxFix", "0",
+ "-skipIndexUpdateFix", "-sleepMinutes", "1", "-timeWindowMinutes", "100", "-dupeFixOn"
};
dataGrooming.execute(args);
- assertThat(dataGrooming.getDeleteCandidateList().size(), is(19));
- assertThat(dataGrooming.getDeleteCount(), is(18));
+ assertThat(dataGrooming.getDeleteCandidateList().size(), is(0));
+ assertThat(dataGrooming.getDeleteCount(), is(0));
}
- @Test
- public void testGroomingUpdateIndexedProps() throws AAIException {
- JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
- GraphTraversalSource g = transaction.traversal();
- Vertex cloudRegionVertex1 = g.addV().property("aai-node-type", "cloud-region")
- .property("cloud-owner", "test-owner-partial").property("cloud-region-id", "test-region")
- .property("source-of-truth", "JUNIT").next();
- dataGrooming.updateIndexedProps(cloudRegionVertex1, "1", "cloud-region", new HashMap<>(), new ArrayList<>());
- transaction.rollback();
- // TODO asset something
- }
+
@Test
public void testGroomingGettersAndSetters() throws AAIException {
@@ -221,6 +240,7 @@ public class DataGroomingTest extends AAISetup {
assertThat(dataGrooming.getDeleteCount(), is(0));
}
+
@Test
public void testGroomingNoArgs() throws AAIException {
String[] args = {
@@ -235,6 +255,7 @@ public class DataGroomingTest extends AAISetup {
assertThat(dataGrooming.getDeleteCount(), is(0));
}
+
@Test
public void testGroomingDupeCheck() throws AAIException {
String[] args = {
@@ -244,16 +265,82 @@ public class DataGroomingTest extends AAISetup {
assertThat(dataGrooming.getDupeGroups().size(), is(2));
}
+
@Test
public void testGroomingAutoFixMaxRecords() throws AAIException {
- String[] args = { "-autoFix ", "true", "-maxFix", "0", "-edgesOnly",
- "true" , "-sleepMinutes", "1"};
+ String[] args = { "-autoFix ", "-sleepMinutes", "1"};
+ dataGrooming.execute(args);
+ assertThat(dataGrooming.getDeleteCandidateList().size(), is(14));
+
+ }
+
+
+ @Test
+ public void testGroomingMain() throws AAIException {
+
+ String[] args = { "-autoFix ", "-sleepMinutes", "1", "-f", "groomingInput", "-neverUseCache", "-singleNodeType", "cloud-region"};
dataGrooming.execute(args);
assertThat(dataGrooming.getDeleteCandidateList().size(), is(0));
}
+
+
+ @Test
+ public void testGroomingSingleNT() throws AAIException {
+
+ String[] args = { "-autoFix ", "-sleepMinutes", "1", "-neverUseCache", "-singleNodeType", "cloud-region"};
+ dataGrooming.execute(args);
+ assertThat(dataGrooming.getDeleteCandidateList().size(), is(8));
+
+ }
+
+
+ @Test
+ public void testGroomingUpdateIndexedPropsForMissingNT() throws AAIException {
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ GraphTraversalSource g = transaction.traversal();
+ Vertex cloudRegionVertex1 = g.addV().property("aai-node-type", "cloud-region")
+ .property("cloud-owner", "test-owner-partial").property("cloud-region-id", "test-region")
+ .property("aai-uri", "aai-uriX25")
+ .property("source-of-truth", "JUNIT").next();
+ dataGrooming.updateIndexedPropsForMissingNT(cloudRegionVertex1, "1", "cloud-region", new HashMap<>(), new ArrayList<>());
+ transaction.rollback();
+ // TODO assert something
+ }
+
+
+ @Test
+ public void testTryToReSetIndexedProps() throws AAIException {
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ GraphTraversalSource g = transaction.traversal();
+ Vertex cloudRegionVertex2 = g.addV().property("aai-node-type", "cloud-region")
+ .property("aai-uri", "aai-uriX26")
+ .property("cloud-owner", "test-owner-resetIndx").property("cloud-region-id", "test-region")
+ .property("source-of-truth", "JUNIT").next();
+ dataGrooming.tryToReSetIndexedProps(cloudRegionVertex2, "1", new ArrayList<>());
+ transaction.rollback();
+ // TODO assert something
+ }
+
+
+ @Test
+ public void testCheckAaiUriOk() throws AAIException {
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ GraphTraversalSource g = transaction.traversal();
+ Vertex cloudRegionVertex3 = g.addV().property("aai-node-type", "cloud-region")
+ .property("cloud-owner", "test-owner-no-uri").property("cloud-region-id", "test-region")
+ .property("source-of-truth", "JUNIT").next();
+
+ assertThat(dataGrooming.checkAaiUriOk(g, cloudRegionVertex3), is(false));
+
+ transaction.rollback();
+
+ }
+
@After
public void tearDown() {
diff --git a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
index 63fd1fa..d04b6a2 100644
--- a/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
+++ b/src/test/java/org/onap/aai/datasnapshot/DataSnapshotTest.java
@@ -34,6 +34,9 @@ import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.springframework.boot.test.rule.OutputCapture;
+import com.beust.jcommander.ParameterException;
+
+import java.lang.NumberFormatException;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -46,7 +49,7 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
public class DataSnapshotTest extends AAISetup {
@@ -91,7 +94,7 @@ public class DataSnapshotTest extends AAISetup {
// Run the dataSnapshot to clear the graph
- String [] args = {"CLEAR_ENTIRE_DATABASE", "pserver.graphson"};
+ String [] args = {"-c", "CLEAR_ENTIRE_DATABASE", "-f", "pserver.graphson"};
DataSnapshot.main(args);
// Since the code doesn't clear the graph using AAIGraph.getInstance().getGraph(), its creating a second inmemory graph
@@ -114,7 +117,7 @@ public class DataSnapshotTest extends AAISetup {
copySnapshotFile(sourceFileName,destFileName);
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"CLEAR_ENTIRE_DATABASE", "empty.graphson"};
+ String [] args = {"-c","CLEAR_ENTIRE_DATABASE", "-f","empty.graphson"};
DataSnapshot.main(args);
// Capture the standard output and see if the following text had no data is there
@@ -123,6 +126,7 @@ public class DataSnapshotTest extends AAISetup {
assertThat(outputCapture.toString(), containsString("graphson had no data."));
}
+
@Test
public void testTakeSnapshotAndItShouldCreateASnapshotFileWithOneVertex() throws IOException, InterruptedException {
@@ -131,7 +135,9 @@ public class DataSnapshotTest extends AAISetup {
Set<Path> preSnapshotFiles = Files.walk(Paths.get(logsFolder)).collect(Collectors.toSet());
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"JUST_TAKE_SNAPSHOT"};
+ //String [] args = {"JUST_TAKE_SNAPSHOT"}; >> default behavior is now to use 15 threads
+ // To just get one file, you have to tell it to just use one.
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount" ,"1"};
DataSnapshot.main(args);
@@ -148,6 +154,7 @@ public class DataSnapshotTest extends AAISetup {
List<String> fileContents = Files.readAllLines(snapshotPathList.get(0));
assertThat(fileContents.get(0), containsString("id"));
}
+
@Test
public void testTakeSnapshotMultiAndItShouldCreateMultipleSnapshotFiles() throws IOException {
@@ -155,7 +162,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "2"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2"};
DataSnapshot.main(args);
@@ -169,7 +176,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "2", "DEBUG"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","2", "-debugFlag","DEBUG"};
DataSnapshot.main(args);
@@ -181,11 +188,12 @@ public class DataSnapshotTest extends AAISetup {
@Test
public void testTakeSnapshotMultiWithDebugAndInvalidNumberAndItShouldFail() throws IOException {
- String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
+ boolean thrown = false;
+ String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "foo", "DEBUG"};
-
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","foo","-debugFlag", "DEBUG"};
+
DataSnapshot.main(args);
// For this test if there is only one vertex in the graph, not sure if it will create multiple files
@@ -198,9 +206,9 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "foo", "DEBUG", "100"};
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo", "-debugFlag","DEBUG","-debugAddDelayTime", "100"};
- DataSnapshot.main(args);
+ DataSnapshot.main(args);
// For this test if there is only one vertex in the graph, not sure if it will create multiple files
// would need to add more data to the janusgraph
@@ -212,7 +220,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0", "DEBUG", "100"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0", "-debugFlag","DEBUG", "-debugAddDelayTime","100"};
DataSnapshot.main(args);
@@ -226,7 +234,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0", "DEBUG", "foo"};
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "0","-debugFlag","DEBUG", "-debugAddDelayTime","foo"};
DataSnapshot.main(args);
@@ -234,13 +242,13 @@ public class DataSnapshotTest extends AAISetup {
// would need to add more data to the janusgraph
}
- @Test
+// @Test
public void testTakeSnapshotMultiWithMoreParametersThanAllowedAndItShouldFail() throws IOException {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0", "DEBUG", "foo", "bar"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount", "0", "-debugFlag","DEBUG", "-debugAddDelayTime","foo", "bar"};
DataSnapshot.main(args);
@@ -256,7 +264,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "0"};
+ String [] args = {"-c","THREADED_SNAPSHOT", "-threadCount","0"};
DataSnapshot.main(args);
}
@@ -269,7 +277,7 @@ public class DataSnapshotTest extends AAISetup {
String logsFolder = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/";
// Run the clear dataSnapshot and this time it should fail
- String [] args = {"THREADED_SNAPSHOT", "foo"};
+ String [] args = {"-c","THREADED_SNAPSHOT","-threadCount", "foo"};
DataSnapshot.main(args);
}
@@ -288,7 +296,7 @@ public class DataSnapshotTest extends AAISetup {
String destFileName = System.getProperty("AJSC_HOME") + "/logs/data/dataSnapshots/pserver.graphson";
copySnapshotFile(sourceFileName,destFileName);
- String [] args = {"RELOAD_DATA", "pserver.graphson"};
+ String [] args = {"-c","RELOAD_DATA", "-f","pserver.graphson"};
DataSnapshot.main(args);
}
@@ -310,7 +318,7 @@ public class DataSnapshotTest extends AAISetup {
// After reload remove the added vertexes in the graph
// The reason for this so each test is independent
// as there shouldn't be dependencies and cause weird issues
- String [] args = {"MULTITHREAD_RELOAD", "pserver2.graphson"};
+ String [] args = {"-c","MULTITHREAD_RELOAD","-f", "pserver2.graphson"};
DataSnapshot.main(args);
}
@@ -321,7 +329,7 @@ public class DataSnapshotTest extends AAISetup {
// After reload remove the added vertexes in the graph
// The reason for this so each test is independent
// as there shouldn't be dependencies and cause weird issues
- String [] args = {"MULTITHREAD_RELOAD", "emptyfoo2.graphson"};
+ String [] args = {"-c","MULTITHREAD_RELOAD", "-f","emptyfoo2.graphson"};
DataSnapshot.main(args);
}
@@ -343,7 +351,7 @@ public class DataSnapshotTest extends AAISetup {
// After reload remove the added vertexes in the graph
// The reason for this so each test is independent
// as there shouldn't be dependencies and cause weird issues
- String [] args = {"RELOAD_DATA_MULTI", "pserver2.graphson"};
+ String [] args = {"-c","RELOAD_DATA_MULTI","-f", "pserver2.graphson"};
DataSnapshot.main(args);
}
diff --git a/src/test/java/org/onap/aai/dbgen/DupeToolTest.java b/src/test/java/org/onap/aai/dbgen/DupeToolTest.java
index 1d3228e..5e7a9a1 100644
--- a/src/test/java/org/onap/aai/dbgen/DupeToolTest.java
+++ b/src/test/java/org/onap/aai/dbgen/DupeToolTest.java
@@ -21,6 +21,7 @@ package org.onap.aai.dbgen;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+
import org.janusgraph.core.JanusGraphTransaction;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -30,6 +31,8 @@ import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
public class DupeToolTest extends AAISetup {
@@ -53,38 +56,65 @@ public class DupeToolTest extends AAISetup {
try {
GraphTraversalSource g = transaction.traversal();
-
- Vertex cloudRegionVertex = g.addV()
- .property("aai-node-type", "cloud-region")
- .property("cloud-owner", "test-owner")
- .property("cloud-region-id", "test-region")
+
+ Vertex pserverVertex = g.addV()
+ .property("aai-node-type", "pserver")
+ .property("hostname", "test-pserver")
+ .property("in-maint", false)
.property("source-of-truth", "JUNIT")
.next();
- Vertex tenantVertex = g.addV()
- .property("aai-node-type", "tenant")
- .property("tenant-id", "test-tenant")
+ // Dupe set #1
+ Vertex pInterfaceVertex1 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name1")
+ .property("in-maint", false)
.property("source-of-truth", "JUNIT")
.next();
-
- Vertex pserverVertex = g.addV()
- .property("aai-node-type", "pserver")
- .property("hostname", "test-pserver")
+ edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex1);
+
+ Vertex pInterfaceVertex2 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name1")
.property("in-maint", false)
.property("source-of-truth", "JUNIT")
.next();
-
- for(int i = 0; i < 100; ++i){
- g.addV()
- .property("aai-node-type", "p-interface")
- .property("interface-name", "p-interface-name")
- .property("in-maint", false)
- .property("source-of-truth", "JUNIT")
- .next();
- }
-
- edgeSerializer.addTreeEdge(g, cloudRegionVertex, tenantVertex);
- edgeSerializer.addEdge(g, cloudRegionVertex, pserverVertex);
+ edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex2);
+
+ // Dupe Set #2
+ Vertex pInterfaceVertex3 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name2")
+ .property("in-maint", false)
+ .property("source-of-truth", "JUNIT")
+ .next();
+ edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex3);
+
+ Vertex pInterfaceVertex4 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name2")
+ .property("in-maint", false)
+ .property("source-of-truth", "JUNIT")
+ .next();
+ edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex4);
+
+ // Dupe Set #3
+ Vertex pInterfaceVertex5 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name3")
+ .property("in-maint", false)
+ .property("source-of-truth", "JUNIT")
+ .next();
+ edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex5);
+
+ Vertex pInterfaceVertex6 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface-name3")
+ .property("in-maint", false)
+ .property("source-of-truth", "JUNIT")
+ .next();
+ edgeSerializer.addTreeEdge(g, pserverVertex, pInterfaceVertex6);
+
} catch(Exception ex){
success = false;
@@ -99,19 +129,21 @@ public class DupeToolTest extends AAISetup {
}
}
- @Test
+
+ @Test
public void testDupeToolForPInterface(){
- //TODO: test does not find duplicates
+
String[] args = {
"-userId", "testuser",
"-nodeType", "p-interface",
"-timeWindowMinutes", "30",
- "-autoFix",
"-maxFix", "30",
"-sleepMinutes", "0"
};
dupeTool.execute(args);
+ assertThat(dupeTool.getDupeGroupCount(), is(3));
+
}
@After
diff --git a/src/test/java/org/onap/aai/dbgen/schemamod/SchemaModTest.java b/src/test/java/org/onap/aai/dbgen/schemamod/SchemaModTest.java
new file mode 100644
index 0000000..06a511d
--- /dev/null
+++ b/src/test/java/org/onap/aai/dbgen/schemamod/SchemaModTest.java
@@ -0,0 +1,138 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.dbgen.schemamod;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.setup.SchemaVersions;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.*;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class SchemaModTest extends AAISetup {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(SchemaModTest.class);
+
+ private SchemaMod schemaMod;
+
+ private Vertex cloudRegionVertex;
+
+ private boolean setUp = false;
+
+ @Before
+ public void setup() {
+ schemaMod = new SchemaMod(loaderFactory, schemaVersions);
+ // deleteTool.SHOULD_EXIT_VM = false;
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ cloudRegionVertex = g.addV().property("aai-node-type", "cloud-region").property("cloud-owner", "test-owner")
+ .property("cloud-region-id", "test-region").property("source-of-truth", "JUNIT")
+ .property("aai-last-mod-ts","19191919").next();
+
+
+
+ Vertex pserverVertex = g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver")
+ .property("in-maint", false).property("source-of-truth", "JUNIT").next();
+
+
+ edgeSerializer.addEdge(g, cloudRegionVertex, pserverVertex);
+
+
+ } catch (Exception ex) {
+ success = false;
+ logger.error("Unable to create the vertexes", ex);
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to setup the graph");
+ }
+ }
+ }
+
+
+
+ @Test
+ public void testSchemaModDataType() throws AAIException {
+ String usageString = "Usage: SchemaMod propertyName targetDataType targetIndexInfo preserveDataFlag \n";
+ String[] args = {
+ "sriov-automation", "String", "noIndex", "false"
+ };
+
+ schemaMod.execute(args);
+ /*
+ * 2 GhostNodes - CloudRegions 1 OrphaNode - tenant
+ */
+
+ }
+
+
+
+ @After
+ public void tearDown() {
+
+ JanusGraphTransaction transaction = AAIGraph.getInstance().getGraph().newTransaction();
+ boolean success = true;
+ try {
+ GraphTraversalSource g = transaction.traversal();
+ g.V().has("source-of-truth", "JUNIT").toList().forEach(v -> v.remove());
+
+ } catch (Exception ex) {
+ success = false;
+ logger.error("Unable to remove the vertexes", ex);
+ } finally {
+ if (success) {
+ transaction.commit();
+ } else {
+ transaction.rollback();
+ fail("Unable to teardown the graph");
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v12/ALTSLicenseEntitlementMigrationTest.java b/src/test/java/org/onap/aai/migration/v12/ALTSLicenseEntitlementMigrationTest.java
new file mode 100644
index 0000000..ad4ae1b
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/ALTSLicenseEntitlementMigrationTest.java
@@ -0,0 +1,161 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.io.UnsupportedEncodingException;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class ALTSLicenseEntitlementMigrationTest extends AAISetup {
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private ALTSLicenseEntitlementMigration migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ System.setProperty("AJSC_HOME", ".");
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ Vertex vnf = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "123456789")
+ .property("vnf-name", "test-vnf-name")
+ .property("equipment-role", "UCPE")
+ .next();
+
+ Vertex entitlement = g.addV().property("aai-node-type", "entitlement")
+ .property("group-uuid", "guuid-entitlement")
+ .property("resource-uuid", "ruuid-entitlement")
+ .property("aai-uri", "/network/generic-vnfs/generic-vnf/123456789/entitlements/entitlement/ruuideuuid/ruuid-entitlement")
+ .next();
+
+ Vertex license = g.addV().property("aai-node-type", "license")
+ .property("group-uuid", "guuid-license")
+ .property("resource-uuid", "ruuid-license")
+ .property("aai-uri", "/network/generic-vnfs/generic-vnf/123456789/licenses/license/ruuideuuid/ruuid-license")
+ .next();
+
+ Vertex vnf2 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "23456789")
+ .property("vnf-name", "test-vnf-name")
+ .property("equipment-role", "UCPE")
+ .next();
+ Vertex duplicateEntitlement = g.addV().property("aai-node-type", "entitlement")
+ .property("group-uuid", "guuid")
+ .property("resource-uuid", "ruuid-entitlement")
+ .property("aai-uri", "/network/generic-vnfs/generic-vnf/123456789/entitlements/entitlement/ruuideuuid/ruuid-entitlement")
+ .next();
+
+ Vertex duplicateLicense = g.addV().property("aai-node-type", "license")
+ .property("group-uuid", "guuid")
+ .property("resource-uuid", "ruuid-license")
+ .property("aai-uri", "/network/generic-vnfs/generic-vnf/123456789/licenses/license/ruuideuuid/ruuid-license")
+ .next();
+
+
+
+ edgeSerializer.addTreeEdge(g, vnf, license);
+ edgeSerializer.addTreeEdge(g, vnf, entitlement);
+ edgeSerializer.addTreeEdge(g, vnf2, duplicateEntitlement);
+ edgeSerializer.addTreeEdge(g, vnf2, duplicateLicense);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new ALTSLicenseEntitlementMigration(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+ @Test
+ public void testEntitlementsUpdated() throws UnsupportedEncodingException {
+ assertEquals("Found 1 entitlement", (Long)1L,
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "entitlement").count().next());
+ assertEquals("Entitlement's resource-uuid is updated ", true,
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "entitlement").has("resource-uuid", "new-ruuid-entitlement").hasNext());
+ assertEquals("Entitlement's resource-uuid is updated by migration ", true,
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "entitlement").has("resource-uuid", "new-ruuid-entitlement").has("last-mod-source-of-truth", "ALTSLicenseEntitlementMigration").hasNext());
+ }
+ @Test
+ public void testLicensesUpdated() throws UnsupportedEncodingException {
+ assertEquals("Found 1 License", (Long)1L,
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "license").count().next());
+ assertEquals("License's resource-uuid is updated ", true,
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "license").has("resource-uuid", "new-ruuid-license").hasNext());
+ }
+
+ @Test
+ public void verifyUri() {
+ assertEquals("Uri should be updated", "/network/generic-vnfs/generic-vnf/123456789/entitlements/entitlement/ruuideuuid/new-ruuid-entitlement",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "entitlement").has("resource-uuid", "new-ruuid-entitlement").next().property(AAIProperties.AAI_URI).value());
+ assertEquals("Uri should be updated", "/network/generic-vnfs/generic-vnf/123456789/licenses/license/ruuideuuid/new-ruuid-license",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "123456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "license").has("resource-uuid", "new-ruuid-license").next().property(AAIProperties.AAI_URI).value());
+ }
+
+ @Test
+ public void duplicateGroupUuid() {
+ Long count = g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "23456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "license").has("resource-uuid", "new-ruuid-license2").count().next() +
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "23456789").in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "entitlement").has("resource-uuid", "new-ruuid-entitlement2").count().next();
+ assertEquals("Duplicate Entitlement or License Group Uuid should be skipped", (Long)1L, count);
+
+
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java b/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java
new file mode 100644
index 0000000..7acb40d
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfigurationTest.java
@@ -0,0 +1,199 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class MigrateDataFromASDCToConfigurationTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateDataFromASDCToConfiguration migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+
+ Vertex configuration;
+ Vertex configuration2;
+ Vertex configuration3;
+ Vertex configuration4;
+ Vertex configuration5;
+
+ private boolean success = true;
+ private String entitlementPoolUuid = "";
+ private final String PARENT_NODE_TYPE = "generic-vnf";
+ private String VNT = "";
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+ Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId1")
+ .property("vnf-type","HN")
+ .next();
+
+ Vertex genericvnf2 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfId2")
+ .property("vnf-type","HN")
+ .next();
+
+ Vertex genericvnf_wrongtype = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnfIdWrong")
+ .property("vnf-type","vHNF")
+ .next();
+
+ Vertex entitlement1 = g.addV().property("aai-node-type", "entitlement")
+ .property("group-uuid", "599a2d74-cfbd-413d-aedb-ec4875817313")
+ .next();
+
+ Vertex entitlement2 = g.addV().property("aai-node-type", "entitlement")
+ .property("group-uuid", "ea9a547e-137b-48e9-a788-c3fb4e631a2a")
+ .next();
+
+ Vertex serviceInstance1 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "servinstanceTestId1")
+ .next();
+
+ Vertex serviceInstance2 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "servinstanceTestId2")
+ .next();
+
+ configuration = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "configurationIdGraph")
+ .property("vendor-allowed-max-bandwidth", "20")
+ .next();
+ configuration3 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "configurationIdGraph3")
+ .property("vendor-allowed-max-bandwidth", "15")
+ .next();
+ configuration2 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "configurationIdGraph2")
+ .property("vendor-allowed-max-bandwidth", "25")
+ .next();
+ configuration4 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "configurationIdGraph4")
+ .property("vendor-allowed-max-bandwidth", "50")
+ .next();
+ configuration5 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "configurationIdGraph4")
+ .property("vendor-allowed-max-bandwidth", "75")
+ .next();
+
+ edgeSerializer.addTreeEdge(g, genericvnf1, entitlement1);
+ edgeSerializer.addEdge(g, genericvnf1, serviceInstance1);
+ edgeSerializer.addEdge(g, serviceInstance1, configuration);
+ edgeSerializer.addEdge(g, serviceInstance1, configuration3);
+
+
+ edgeSerializer.addEdge(g, genericvnf2, configuration2, "org.onap.relationships.inventory.Uses");
+
+ edgeSerializer.addTreeEdge(g, genericvnf_wrongtype, entitlement2);
+ edgeSerializer.addEdge(g, genericvnf_wrongtype, serviceInstance2);
+ edgeSerializer.addEdge(g, serviceInstance2, configuration5);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateDataFromASDCToConfiguration(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * checks if the VNt value was updated and if theres a second configuration object it is also to be modified
+ */
+
+ @Test
+ public void confirmVNtValueChanged() {
+
+ assertEquals("1000",configuration.property("vendor-allowed-max-bandwidth").value());
+ assertEquals("1000",configuration3.property("vendor-allowed-max-bandwidth").value());
+
+ }
+
+ /***
+ * checks to see if the entitlement object is missing the configuration objects should not be modified at all
+ */
+ @Test
+ public void missingEntitlementObject() {
+ assertEquals("25",configuration2.property("vendor-allowed-max-bandwidth").value());
+ }
+ /***
+ * checks to see if there's a configuration object not connected to anything it should not be modified at all
+ */
+
+ @Test
+ public void confirmConfiguration4notchanged() {
+ assertEquals("50",configuration4.property("vendor-allowed-max-bandwidth").value());
+ }
+ /***
+ * checks that a configuration object not linked to a "HN" vnf-type should not be changed
+ */
+ @Test
+ public void differentVNFType() {
+ assertEquals("75",configuration5.property("vendor-allowed-max-bandwidth").value());
+ }
+
+
+
+
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigrateHUBEvcInventoryTest.java b/src/test/java/org/onap/aai/migration/v12/MigrateHUBEvcInventoryTest.java
new file mode 100644
index 0000000..72daf2e
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigrateHUBEvcInventoryTest.java
@@ -0,0 +1,377 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigrateHUBEvcInventoryTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateHUBEvcInventory migration;
+ private JanusGraphTransaction tx;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex customer1 = g.addV()
+ .property("aai-node-type", "customer")
+ .property("global-customer-id", "customer-id-1")
+ .property("subscriber-type", "CUST")
+ .next();
+
+ Vertex servSub1 = g.addV()
+ .property("aai-node-type", "service-subscription")
+ .property("service-type", "SAREA")
+ .next();
+
+ Vertex servInstance1 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-type", "SAREA")
+ .property("service-instance-id", "evc-name-1")
+ .next();
+ Vertex servInstance3 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-type", "SAREA")
+ .property("service-instance-id", "evc-name-3")
+ .next();
+ Vertex servInstance2 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-type", "SAREA")
+ .property("service-instance-id", "evc-name-2")
+ .next();
+
+ Vertex evc1 = g.addV().property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-1")
+ .next();
+ Vertex config1 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-1")
+ .next();
+ Vertex fp1 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "evc-name-1")
+ .next();
+ Vertex for11 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "1")
+ .property("forwarder-role","ingress")
+ .next();
+ Vertex for12 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "2")
+ .property("forwarder-role","egress")
+ .next();
+ Vertex config11 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-1-1")
+ .next();
+ Vertex config12 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-1-2")
+ .next();
+ Vertex fevc11 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-1-1")
+ .property("svlan", "6")
+ .next();
+ Vertex fevc12 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-1-2")
+ .property("svlan", "16")
+ .next();
+
+
+
+ Vertex evc2 = g.addV().property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-2")
+ .next();
+ Vertex config2 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-2")
+ .next();
+ Vertex fp2 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "evc-name-2")
+ .next();
+ Vertex for21 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "1")
+ .property("forwarder-role","ingress")
+ .next();
+ Vertex for22 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "2")
+ .property("forwarder-role","ingress")
+ .next();
+ Vertex for23 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "3")
+ .property("forwarder-role","egress")
+ .next();
+ Vertex for24 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "4")
+ .property("forwarder-role","egress")
+ .next();
+ Vertex config21 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-2-1")
+ .next();
+ Vertex config22 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-2-2")
+ .next();
+ Vertex config23 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-2-3")
+ .next();
+ Vertex config24 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-2-4")
+ .next();
+ Vertex fevc21 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-2-1")
+ .property("svlan", "6")
+ .next();
+ Vertex fevc22 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-2-2")
+ .property("svlan", "16")
+ .next();
+ Vertex fevc23 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-2-3")
+ .property("svlan", "12")
+ .property("ivlan", "600")
+ .next();
+ Vertex fevc24 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-2-4")
+ .property("svlan", "16")
+ .property("ivlan", "600")
+ .next();
+
+ Vertex evc3 = g.addV().property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-3")
+ .next();
+ Vertex config3 = g.addV().property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-3")
+ .next();
+ Vertex fp3 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "evc-name-3")
+ .next();
+ Vertex for31 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "1")
+ .property("forwarder-role","ingress")
+ .next();
+ Vertex for32 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", "2")
+ .property("forwarder-role","egress")
+ .next();
+ Vertex config31 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-3-1")
+ .next();
+ Vertex config32 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "evc-name-3-2")
+ .next();
+ Vertex fevc31 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-3-1")
+ .property("svlan", "6")
+ .next();
+ Vertex fevc32 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "evc-name-3-2")
+// .property("svlan", "16")
+ .next();
+
+ // graph 1
+ edgeSerializer.addTreeEdge(g, customer1, servSub1);
+ edgeSerializer.addTreeEdge(g, servSub1, servInstance1);
+ edgeSerializer.addTreeEdge(g, servSub1, servInstance2);
+ edgeSerializer.addTreeEdge(g, servSub1, servInstance3);
+
+ edgeSerializer.addEdge(g, servInstance1, fp1);
+ edgeSerializer.addEdge(g, servInstance2, fp2);
+
+ edgeSerializer.addEdge(g, fp1, config1);
+ edgeSerializer.addEdge(g, fp2, config2);
+ edgeSerializer.addEdge(g, fp3, config3);
+
+ edgeSerializer.addTreeEdge(g, evc1, config1);
+ edgeSerializer.addTreeEdge(g, evc2, config2);
+ edgeSerializer.addTreeEdge(g, evc3, config3);
+
+ edgeSerializer.addTreeEdge(g, fp1, for11);
+ edgeSerializer.addTreeEdge(g, fp1, for12);
+ edgeSerializer.addTreeEdge(g, fp2, for21);
+ edgeSerializer.addTreeEdge(g, fp2, for22);
+ edgeSerializer.addTreeEdge(g, fp2, for23);
+ edgeSerializer.addTreeEdge(g, fp2, for24);
+ edgeSerializer.addTreeEdge(g, fp3, for31);
+ edgeSerializer.addTreeEdge(g, fp3, for32);
+
+ edgeSerializer.addEdge(g, for11, config11);
+ edgeSerializer.addEdge(g, for12, config12);
+ edgeSerializer.addEdge(g, for21, config21);
+ edgeSerializer.addEdge(g, for22, config22);
+ edgeSerializer.addEdge(g, for23, config23);
+ edgeSerializer.addEdge(g, for24, config24);
+ edgeSerializer.addEdge(g, for31, config31);
+ edgeSerializer.addEdge(g, for32, config32);
+
+ edgeSerializer.addTreeEdge(g, config11, fevc11);
+ edgeSerializer.addTreeEdge(g, config12, fevc12);
+ edgeSerializer.addTreeEdge(g, config21, fevc21);
+ edgeSerializer.addTreeEdge(g, config22, fevc22);
+ edgeSerializer.addTreeEdge(g, config23, fevc23);
+ edgeSerializer.addTreeEdge(g, config24, fevc24);
+ edgeSerializer.addTreeEdge(g, config31, fevc31);
+ edgeSerializer.addTreeEdge(g, config32, fevc32);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateHUBEvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Test
+ public void testRun_checkFevc1AndFevc2AreUpdated() throws Exception {
+
+ // check if forwarder-evc nodes get updated
+ assertEquals("forwarder-evc evc-name-1-1 updated with ivlan", true,
+ g.V().has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id", "evc-name-1-1")
+ .has("ivlan","4054")
+ .hasNext());
+
+ assertEquals("forwarder-evc evc-name-2-2 updated with ivlan", true,
+ g.V().has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id", "evc-name-2-2")
+ .has("ivlan","4084")
+ .hasNext());
+ assertEquals("forwarder-evc evc-name-2-3 updated with ivlan", true,
+ g.V().has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id", "evc-name-2-3")
+ .has("ivlan","4054")
+ .hasNext());
+
+ assertEquals("4 forwarder-evcs exist for evc evc-name-2", new Long(4L),
+ g.V().has("forwarding-path-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .count().next());
+
+ assertEquals("3 forwarder-evcs updated for evc evc-name-2", new Long(3L),
+ g.V().has("forwarding-path-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id").has("ivlan")
+ .count().next());
+
+ assertEquals("forwarder-evc evc-name-3-1 updated with ivlan", false,
+ g.V().has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id", "evc-name-3-1")
+ .has("ivlan")
+ .hasNext());
+ }
+
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"forwarder-evc"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigrateHUBEvcInventory", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryMethodTest.java b/src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryMethodTest.java
new file mode 100644
index 0000000..59ae5e7
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryMethodTest.java
@@ -0,0 +1,149 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.javatuples.Pair;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class MigrateINVPhysicalInventoryMethodTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private JanusGraphTransaction tx;
+ private GraphTraversalSource g;
+ private TransactionalGraphEngine spy;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+
+ @Test
+ public void headerTest() throws Exception {
+ MigrateINVPhysicalInventory m = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ String header = "ptnii-name,fic,equipment-model,equipment-role,equipment-role-additional,ip-addr,subnet-mask,slot-name,card-type,card-port-lock,card-vlan-lock,port-aid,port-type,port-role,port-lock,vlan-lock,reservation-name,collector-interconnect-type,tag-mode,media-type,media-speed-value+media-speed-units,uni-cir-value+uni-cir-units,evc-name";
+ List<String> lines = new ArrayList<>();
+ lines.add(header);
+ assertEquals(header, m.processAndRemoveHeader(lines));
+ assertEquals(0, lines.size());
+ assertEquals(23, m.headerLength);
+
+ }
+
+ @Test
+ public void verifyLineTest() throws Exception {
+ MigrateINVPhysicalInventory m = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ m.headerLength = 23;
+ assertFalse(m.verifyLine(Collections.nCopies(5, "foo")));
+ assertTrue(m.verifyLine(Collections.nCopies(23, "foo")));
+ assertEquals(1, m.skippedRowsCount.intValue());
+
+ }
+
+ @Test
+ public void readLineTest() throws Exception {
+ MigrateINVPhysicalInventory m = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ String line = "pnf-name-collector-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,\"1.7 \",SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651881_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-1\n";
+ Pair<String, String> pair = m.processLine(Arrays.asList(line.split("\\s*,\\s*", -1))).get();
+ assertEquals("Test 1","pnf-name-collector-1", pair.getValue0());
+ assertEquals("Test 1","1.7", pair.getValue1());
+
+ line = "pnf-name-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,1.2,SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651882_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-3";
+ pair = m.processLine(Arrays.asList(line.split("\\s*,\\s*", -1))).get();
+ assertEquals("Test 1","pnf-name-1", pair.getValue0());
+ assertEquals("Test 1","1.2", pair.getValue1());
+
+ }
+
+ @Test
+ public void getFileContentsTest() throws Exception {
+ MigrateINVPhysicalInventory m = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+
+ Map<String,Set<String>> expected = new HashMap<>();
+ List<String> lines = new ArrayList<>();
+
+ String header = "ptnii-name,fic,equipment-model,equipment-role,equipment-role-additional,ip-addr,subnet-mask,slot-name,card-type,card-port-lock,card-vlan-lock,port-aid,port-type,port-role,port-lock,vlan-lock,reservation-name,collector-interconnect-type,tag-mode,media-type,media-speed-value+media-speed-units,uni-cir-value+uni-cir-units,evc-name";
+ lines.add(header);
+
+ lines.add("pnf-name-collector-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,\"1.7 \",SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651881_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-1");
+ expected.put("pnf-name-collector-1", new HashSet<>(Arrays.asList("1.7")));
+
+ lines.add("pnf-name-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,1.2,SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651882_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-3");
+ lines.add("pnf-name-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,1.2,SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651882_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-3");
+ lines.add("pnf-name-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,1.3,SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651882_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-3");
+ expected.put("pnf-name-1", new HashSet<>(Arrays.asList("1.2", "1.3")));
+
+ lines.add("foo");
+
+ assertEquals(expected, m.getFileContents(lines));
+
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryTest.java b/src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryTest.java
new file mode 100644
index 0000000..82ea770
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryTest.java
@@ -0,0 +1,168 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.Optional;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+public class MigrateINVPhysicalInventoryTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateINVPhysicalInventory migration;
+ private JanusGraphTransaction tx;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+
+ Vertex pnf1 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-1")
+ .property("aai-uri", "/network/pnfs/pnf/pnf-name-1")
+ .next();
+ Vertex port11 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.1")
+ .property("aai-uri", "/network/pnfs/pnf/pnf-name-1/p-interfaces/pinterface/1.1")
+ .next();
+ // graph 1
+
+ edgeSerializer.addTreeEdge(g, pnf1, port11);
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+
+ @Test
+ public void pnfsExistTest() throws Exception {
+ // check if pnf node gets created
+ assertEquals("2 PNFs exist", new Long(2L),
+ g.V().has("aai-node-type", "pnf")
+ .count().next());
+ }
+
+ @Test
+ public void pInterfacesExistTest() throws Exception {
+
+ assertEquals("4 Pinterfaces exist", new Long(4L),
+ g.V().has("aai-node-type", "p-interface")
+ .count().next());
+ }
+
+ @Test
+ public void testRun_checkPnfsAndPInterfacesExist() throws Exception {
+ // check if graph nodes exist
+
+ // check if pnf node gets created
+ assertEquals("2 PNFs exist", new Long(2L),
+ g.V().has("aai-node-type", "pnf")
+ .count().next());
+
+ System.out.println("cOUNT:" +g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-collector-1").in("tosca.relationships.network.BindsTo").count().next());
+
+ assertEquals("p-interfaces created for pnfs", new Long(1L),
+ g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-collector-1").count().next());
+
+ assertEquals("p-interface 1.7 created for pnf-name-collector-1", true,
+ g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-collector-1")
+ .in("tosca.relationships.network.BindsTo")
+ .has("interface-name","1.7")
+ .hasNext());
+ assertEquals("p-interfaces created for pnfs", new Long(2L),
+ g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-1")
+ .in("tosca.relationships.network.BindsTo").count().next());
+ }
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"pnf"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigrateINVPhysicalInventory", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigrateInvEvcInventoryTest.java b/src/test/java/org/onap/aai/migration/v12/MigrateInvEvcInventoryTest.java
new file mode 100644
index 0000000..ebe5136
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigrateInvEvcInventoryTest.java
@@ -0,0 +1,152 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigrateInvEvcInventoryTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private static Loader loader;
+ private static TransactionalGraphEngine dbEngine;
+ private static JanusGraph graph;
+ private static MigrateINVEvcInventory migration;
+ private static JanusGraphTransaction tx;
+ private static GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex evc = g.addV()
+ .property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-1")
+ .next();
+
+ Vertex evc2 = g.addV()
+ .property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-2")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateINVEvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Test
+ public void testRun_updateEvcNode() throws Exception {
+ // check if graph nodes exist
+ assertEquals("evc node exists", true,
+ g.V().has("aai-node-type", "evc")
+ .has("evc-id", "evc-name-1")
+ .hasNext());
+
+ // check if evc object is updated to set the value for inter-connect-type-ingress
+ assertEquals("evc is updated", true,
+ g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-1")
+ .has("inter-connect-type-ingress", "SHARED")
+ .hasNext());
+ }
+
+ @Test
+ public void testRun_evcNotCreated() throws Exception {
+
+ assertEquals("evc node does not exist", false,
+ g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-3")
+ .hasNext());
+
+ //inter-connect-type-ingress is not present on the evc
+ assertEquals("evc node exists", true,
+ g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-2")
+ .hasNext());
+ assertEquals("evc node not updated with inter-connect-type-ingress", false,
+ g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-2").has("inter-connect-type-ingress")
+ .hasNext());
+
+ }
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"evc"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigrateINVEvcInventory", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigratePATHEvcInventoryTest.java b/src/test/java/org/onap/aai/migration/v12/MigratePATHEvcInventoryTest.java
new file mode 100644
index 0000000..334f32b
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigratePATHEvcInventoryTest.java
@@ -0,0 +1,658 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+public class MigratePATHEvcInventoryTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigratePATHEvcInventory migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex customer1 = g.addV()
+ .property("aai-node-type", "customer")
+ .property("global-customer-id", "customer-id-1")
+ .property("subscriber-type", "CUST")
+ .next();
+
+ Vertex servSub1 = g.addV()
+ .property("aai-node-type", "service-subscription")
+ .property("service-type", "SAREA")
+ .next();
+
+ Vertex servInstance1 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-type", "SAREA")
+ .property("service-instance-id", "evc-name-1")
+ .next();
+ Vertex servInstance3 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-type", "SAREA")
+ .property("service-instance-id", "evc-name-3")
+ .next();
+ Vertex servInstance2 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-type", "SAREA")
+ .property("service-instance-id", "evc-name-2")
+ .next();
+
+ Vertex pnf1 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-1")
+ .next();
+ Vertex port11 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.1")
+ .next();
+ Vertex port12 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.41")
+ .next();
+
+ Vertex pnf2 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-2")
+ .next();
+ Vertex port21 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.25")
+ .next();
+ Vertex port22 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "ae1")
+ .next();
+
+ Vertex pnf3 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-3")
+ .next();
+ Vertex port31 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.32")
+ .next();
+ Vertex port32 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "ae1")
+ .next();
+
+ Vertex pnf4 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-4")
+ .next();
+ Vertex port41 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.7")
+ .next();
+ Vertex port42 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "ae101")
+ .next();
+
+ Vertex pnf5 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-5")
+ .next();
+ Vertex port51 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "104")
+ .next();
+ Vertex port52 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "101")
+ .next();
+
+ Vertex pnf6 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-6")
+ .next();
+ Vertex port61 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "ae104")
+ .next();
+ Vertex port62 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "1.39")
+ .next();
+
+ Vertex evc1 = g.addV().property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-1")
+ .next();
+ Vertex fp1 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "evc-name-1")
+ .next();
+
+ Vertex evc2 = g.addV().property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-2")
+ .next();
+ Vertex fp2 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "evc-name-2")
+ .next();
+
+ Vertex evc3 = g.addV().property("aai-node-type", "evc")
+ .property("evc-id", "evc-name-3")
+ .next();
+ Vertex fp3 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "evc-name-3")
+ .next();
+
+ // graph 1
+ edgeSerializer.addTreeEdge(g, customer1, servSub1);
+ edgeSerializer.addTreeEdge(g, servSub1, servInstance1);
+ edgeSerializer.addTreeEdge(g, servSub1, servInstance2);
+ edgeSerializer.addTreeEdge(g, servSub1, servInstance3);
+
+ edgeSerializer.addEdge(g, servInstance1, fp1);
+ edgeSerializer.addEdge(g, servInstance2, fp2);
+ edgeSerializer.addEdge(g, servInstance3, fp3);
+
+ edgeSerializer.addTreeEdge(g, pnf1, port11);
+ edgeSerializer.addTreeEdge(g, pnf1, port12);
+
+ edgeSerializer.addTreeEdge(g, pnf2, port21);
+ edgeSerializer.addTreeEdge(g, pnf2, port22);
+
+ edgeSerializer.addTreeEdge(g, pnf3, port31);
+ edgeSerializer.addTreeEdge(g, pnf3, port32);
+
+ edgeSerializer.addTreeEdge(g, pnf4, port41);
+ edgeSerializer.addTreeEdge(g, pnf4, port42);
+
+ edgeSerializer.addTreeEdge(g, pnf5, port51);
+ edgeSerializer.addTreeEdge(g, pnf5, port52);
+
+ edgeSerializer.addTreeEdge(g, pnf6, port61);
+ edgeSerializer.addTreeEdge(g, pnf6, port62);
+
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigratePATHEvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @Test
+ public void testRun_checkServInstanceAndForwardingPathsExist() throws Exception {
+ // check if graph nodes exist
+
+ // check if service-instance node gets created
+ assertEquals("service subscription node, service-type=SAREA", true,
+ g.V().has("service-instance-id", "evc-name-1")
+ .out("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .hasNext());
+
+ assertEquals("fowarding-path node exists", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo")
+ .has("aai-node-type", "forwarding-path")
+ .has("forwarding-path-id", "evc-name-1")
+ .hasNext());
+ assertEquals("fowarding-path node exists", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.AppliesTo")
+ .has("aai-node-type", "forwarding-path")
+ .has("forwarding-path-id", "evc-name-2")
+ .hasNext());
+ assertEquals("fowarding-path node exists", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo")
+ .has("aai-node-type", "forwarding-path")
+ .has("forwarding-path-id", "evc-name-3")
+ .hasNext());
+
+ }
+
+ @Test
+ public void testRun_checkForwardersForEvc1AreCreated() throws Exception {
+ // check if graph nodes exist
+ // check if forwarder node gets created
+
+ assertEquals("forwarder node is created for evc-name-1 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 1)
+ .has("forwarder-role", "ingress")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-1 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 2)
+ .has("forwarder-role", "egress")
+ .hasNext());
+ }
+
+ @Test
+ public void testRun_checkForwardersForEvc2AreCreated() throws Exception {
+
+ // check if forwarder node gets created
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .hasNext());
+
+ assertEquals("4 forwarders are created for evc-name-2 ", (Long)4l,
+ g.V().
+ has("aai-node-type", "forwarding-path").has("forwarding-path-id","evc-name-2")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("aai-node-type", "forwarder").count().next()); //org.onap.relationships.inventory.BelongsTo
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("aai-node-type", "forwarding-path").has("forwarding-path-id","evc-name-2")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 1)
+ .has("forwarder-role", "ingress")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 1)
+ .has("forwarder-role", "ingress")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 2)
+ .has("forwarder-role", "intermediate")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 3)
+ .has("forwarder-role", "intermediate")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 4)
+ .has("forwarder-role", "egress")
+ .hasNext());
+ }
+
+ @Test
+ public void testRun_checkForwardersForEvc3AreCreated() throws Exception {
+
+ // check if forwarder node gets created
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 1)
+ .has("forwarder-role", "ingress")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 1)
+ .has("forwarder-role", "ingress")
+ .out("org.onap.relationships.inventory.ForwardsTo")
+ .has("aai-node-type", "p-interface")
+ .has("interface-name","1.7")
+ .hasNext());
+
+ assertEquals("forwarder-evc node is created for forwarder with sequence 1 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 1)
+ .has("forwarder-role", "ingress")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-1").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id","evc-name-3-1")
+ .has("circuit-id","M0651881")
+ .has("cvlan","34")
+ .has("svlan","8")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 2)
+ .has("forwarder-role", "intermediate")
+ .hasNext());
+
+ //forwarder to interface check
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 2)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.ForwardsTo")
+ .has("aai-node-type", "lag-interface")
+ .has("interface-name","ae101")
+ .hasNext());
+
+ assertEquals("forwarder-evc node is created for forwarder with sequence 2 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 2)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-2").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id","evc-name-3-2")
+ .has("cvlan","34")
+ .has("svlan","740")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 3)
+ .has("forwarder-role", "intermediate")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 3)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.ForwardsTo")
+ .has("aai-node-type", "lag-interface")
+ .has("interface-name","101")
+ .hasNext());
+
+ assertEquals("forwarder-evc node is created for forwarder with sequence 3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 3)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-3").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id","evc-name-3-3")
+ .has("cvlan","35")
+ .has("svlan","740")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 4)
+ .has("forwarder-role", "intermediate")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 4)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.ForwardsTo")
+ .has("aai-node-type", "lag-interface")
+ .has("interface-name","104")
+ .hasNext());
+
+ assertEquals("forwarder-evc node is created for forwarder with sequence 4 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 4)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-4").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id","evc-name-3-4")
+ .has("cvlan","37")
+ .has("svlan","740")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 5)
+ .has("forwarder-role", "intermediate")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 5)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.ForwardsTo")
+ .has("aai-node-type", "lag-interface")
+ .has("interface-name","ae104")
+ .hasNext());
+
+
+
+ assertEquals("configuration node is created for forwarder with sequence 5 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 5)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-5").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .hasNext());
+
+ assertEquals("forwarder-evc node is created for forwarder with sequence 5 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 5)
+ .has("forwarder-role", "intermediate")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-5").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id","evc-name-3-5")
+ .has("cvlan","36")
+ .has("svlan","740")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 6)
+ .has("forwarder-role", "egress")
+ .hasNext());
+
+ assertEquals("forwarder node is created for evc-name-3 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 6)
+ .has("forwarder-role", "egress")
+ .out("org.onap.relationships.inventory.ForwardsTo")
+ .has("aai-node-type", "p-interface")
+ .has("interface-name","1.39")
+ .hasNext());
+
+ assertEquals("configuration node is created for forwarder with sequence 6 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 6)
+ .has("forwarder-role", "egress")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-6").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .hasNext());
+
+ assertEquals("configuration node is created for forwarder with sequence 6 ", true,
+ g.V().has("global-customer-id", "customer-id-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
+ .has("sequence", 6)
+ .has("forwarder-role", "egress")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-id","evc-name-3-6").has("configuration-type","forwarder").has("configuration-sub-type", "forwarder")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
+ .has("forwarder-evc-id","evc-name-3-6").has("circuit-id","IZEZ.597112..ATI").has("cvlan","36").has("svlan","3")
+ .hasNext());
+
+ }
+
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"forwarding-path"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigratePATHEvcInventory", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigratePATHPhysicalInventoryTest.java b/src/test/java/org/onap/aai/migration/v12/MigratePATHPhysicalInventoryTest.java
new file mode 100644
index 0000000..11aa0a6
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigratePATHPhysicalInventoryTest.java
@@ -0,0 +1,159 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.shortThat;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigratePATHPhysicalInventoryTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigratePATHPhysicalInventory migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex pnf2 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-2")
+ .next();
+ Vertex port21 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "ae1")
+ .next();
+
+ Vertex pnf3 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-3")
+ .next();
+ Vertex pnf4 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-4")
+ .next();
+ Vertex pnf5 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-5")
+ .next();
+ // graph 1
+
+ edgeSerializer.addTreeEdge(g, pnf2, port21);
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigratePATHPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @Test
+ public void testRun_checkPnfsAndPInterfacesExist() throws Exception {
+ // check if graph nodes exist
+
+ testGetMigrationName();
+ testGetAffectedNodeTypes();
+
+ // check if pnf node gets created
+ assertEquals("4 PNFs exist", new Long(4L),
+ g.V().has("aai-node-type", "pnf")
+ .count().next());
+
+ assertEquals("5 lag-interfaces were created", new Long (5L), g.V().has("aai-node-type", "lag-interface")
+ .out("tosca.relationships.network.BindsTo").count().next());
+
+ assertEquals("lag-interfaces created for pnfs", new Long(1L),
+ g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-3").count().next());
+
+ assertEquals("lag-interface ae1 created for pnf-name-3", true,
+ g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-3")
+ .in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type", "lag-interface")
+ .has("interface-name","ae1")
+ .hasNext());
+
+ assertEquals("lag-interfaces created for pnfs", new Long(2L),
+ g.V().has("aai-node-type", "pnf")
+ .has("pnf-name", "pnf-name-5")
+ .in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type", "lag-interface").count().next());
+ }
+
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"lag-interface"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigratePATHPhysicalInventory", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v12/MigrateSAREvcInventoryTest.java b/src/test/java/org/onap/aai/migration/v12/MigrateSAREvcInventoryTest.java
new file mode 100644
index 0000000..79a5877
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v12/MigrateSAREvcInventoryTest.java
@@ -0,0 +1,357 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v12;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigrateSAREvcInventoryTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateSAREvcInventory migration;
+ private JanusGraphTransaction tx;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex customer1 = g.addV()
+ .property("aai-node-type", "customer")
+ .property("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .property("subscriber-type", "CUST")
+ .next();
+
+ Vertex servSub1 = g.addV()
+ .property("aai-node-type", "service-subscription")
+ .property("service-type", "SAREA")
+ .next();
+
+ Vertex servInst1 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-instance-id", "evc-name-1")
+ .next();
+
+ Vertex customer2 = g.addV()
+ .property("aai-node-type", "customer")
+ .property("global-customer-id", "cust-1")
+ .property("subscriber-type", "CUST")
+ .next();
+
+ Vertex servSub2 = g.addV()
+ .property("aai-node-type", "service-subscription")
+ .property("service-type", "SAREA")
+ .next();
+
+ Vertex servInst2 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-instance-id", "evc-name-1")
+ .next();
+
+ Vertex collectorPnf = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-collector-1")
+ .next();
+
+ Vertex bearerPnf = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf-name-bearer-1")
+ .next();
+
+ Vertex collectorPort = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-int-collector-1")
+ .next();
+
+ Vertex bearerPort = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "p-int-bearer-1")
+ .next();
+
+ Vertex servInst4 = g.addV()
+ .property("aai-node-type", "service-instance")
+ .property("service-instance-id", "evc-name-4")
+ .next();
+
+ // graph 1
+ edgeSerializer.addTreeEdge(g, customer1, servSub1);
+// edgeSerializer.addTreeEdge(g, servSub1, servInst1);
+ edgeSerializer.addTreeEdge(g, customer2, servSub2);
+ edgeSerializer.addTreeEdge(g, servSub2, servInst2);
+ edgeSerializer.addTreeEdge(g, servSub1, servInst4); //evc-name-4 exists in graph as a child of SAREA serv-sub
+ edgeSerializer.addTreeEdge(g, collectorPnf, collectorPort);
+ edgeSerializer.addTreeEdge(g, bearerPnf, bearerPort);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateSAREvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Test
+ public void testRun_createServiceInstanceNode() throws Exception {
+ // check if graph nodes exist
+ assertEquals("service instance node exists", true,
+ g.V().has("service-instance-id", "evc-name-1")
+ .hasNext());
+
+ // check if service-instance node gets created
+ assertEquals("service subscription node, service-type=SAREA", true,
+ g.V().has("service-instance-id", "evc-name-1")
+ .out("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .hasNext());
+
+
+
+ // check if fowarding-path node gets created
+ assertEquals("fowarding-path is created", true, g.V().has("forwarding-path-id", "evc-name-1")
+ .has("forwarding-path-name", "evc-name-1").hasNext());
+
+ assertEquals("fowarding-path node exists", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo")
+ .has("aai-node-type", "forwarding-path")
+ .has("forwarding-path-id", "evc-name-1")
+ .has("forwarding-path-name", "evc-name-1")
+ .hasNext());
+
+ // check if configuration node gets created
+ assertEquals("configuration node, configuration-type= forwarding-path", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-type", "forwarding-path")
+ .has("configuration-sub-type", "evc")
+ .hasNext());
+
+ //check if evc node gets created
+ assertEquals("evc is created", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "evc")
+ .hasNext());
+
+ // check if evc node gets created
+ assertEquals("configuration node, configuration-type= evc", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "evc")
+ .has("evc-id", "evc-name-1")
+ .has("forwarding-path-topology", "PointToPoint")
+ .has("cir-value", "40")
+ .has("cir-units", "Mbps")
+ .has("tagmode-access-ingress", "DOUBLE")
+ .has("tagmode-access-egress", "DOUBLE")
+ .hasNext());
+ }
+
+ @Test
+ public void testRun_evcNotCreated() throws Exception {
+ // check if graph nodes exist
+ assertEquals("customer node exists", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .hasNext());
+
+ assertEquals("service subscription node, service-type=SAREA", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .hasNext());
+
+ //service-instance should not be created
+ assertEquals("service instance node created", false,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
+ .hasNext());
+
+ assertEquals("service instance node already exists", true,
+ g.V().has("global-customer-id", "cust-1")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .hasNext());
+
+ // fowarding-path node should not be created
+ assertEquals("fowarding-path created", false, g.V().has("aai-node-type", "forwarding-path")
+ .has("forwarding-path-name", "evc-name-2").hasNext());
+
+ // configuration node should not be created
+ assertEquals("configuration node created", false, g.V().has("aai-node-type", "configuration")
+ .has("configuration-id", "evc-name-2").hasNext());
+
+ // evc node should not be created
+ assertEquals("evc node created", false, g.V().has("aai-node-type", "evc")
+ .has("evc-id", "evc-name-2").hasNext());
+
+ // service-instance is not created because pnf exists, but p-interface does not
+ assertEquals("service instance node created", false,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
+ .hasNext());
+ }
+
+ @Test
+ public void testRun_createFPConfigurationEvcNode4() throws Exception {
+ // check if graph nodes exist
+ assertEquals("service instance node exists", true,
+ g.V().has("service-instance-id", "evc-name-4")
+ .hasNext());
+
+ // check if service-instance node gets created
+ assertEquals("service subscription node, service-type=SAREA", true,
+ g.V().has("service-instance-id", "evc-name-4")
+ .out("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .hasNext());
+
+
+
+ // check if fowarding-path node gets created
+ assertEquals("fowarding-path is created", true, g.V().has("forwarding-path-id", "evc-name-4")
+ .has("forwarding-path-name", "evc-name-4").hasNext());
+
+ assertEquals("fowarding-path node exists", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-4")
+ .in("org.onap.relationships.inventory.AppliesTo")
+ .has("aai-node-type", "forwarding-path")
+ .has("forwarding-path-id", "evc-name-4")
+ .has("forwarding-path-name", "evc-name-4")
+ .hasNext());
+
+ // check if configuration node gets created
+ assertEquals("configuration node, configuration-type= forwarding-path", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-4")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .has("configuration-type", "forwarding-path")
+ .has("configuration-sub-type", "evc")
+ .hasNext());
+
+ //check if evc node gets created
+ assertEquals("evc is created", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-4")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "evc")
+ .hasNext());
+
+ // check if evc node gets created
+ assertEquals("configuration node, configuration-type= evc", true,
+ g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
+ .in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
+ .in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
+ .out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
+ .in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "evc")
+ .has("evc-id", "evc-name-1")
+ .has("forwarding-path-topology", "PointToPoint")
+ .has("cir-value", "40")
+ .has("cir-units", "Mbps")
+ .has("tagmode-access-ingress", "DOUBLE")
+ .has("tagmode-access-egress", "DOUBLE")
+ .hasNext());
+ }
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"service-instance"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigrateSAREvcInventory", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartOneTest.java b/src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartOneTest.java
new file mode 100644
index 0000000..d3607d3
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartOneTest.java
@@ -0,0 +1,173 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.janusgraph.core.schema.JanusGraphManagement;
+
+public class MigrateBadWidgetModelsPartOneTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private GraphTraversalSource g;
+ private MockMigrateBadWidgetModelsPartOne migration;
+ private Vertex modelVer1 = null;
+ private Vertex modelVer3 = null;
+
+ @Before
+ public void setUp() throws Exception {
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+ JanusGraphManagement janusgraphManagement = graph.openManagement();
+ g = graph.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
+ createFirstVertexAndRelatedVertexes();
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
+
+ migration = new MockMigrateBadWidgetModelsPartOne(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ private void createFirstVertexAndRelatedVertexes() throws AAIException {
+
+ // Add model1/model-ver1 -- invalid model/model-ver
+ Vertex model1 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "model-invariant-id-1").property("model-type", "widget").next();
+ modelVer1 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-1")
+ .property("model-name", "connector").property("model-version", "v1.0").next();
+ edgeSerializer.addTreeEdge(g, model1, modelVer1);
+
+ // Add named-query and named-query-element nodes. Point the named-query-element at model1
+ Vertex namedQ1 = g.addV().property("aai-node-type", "named-query")
+ .property("named-query-uuid", "named-query-uuid-1").property("named-query-name", "test-NQ-1").next();
+ Vertex namedQElement1 = g.addV().property("aai-node-type", "named-query-element")
+ .property("named-query-element-uuid", "named-query-element-uuid-1").next();
+ edgeSerializer.addTreeEdge(g, namedQElement1, namedQ1);
+ edgeSerializer.addEdge(g, model1, namedQElement1);
+
+
+ // For model3/model-ver3 - we use valid invId/versionIds
+ Vertex model3 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "4c01c948-7607-4d66-8a6c-99c2c2717936").property("model-type", "widget")
+ .next();
+ modelVer3 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "22104c9f-29fd-462f-be07-96cd6b46dd33")
+ .property("model-name", "connector").property("model-version", "v1.0").next();
+ edgeSerializer.addTreeEdge(g, model3, modelVer3);
+ }
+
+ class MockMigrateBadWidgetModelsPartOne extends MigrateBadWidgetModelsPartOne {
+
+ public MockMigrateBadWidgetModelsPartOne(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[] { "model", "model-element", "model-ver" });
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MockMigrateBadWidgetModelsPartOne";
+ }
+ }
+
+ @Test
+ public void testBelongsToEdgeStillThereForNqElement() {
+ assertEquals(true,
+ g.V().has("aai-node-type", "named-query-element").has("named-query-element-uuid", "named-query-element-uuid-1")
+ .out("org.onap.relationships.inventory.BelongsTo")
+ .has("named-query-uuid", "named-query-uuid-1").hasNext());
+ }
+
+ @Test
+ public void testBadNodesAreNotGone() {
+ assertEquals(true,
+ g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1").hasNext());
+ assertEquals(true,
+ g.V().has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1").hasNext());
+ }
+
+ @Test
+ public void testNQNodesaAreStillThere() {
+ assertEquals(true,
+ g.V().has("aai-node-type", "named-query").has("named-query-uuid", "named-query-uuid-1").hasNext());
+ assertEquals(true,
+ g.V().has("aai-node-type", "named-query-element").has("named-query-element-uuid", "named-query-element-uuid-1").hasNext());
+
+ }
+
+
+ @Test
+ public void testThatNewEdgeAdded() {
+ assertEquals(true,
+ g.V().has("aai-node-type", "model").has("model-invariant-id", "4c01c948-7607-4d66-8a6c-99c2c2717936")
+ .in("org.onap.relationships.inventory.IsA").has("named-query-element-uuid", "named-query-element-uuid-1")
+ .hasNext());
+ }
+
+ @Test
+ public void testThatOldEdgeDeleted() {
+ assertEquals(false,
+ g.V().has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1")
+ .in("org.onap.relationships.inventory.IsA").has("named-query-element-uuid", "named-query-element-uuid-1")
+ .hasNext());
+ }
+
+
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartTwoTest.java b/src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartTwoTest.java
new file mode 100644
index 0000000..f3c4bb1
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartTwoTest.java
@@ -0,0 +1,172 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.janusgraph.core.schema.JanusGraphManagement;
+
+public class MigrateBadWidgetModelsPartTwoTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private GraphTraversalSource g;
+ private MockMigrateBadWidgetModelsPartTwo migration;
+ private Vertex modelVer1 = null;
+ private Vertex modelVer3 = null;
+
+ @Before
+ public void setUp() throws Exception {
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+ JanusGraphManagement janusgraphManagement = graph.openManagement();
+ g = graph.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(queryStyle, type, loader);
+ createFirstVertexAndRelatedVertexes();
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ Mockito.doReturn(janusgraphManagement).when(adminSpy).getManagementSystem();
+
+ migration = new MockMigrateBadWidgetModelsPartTwo(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ private void createFirstVertexAndRelatedVertexes() throws AAIException {
+ Vertex model1 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "model-invariant-id-1").property("model-type", "widget").next();
+ modelVer1 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-1")
+ .property("model-name", "connector").property("model-version", "v1.0").next();
+ edgeSerializer.addTreeEdge(g, model1, modelVer1);
+
+ // Create the cousin vertex - modelElement2 for modelVer1
+ Vertex model2 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "model-invariant-id-2").property("model-type", "resource").next();
+ Vertex modelVer2 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "model-version-id-2").property("model-name", "resourceMod4Test")
+ .property("model-version", "v1.0").next();
+ edgeSerializer.addTreeEdge(g, model2, modelVer2);
+ Vertex modelElement2 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "model-element-uuid-2").property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded").next();
+ edgeSerializer.addTreeEdge(g, modelVer2, modelElement2);
+ edgeSerializer.addEdge(g, modelVer1, modelElement2);
+
+ // For model3/model-ver3 - we use valid invid/versionIds
+ Vertex model3 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "4c01c948-7607-4d66-8a6c-99c2c2717936").property("model-type", "widget")
+ .next();
+ modelVer3 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "22104c9f-29fd-462f-be07-96cd6b46dd33")
+ .property("model-name", "connector").property("model-version", "v1.0").next();
+ edgeSerializer.addTreeEdge(g, model3, modelVer3);
+ }
+
+ class MockMigrateBadWidgetModelsPartTwo extends MigrateBadWidgetModelsPartTwo {
+
+ public MockMigrateBadWidgetModelsPartTwo(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[] { "model", "model-element", "model-ver" });
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MockMigrateNodesThatUseBadWidgetModelsPartTwo";
+ }
+ }
+
+
+ @Test
+ public void testBelongsToEdgesStillThereX() {
+ assertEquals(true,
+ g.V().has("aai-node-type", "model-ver").has("model-version-id", "22104c9f-29fd-462f-be07-96cd6b46dd33")
+ .out("org.onap.relationships.inventory.BelongsTo")
+ .has("model-invariant-id", "4c01c948-7607-4d66-8a6c-99c2c2717936").hasNext());
+ assertEquals(true,
+ g.V().has("aai-node-type", "model-element").has("model-element-uuid", "model-element-uuid-2")
+ .out("org.onap.relationships.inventory.BelongsTo").has("model-version-id", "model-version-id-2")
+ .hasNext());
+ }
+
+ @Test
+ public void testBadVerNodeIsGoneX() {
+ assertEquals(false,
+ g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1").hasNext());
+ }
+
+ @Test
+ public void testBadModelNodeIsGoneX() {
+ assertEquals(false,
+ g.V().has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1").hasNext());
+ }
+
+ @Test
+ public void testThatNewEdgeAddedX() {
+ assertEquals(true,
+ g.V().has("aai-node-type", "model-ver").has("model-version-id", "22104c9f-29fd-462f-be07-96cd6b46dd33")
+ .in("org.onap.relationships.inventory.IsA").has("model-element-uuid", "model-element-uuid-2")
+ .hasNext());
+ }
+
+ @Test
+ public void testThatOldEdgeGone() {
+ assertEquals(false,
+ g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1")
+ .in("org.onap.relationships.inventory.IsA").has("model-element-uuid", "model-element-uuid-2")
+ .hasNext());
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v13/MigrateEdgesBetweenVnfcAndVfModuleTest.java b/src/test/java/org/onap/aai/migration/v13/MigrateEdgesBetweenVnfcAndVfModuleTest.java
new file mode 100644
index 0000000..90d30fc
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v13/MigrateEdgesBetweenVnfcAndVfModuleTest.java
@@ -0,0 +1,119 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.edges.enums.EdgeProperty;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+public class MigrateEdgesBetweenVnfcAndVfModuleTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private static Loader loader;
+ private static TransactionalGraphEngine dbEngine;
+ private static JanusGraph graph;
+ private static MigrateEdgesBetweenVnfcAndVfModule migration;
+ private static JanusGraphTransaction tx;
+ private static GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex vnfc = g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc-name-1").next();
+
+ Vertex vfmodule = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module-id-1").next();
+
+
+ //edgeSerializer.addEdge(g, vfmodule, vnfc,"org.onap.relationships.inventory.Uses");
+
+ vfmodule.addEdge("org.onap.relationships.inventory.Uses", vnfc, EdgeProperty.CONTAINS.toString(), "NONE",
+ EdgeProperty.DELETE_OTHER_V.toString(), "NONE", EdgeProperty.PREVENT_DELETE.toString(), "OUT");
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateEdgesBetweenVnfcAndVfModule(spy,loaderFactory,edgeIngestor,edgeSerializer,schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Ignore
+ @Test
+ public void testIdsUpdated() throws Exception {
+
+ //System.out.println("After Migration: " +migration.asString(g.V().has("aai-node-type","vnfc").inE().next()));
+
+ assertEquals("vf-module to vnfc migration done", true,
+ g.V().has("aai-node-type", "vf-module").outE().hasLabel("org.onap.relationships.inventory.Uses")
+ .has(EdgeProperty.DELETE_OTHER_V.toString(), "OUT").hasNext());
+
+ assertEquals("vf-module to vnfc migration done", true,
+ g.V().has("aai-node-type", "vnfc").inE().hasLabel("org.onap.relationships.inventory.Uses")
+ .has(EdgeProperty.PREVENT_DELETE.toString(), "NONE").hasNext());
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v13/MigrateForwarderEvcCircuitIdTest.java b/src/test/java/org/onap/aai/migration/v13/MigrateForwarderEvcCircuitIdTest.java
new file mode 100644
index 0000000..1006a29
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v13/MigrateForwarderEvcCircuitIdTest.java
@@ -0,0 +1,195 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v13;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigrateForwarderEvcCircuitIdTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigrateForwarderEvcCircuitId migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex pnf1 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-1").next();
+ Vertex pnf2 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-2").next();
+ Vertex pnf3 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-3").next();
+ Vertex pnf4 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-4").next();
+ Vertex pnf5 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-5").next();
+
+ Vertex pInterface1 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-1").next();
+ Vertex pInterface2 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-2").next();
+ Vertex pInterface3 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-3").next();
+ Vertex pInterface4 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-4").next();
+ Vertex pInterface5 = g.addV().property("aai-node-type", "p-interface").property("interface-name", "p-interface-5").next();
+
+ Vertex forwarder1 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1)
+ .property("forwarder-role", "ingress").next();
+ Vertex forwarder2 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1)
+ .property("forwarder-role", "ingress").next();
+ Vertex forwarder3 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1)
+ .property("forwarder-role", "ingress").next();
+ Vertex forwarder4 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1)
+ .property("forwarder-role", "ingress").next();
+ Vertex forwarder5 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1)
+ .property("forwarder-role", "ingress").next();
+
+
+ Vertex configuration1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-1")
+ .property("configuration-type", "test").property("configuration-subt-type", "test").next();
+ Vertex configuration2 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-2")
+ .property("configuration-type", "test").property("configuration-subt-type", "test").next();
+ Vertex configuration3 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-3")
+ .property("configuration-type", "test").property("configuration-subt-type", "test").next();
+ Vertex configuration4 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-4")
+ .property("configuration-type", "test").property("configuration-subt-type", "test").next();
+ Vertex configuration5 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-5")
+ .property("configuration-type", "test").property("configuration-subt-type", "test").next();
+
+
+ Vertex forwarderEvc1 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-1")
+ .property("circuit-id", "1").property("resource-version", "v13").next();
+ Vertex forwarderEvc2 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-2")
+ .property("circuit-id", "2").property("resource-version", "v13").next();
+ Vertex forwarderEvc3 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-3")
+ .property("resource-version", "v13").next();
+ Vertex forwarderEvc4 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-4")
+ .property("circuit-id", "3").property("resource-version", "v13").next();
+ Vertex forwarderEvc5 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-5")
+ .property("resource-version", "v13").next();
+
+
+
+ edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
+ edgeSerializer.addEdge(g, pInterface1, forwarder1);
+ edgeSerializer.addEdge(g, forwarder1, configuration1);
+ edgeSerializer.addTreeEdge(g, configuration1, forwarderEvc1);
+
+ edgeSerializer.addTreeEdge(g, pnf2, pInterface2);
+ edgeSerializer.addEdge(g, pInterface2, forwarder2);
+ edgeSerializer.addEdge(g, forwarder2, configuration2);
+ edgeSerializer.addTreeEdge(g, configuration2, forwarderEvc2);
+
+ edgeSerializer.addTreeEdge(g, pnf3, pInterface3);
+ edgeSerializer.addEdge(g, pInterface3, forwarder3);
+ edgeSerializer.addEdge(g, forwarder3, configuration3);
+ edgeSerializer.addTreeEdge(g, configuration3, forwarderEvc3);
+
+ edgeSerializer.addTreeEdge(g, pnf4, pInterface4);
+ edgeSerializer.addEdge(g, pInterface4, forwarder4);
+ edgeSerializer.addEdge(g, forwarder4, configuration4);
+ edgeSerializer.addTreeEdge(g, configuration4, forwarderEvc4);
+
+ edgeSerializer.addTreeEdge(g, pnf5, pInterface5);
+ edgeSerializer.addEdge(g, pInterface5, forwarder5);
+ edgeSerializer.addEdge(g, forwarder5, configuration5);
+ edgeSerializer.addTreeEdge(g, configuration5, forwarderEvc5);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateForwarderEvcCircuitId(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @Test
+ public void testCircuitIdsUpdated() throws Exception {
+ // check if graph nodes are updated
+
+ assertEquals("First circuit-id updated", "10",
+ g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "10").next().value("circuit-id").toString());
+
+ assertEquals("Second circuit-id updated", "20",
+ g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "20").next().value("circuit-id").toString());
+
+ assertFalse("Third circuit-id remains empty", g.V().has("aai-node-type", "forwarder-evc").has("forwarder-evc-id", "evc-3")
+ .next().property("circuit-id").isPresent());
+
+ assertEquals("Fourth circuit-id not updated", "3",
+ g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "3").next().value("circuit-id").toString());
+
+ assertFalse("Fifth circuit-id remains empty", g.V().has("aai-node-type", "forwarder-evc").has("forwarder-evc-id", "evc-5")
+ .next().property("circuit-id").isPresent());
+ }
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"forwarder-evc"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigrateForwarderEvcCircuitId", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/migration/v14/MigrateGenericVnfMgmtOptionsTest.java b/src/test/java/org/onap/aai/migration/v14/MigrateGenericVnfMgmtOptionsTest.java
new file mode 100644
index 0000000..a35c300
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v14/MigrateGenericVnfMgmtOptionsTest.java
@@ -0,0 +1,230 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v14;
+
+import org.onap.aai.AAISetup;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.migration.Status;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import javax.validation.constraints.AssertFalse;
+
+import static org.junit.Assert.assertTrue;
+
+public class MigrateGenericVnfMgmtOptionsTest extends AAISetup {
+
+ protected static final String VNF_NODE_TYPE = "generic-vnf";
+
+ public static class MigrateVnfType extends MigrateGenericVnfMgmtOptions {
+ public MigrateVnfType(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions){
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+ @Override
+ public Status getStatus() {
+ return Status.SUCCESS;
+ }
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{VNF_NODE_TYPE});
+ }
+ @Override
+ public String getMigrationName() {
+ return "MockMigrateVnfType";
+ }
+ }
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigrateVnfType migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setup() throws Exception{
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ //generic-vnf
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf0")
+ .property("vnf-type", "HN")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf1")
+ .property("vnf-type", "HN")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf2")
+ .property("vnf-type", "HN")
+ .property("management-option", "existingOption")
+ .next();
+
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf10")
+ .property("vnf-type", "HP")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf11")
+ .property("vnf-type", "HP")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf12")
+ .property("vnf-type", "HP")
+ .property("management-option", "existingOption")
+ .next();
+
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf20")
+ .property("vnf-type", "HG")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf21")
+ .property("vnf-type", "HG")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf22")
+ .property("vnf-type", "HG")
+ .property("management-option", "existingOption")
+ .next();
+
+ // Non-eligible migration conditions - vnf-type = XX
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf30")
+ .property("vnf-type", "XX")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf31")
+ .property("vnf-type", "XX")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf32")
+ .property("vnf-type", "XX")
+ .property("management-option", "existingOption")
+ .next();
+ // Non-eligible migration conditions - vnf-type = missing
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf40")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf41")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf42")
+ .property("management-option", "existingOption")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateVnfType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+
+ }
+
+ @Test
+ public void testMissingProperty(){
+ //management-option
+ assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf0").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf10").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf20").has("management-option", "AT&T Managed-Basic").hasNext());
+ }
+
+ @Test
+ public void testEmptyValue() {
+ //management-option
+ assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf11").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf21").has("management-option", "AT&T Managed-Basic").hasNext());
+
+ }
+
+ @Test
+ public void testExistingValues() {
+ //management-option
+ assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf2").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf12").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf22").has("management-option", "AT&T Managed-Basic").hasNext());
+
+
+ }
+
+ @Test
+ public void testExistingVnfsNotMigrated() {
+ //management-option
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf30").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf31").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected and management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf32").has("management-option", "AT&T Managed-Basic").hasNext());
+
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf40").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf41").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present and management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf42").has("management-option", "AT&T Managed-Basic").hasNext());
+
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v14/MigrateMissingFqdnOnPserversTest.java b/src/test/java/org/onap/aai/migration/v14/MigrateMissingFqdnOnPserversTest.java
new file mode 100644
index 0000000..f4ec345
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v14/MigrateMissingFqdnOnPserversTest.java
@@ -0,0 +1,129 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v14;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+
+public class MigrateMissingFqdnOnPserversTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateMissingFqdnOnPservers migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ Vertex pserver1;
+ Vertex pserver2;
+ Vertex pserver3;
+ Vertex pserver4;
+ Vertex pserver5;
+
+
+ @Before
+ public void setUp() throws Exception {
+
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+
+ pserver1 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE)
+ .property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname1.com")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO")
+ .next();
+
+ pserver2 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE)
+ .property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname2.com")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_FQDN, "")
+ .next();
+
+ pserver3 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE)
+ .property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "akr1")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_FQDN, "akr1")
+ .next();
+
+ pserver4 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE)
+ .property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname1")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_FQDN, "")
+ .next();
+
+ pserver5 = g.addV().property("aai-node-type", MigrateMissingFqdnOnPservers.PSERVER_NODE_TYPE)
+ .property(MigrateMissingFqdnOnPservers.PSERVER_HOSTNAME, "hostname2")
+ .property(MigrateMissingFqdnOnPservers.PSERVER_SOURCEOFTRUTH, "RO")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateMissingFqdnOnPservers(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * checks if the fqdn value was changed
+ */
+
+ @Test
+ public void confirmFQDNValueChanged() {
+
+ assertEquals("hostname1.com",pserver1.property(MigrateMissingFqdnOnPservers.PSERVER_FQDN).value());//created fqdn property
+ assertEquals("hostname2.com",pserver2.property(MigrateMissingFqdnOnPservers.PSERVER_FQDN).value());//updated empty fqdn
+ assertEquals("akr1",pserver3.property(MigrateMissingFqdnOnPservers.PSERVER_FQDN).value());//Not changed
+ assertEquals("",pserver4.property(MigrateMissingFqdnOnPservers.PSERVER_FQDN).value());//Not changed
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v14/MigrateNetworkTechToCloudRegionTest.java b/src/test/java/org/onap/aai/migration/v14/MigrateNetworkTechToCloudRegionTest.java
new file mode 100644
index 0000000..6438034
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v14/MigrateNetworkTechToCloudRegionTest.java
@@ -0,0 +1,147 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v14;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+public class MigrateNetworkTechToCloudRegionTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private GraphTraversalSource g;
+ private MigrateNetworkTechToCloudRegion migration;
+
+ @Before
+ public void setUp() throws Exception {
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ Vertex cloudRegion1 = g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region-id-1").property("cloud-owner", "att-aic").property("resource-version", "1").next();
+ Vertex cloudRegion2 = g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region-id-2").property("cloud-owner", "att-nc").property("resource-version", "2").next();
+ Vertex cloudRegion3 = g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region-id-3").property("cloud-owner", "att-aic").property("resource-version", "7").next();
+
+ Vertex networkTech1 = g.addV().property("aai-node-type","network-technology").property("network-technology-id", "network-technology-1").property("network-technology-name", "CONTRAIL").property("resource-version", "3").next();
+ Vertex networkTech2 = g.addV().property("aai-node-type", "network-technology").property("network-technology-id", "network-technology-2").property("network-technology-name", "AIC_SR_IOV").property("resource-version", "4").next();
+ Vertex networkTech3 = g.addV().property("aai-node-type", "network-technology").property("network-technology-id", "network-technology-3").property("network-technology-name", "TEST").property("resource-version", "5").next();
+ Vertex networkTech4 = g.addV().property("aai-node-type", "network-technology").property("network-technology-id", "network-technology-4").property("network-technology-name", "OVS").property("resource-version", "8").next();
+
+
+ edgeSerializer.addEdge(g, cloudRegion1, networkTech1);
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+
+
+ migration = new MigrateNetworkTechToCloudRegion(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+
+ /*try {
+ System.out.println("containsVertexLabel :: "+graph.containsVertexLabel("cloud-region"));
+ graph.io(IoCore.graphson()).writeGraph("tinkerpop-modern.json");
+
+ try (final InputStream stream = new FileInputStream("tinkerpop-modern.json")) {
+ graph.io(IoCore.graphson()).reader().create().readGraph(stream, graph);
+ }
+
+ OutputStream out = new FileOutputStream("tinkerpop-modern.json");
+ GraphSONWriter objGraphSONWriter = new GraphSONWriter(GraphSONWriter.build());
+ objGraphSONWriter.writeGraph(out, graph);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }*/
+ }
+
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+ @Test
+ public void checkEdgeCreatedForNetworkTechnology() {
+
+ assertEquals(true,
+ g.V().has("aai-node-type", "cloud-region").has("cloud-region-id", "cloud-region-id-1")
+ .out()
+ .has("aai-node-type", "network-technology").has("network-technology-id","network-technology-2").hasNext());
+
+ assertEquals(true,
+ g.V().has("aai-node-type", "cloud-region").has("cloud-region-id", "cloud-region-id-3")
+ .out()
+ .has("aai-node-type", "network-technology").has("network-technology-id","network-technology-1").hasNext());
+
+
+ assertEquals(true,
+ g.V().has("aai-node-type", "cloud-region").has("cloud-region-id", "cloud-region-id-2")
+ .out()
+ .has("aai-node-type", "network-technology").has("network-technology-id","network-technology-4").hasNext());
+
+
+ assertEquals("Edge not created", false,
+ g.V().has("aai-node-type", "cloud-region").has("cloud-region-id", "cloud-region-id-1")
+ .out()
+ .has("aai-node-type", "network-technology").has("network-technology-id","network-technology-3").hasNext());
+
+ assertEquals("Edge not created", false,
+ g.V().has("aai-node-type", "cloud-region").has("cloud-region-id", "cloud-region-id-2")
+ .out()
+ .has("aai-node-type", "network-technology").has("network-technology-id","network-technology-1").hasNext());
+
+
+ assertEquals("Edge exists to 2 cloud regions", new Long(2L),
+ g.V().has("aai-node-type", "network-technology").has("network-technology-id", "network-technology-1")
+ .in().count().next());
+
+ /*
+ try {
+ graph.io(IoCore.graphson()).writeGraph("tinkerpop-modern.json");
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }*/
+
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/migration/v14/MigrateSameSourcedRCTROPServerDataTest.java b/src/test/java/org/onap/aai/migration/v14/MigrateSameSourcedRCTROPServerDataTest.java
new file mode 100644
index 0000000..3795dac
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v14/MigrateSameSourcedRCTROPServerDataTest.java
@@ -0,0 +1,1056 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v14;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.migration.v14.MigrateSameSourcedRCTROPserverData;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigrateSameSourcedRCTROPServerDataTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ Loader loader;
+ TransactionalGraphEngine dbEngine;
+ JanusGraph graph;
+ MigrateSameSourcedRCTROPserverData migration;
+ JanusGraphTransaction tx;
+ GraphTraversalSource g;
+ Vertex pintOld;
+ Vertex lInterfaceold;
+ Vertex pintOldRo;
+ Vertex lInterfaceoldRo;
+ Vertex pintOldRo1;
+ Vertex pintNewRo1;
+ Vertex plinkROonOldRo1;
+
+ Vertex pintOldScn3;
+ Vertex pintNewScn3;
+ Vertex pLinkOldScn3;
+ Vertex pLinkNewScn3;
+
+ Vertex pintOldScn2;
+ Vertex pintNewScn2;
+ Vertex pLinkOldScn2;
+ Vertex pintOld2Scn2;
+ Vertex sriovPfOld;
+ Vertex sriovVfOld;
+
+ Vertex lInterfaceold2;
+ Vertex pintOld2;
+
+ Vertex pLinkMoveScn2;
+ Vertex pLinkMoveScn1;
+
+ Vertex pint1ROOld;
+ Vertex pint2ROOld;
+ Vertex pint2RONew;
+ Vertex pint3ROOld;
+ Vertex pint3RONew;
+ Vertex pint1ROOldPlink;
+
+ //ManyToOne edge scenario
+ Vertex pserverRCTScn6;
+ Vertex pserverRCT1Scn6;
+ Vertex zoneScn61;
+ Vertex zoneScn62;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType,schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+//rct
+ Vertex pserverOld = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverOld")
+ .property("source-of-truth","RCT")
+ .property("fqdn","tttt.bbbb.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld")
+ .property("resource-version","1")
+ .next();
+ Vertex pserverNew = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverNew")
+ .property("source-of-truth","RCT")
+ .property("fqdn","tttt.cccc.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNew")
+ .property("resource-version","2")
+ .next();
+ pintOld = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintOld")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld")
+ .next();
+
+ lInterfaceold = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "linterfaceold")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld/l-interfaces/l-interface/linterfaceold")
+ .next();
+
+ pintOld2 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintOld2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2")
+ .next();
+ lInterfaceold2 = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "linterfaceold2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2")
+ .next();
+
+ sriovPfOld = g.addV().property("aai-node-type", "sriov-pf")
+ .property("pf-pci-id","sriovPfOld")
+ .property("source-of-truth","RCT")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2/sriov-pfs/sriov-pf/sriovPfOld")
+ .next();
+
+ sriovVfOld = g.addV().property("aai-node-type", "sriov-vf")
+ .property("pci-id","sriovVfOld")
+ .property("source-of-truth","RCT")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2/sriov-vfs/sriov-vf/sriovVfOld")
+ .next();
+
+
+
+ Vertex vserver3 = g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
+ .next();
+ Vertex lInterface3 = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "linterfaceold3")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
+ .next();
+ Vertex sriovVfOld3 = g.addV().property("aai-node-type", "sriov-vf")
+ .property("pci-id","sriovVfOld3")
+ .property("source-of-truth","RCT")
+// .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
+ .next();
+ Vertex complexOld = g.addV().property("aai-node-type", "complex")
+ .property("physical-location-id", "complexOld")
+ .property("aai-uri","/cloud-infrastructure/complex/complexOld")
+ .next();
+
+
+//ro
+ Vertex pserverRoOld = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRo.OldOne.aaaa.bbbbb")
+ .property("source-of-truth","RO")
+ .property("fqdn","aaaa.bbbb.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb")
+ .property("resource-version","1")
+ .next();
+ Vertex pserverRoNew = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRo.NewOne.aaaa.ccccccccccc")
+ .property("source-of-truth","RO")
+ .property("fqdn","aaaa.cccc.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc")
+ .property("resource-version","2")
+ .next();
+
+ Vertex pserverRo3 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRo3")
+ .property("source-of-truth","RO")
+ .property("fqdn","aaaa.cccc.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo3")
+ .property("resource-version","2")
+ .next();
+
+ Vertex pserverRo4 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRoComplexTest.aaa")
+ .property("source-of-truth","RO")
+ .property("fqdn","aaaa.cccc.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRoComplexTest.aaa")
+ .property("resource-version","2")
+ .next();
+
+ Vertex pserverRo5 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRoComplexTest.aaaaa")
+ .property("source-of-truth","RO")
+ .property("fqdn","aaaa.cccc.cccc.eeee")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRoComplexTest.aaaaa")
+ .property("resource-version","2")
+ .next();
+
+ pintOldRo = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintOldRo")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintOldRo")
+ .next();
+ lInterfaceoldRo = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "linterfaceoldRo")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintOld/l-interfaces/l-interface/linterfaceold")
+ .next();
+ Vertex complexOldRO = g.addV().property("aai-node-type", "complex")
+ .property("physical-location-id", "complexOldRO")
+ .property("aai-uri","/cloud-infrastructure/complexes/complex/vserver3")
+ .next();
+
+ pintOldRo1 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintRo1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintRo1")
+ .next();
+
+ pintNewRo1 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintRo1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintRo1")
+ .next();
+
+ plinkROonOldRo1 = g.addV()
+ .property("aai-node-type", "physical-link")
+ .property("link-name", "plinkROonOldRo1")
+ .next();
+
+ Vertex pintNew31 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintRo1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo3/p-interfaces/p-interface/pintRo1")
+ .next();
+
+ Vertex pintOld41 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintOld41")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRoComplexTest.aaa/p-interfaces/p-interface/pintOld41")
+ .next();
+
+ Vertex sriovpfOldRo1= g.addV()
+ .property("aai-node-type", "sriov-pf")
+ .property("pf-pci-id", "sriovpfOldRo1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintRo1/sriov-pfs/sriov-pf/sriovpfOldRo1")
+ .next();
+
+ //Scenario 3 same p interface name, new interface has a seprate plink
+
+ Vertex pserverOldScn3 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverOldScn3")
+ .property("source-of-truth","RCT")
+ .property("fqdn","eeee.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn3")
+ .property("resource-version","1")
+ .next();
+ Vertex pserverNewScn3= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverNewScn3")
+ .property("source-of-truth","RCT")
+ .property("fqdn","eeee.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn3")
+ .property("resource-version","2")
+ .next();
+
+ pintOldScn3= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintOldScn3")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn3/p-interfaces/p-interface/pintOldScn3")
+ .next();
+ pintNewScn3= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintNewScn3")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn3/p-interfaces/p-interface/pintNewScn3")
+ .next();
+
+ pLinkOldScn3 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkOldScn3")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
+ .next();
+ pLinkNewScn3 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkNewScn3")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
+ .next();
+
+
+
+
+
+// Scenario 2 missing plink in new pserver same pinterface name
+
+ Vertex pserverOldScn2 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverOldScn2")
+ .property("source-of-truth","RCT")
+ .property("fqdn","vvvv.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn2")
+ .property("resource-version","1")
+ .next();
+ Vertex pserverNewScn2= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverNewScn2")
+ .property("source-of-truth","RCT")
+ .property("fqdn","vvvv.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn2")
+ .property("resource-version","2")
+ .next();
+
+ pintOldScn2= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn2/p-interfaces/p-interface/pintScn2")
+ .next();
+ pintOld2Scn2= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintOld2Scn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn2/p-interfaces/p-interface/pintOld2Scn2")
+ .next();
+
+ pintNewScn2= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn2/p-interfaces/p-interface/pintScn2")
+ .next();
+
+ pLinkOldScn2 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkOldScn2")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
+ .next();
+
+// Scnario 2 RCT Pinter face match moving plink and updating the name
+ Vertex pserver1Scn2 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver1Scn2")
+ .property("source-of-truth","RCT")
+ .property("fqdn","same.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn2")
+ .property("resource-version","1")
+ .next();
+ Vertex pserver2Scn2= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver2Scn2")
+ .property("source-of-truth","RCT")
+ .property("fqdn","same.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2Scn2")
+ .property("resource-version","2")
+ .next();
+ Vertex pserver3Scn2= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver3Scn2")
+ .property("source-of-truth","RCT")
+ .property("fqdn","jkkdahfkjashf.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn2")
+ .property("resource-version","2")
+ .next();
+
+
+ Vertex pint1Scn2= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint1Scn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn2/p-interfaces/p-interface/pint1Scn2")
+ .next();
+ Vertex pint2NewScn2= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint1Scn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2Scn2/p-interfaces/p-interface/pint1Scn2")
+ .next();
+ Vertex pint3Scn2= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint3Scn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn2/p-interfaces/p-interface/pint3Scn2")
+ .next();
+
+ pLinkMoveScn2= g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pserver1Scn2:pint1Scn2|pserver3Scn2:pint3Scn2")
+ .property("aai-uri","/cloud-infrastructure/plink/pLinkMoveScn2")
+ .next();
+
+
+// Scenario 1 RCT plink name change move everything from old pserver to new pserver, new pserver has no plink
+ Vertex pserver1Scn1 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver1Scn1")
+ .property("source-of-truth","RCT")
+ .property("fqdn","sameScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn1")
+ .property("resource-version","1")
+ .next();
+ Vertex pserver2Scn1= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver2Scn1")
+ .property("source-of-truth","RCT")
+ .property("fqdn","sameScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2Scn1")
+ .property("resource-version","2")
+ .next();
+ Vertex pserver3Scn1= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver3Scn1")
+ .property("source-of-truth","RCT")
+ .property("fqdn","jkkdahfkjashf.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn1")
+ .property("resource-version","2")
+ .next();
+
+
+ Vertex pint1Scn1= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint1Scn1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn1/p-interfaces/p-interface/pint1Scn1")
+ .next();
+
+ Vertex pint3Scn1= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint3Scn1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn1/p-interfaces/p-interface/pint3Scn1")
+ .next();
+
+
+ pLinkMoveScn1= g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pserver1Scn1:pint1Scn1|pserver3Scn1:pint3Scn1")
+ .property("aai-uri","/cloud-infrastructure/plink/pLinkMoveScn1")
+ .next();
+
+
+ //Scnario 2 RCT Pinter face match moving plink and updating the name
+ edgeSerializer.addTreeEdge(g,pserver1Scn2,pint1Scn2);
+
+ edgeSerializer.addTreeEdge(g,pserver2Scn2,pint2NewScn2);
+
+ edgeSerializer.addTreeEdge(g,pserver3Scn2,pint3Scn2);
+
+ edgeSerializer.addEdge(g,pint1Scn2,pLinkMoveScn2);
+ edgeSerializer.addEdge(g,pint3Scn2,pLinkMoveScn2);
+
+
+ // Scenario 1 RCT plink name change move everything from old pserver to new pserver, new pserver has no plink
+ edgeSerializer.addTreeEdge(g, pserver1Scn1,pint1Scn1);
+ edgeSerializer.addTreeEdge(g, pserver3Scn1,pint3Scn1);
+
+ edgeSerializer.addEdge(g,pint1Scn1,pLinkMoveScn1);
+ edgeSerializer.addEdge(g,pint3Scn1,pLinkMoveScn1);
+
+
+//RCT
+ edgeSerializer.addTreeEdge(g, pserverOld,pintOld);
+ edgeSerializer.addTreeEdge(g, pintOld,lInterfaceold);
+// rules.addTreeEdge(g, pintOld,sriovPfOld);
+// rules.addTreeEdge(g, lInterfaceold,sriovVfOld);
+
+ edgeSerializer.addTreeEdge(g, pserverOld,pintOld2);
+ edgeSerializer.addTreeEdge(g, pintOld2,lInterfaceold2);
+ edgeSerializer.addTreeEdge(g, pintOld2,sriovPfOld);
+ edgeSerializer.addTreeEdge(g, sriovVfOld,lInterfaceold2);
+
+ edgeSerializer.addTreeEdge(g,vserver3,lInterface3);
+ edgeSerializer.addTreeEdge(g,lInterface3,sriovVfOld3);
+
+ edgeSerializer.addEdge(g,sriovPfOld,sriovVfOld3);
+ edgeSerializer.addEdge(g,pserverOld,complexOld);
+
+
+
+//ro
+ edgeSerializer.addTreeEdge(g,pserverRoOld,pintOldRo);
+ edgeSerializer.addTreeEdge(g,pintOldRo,lInterfaceoldRo);
+ edgeSerializer.addEdge(g,pserverRoOld,complexOldRO);
+ edgeSerializer.addTreeEdge(g,pserverRoOld, pintOldRo1);
+ edgeSerializer.addTreeEdge(g,pserverRoNew, pintNewRo1);
+ edgeSerializer.addEdge(g, pintOldRo1, plinkROonOldRo1);
+
+ edgeSerializer.addTreeEdge(g, pserverRo3, pintNew31);
+ edgeSerializer.addEdge(g, pintNew31, plinkROonOldRo1);
+
+ edgeSerializer.addTreeEdge(g, pserverRo4, pintOld41);
+
+ edgeSerializer.addTreeEdge(g, pintOldRo1, sriovpfOldRo1);
+
+
+ // physical-link tests
+ //1. p-int does not exist on longer hostname RO, p-int and p-link moves from shorter to longer
+ pint1ROOld= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint1ROOld")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pint1ROOld")
+ .next();
+
+ Vertex pLink1ROOld = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLink1ROOld")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .next();
+ edgeSerializer.addTreeEdge(g,pserverRoOld,pint1ROOld);
+ edgeSerializer.addEdge(g,pint1ROOld,pLink1ROOld);
+
+ //2. p-int matches on shorter and longer hostname ROP pservers, p-link does not exist on longer RO. p-link moves from shorter to longer hostname
+ pint2ROOld= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint2RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pint2RO")
+ .next();
+
+ Vertex pLink2ROOld = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLink2ROOld")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .next();
+
+ pint2RONew= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint2RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint2RO")
+ .next();
+
+ edgeSerializer.addTreeEdge(g,pserverRoOld,pint2ROOld);
+ edgeSerializer.addEdge(g,pint2ROOld,pLink2ROOld);
+ edgeSerializer.addTreeEdge(g,pserverRoNew,pint2RONew);
+
+ //3. p-int matches on shorter and longer hostname ROP pservers, p-link exists on both, no change in plink or p-int on longer
+ pint3ROOld= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint3RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pint3RO")
+ .next();
+
+ Vertex pLink3ROOld = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLink3ROOld")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .next();
+
+ pint3RONew= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint3RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint3RO")
+ .next();
+
+ Vertex pLink3RONew = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLink3RONew")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .next();
+
+ edgeSerializer.addTreeEdge(g,pserverRoOld,pint3ROOld);
+ edgeSerializer.addEdge(g,pint3ROOld,pLink3ROOld);
+ edgeSerializer.addTreeEdge(g,pserverRoNew,pint3RONew);
+ edgeSerializer.addEdge(g,pint3RONew,pLink3RONew);
+ //End physical-links tests
+
+
+//sc3
+ edgeSerializer.addTreeEdge(g,pserverOldScn3,pintOldScn3);
+ edgeSerializer.addTreeEdge(g,pserverNewScn3,pintNewScn3);
+ edgeSerializer.addEdge(g,pintNewScn3,pLinkNewScn3);
+ edgeSerializer.addEdge(g,pintOldScn3,pLinkOldScn3);
+
+//sc2
+ edgeSerializer.addTreeEdge(g,pserverOldScn2,pintOldScn2);
+ edgeSerializer.addTreeEdge(g,pserverOldScn2,pintOld2Scn2);
+ edgeSerializer.addTreeEdge(g,pserverNewScn2,pintNewScn2);
+ edgeSerializer.addEdge(g,pintOldScn2,pLinkOldScn2);
+
+//RCT fqdn not set new tests
+
+ Vertex rctP1 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","rctP1")
+ .property("source-of-truth","RCT")
+ .property("fqdn","sameFqdnScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1")
+ .property("resource-version","1")
+ .next();
+
+ // Don't throw null pointer with fqdn not set
+ Vertex rctP2 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","rctP2")
+ .property("source-of-truth","RCT")
+// .property("fqdn","sameScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2")
+ .property("resource-version","2")
+ .next();
+
+ Vertex rctP3 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","rctP3")
+ .property("source-of-truth","RCT")
+ .property("fqdn","sameFqdnScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3")
+ .property("resource-version","3")
+ .next();
+
+ Vertex rctP4 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","rctP4")
+ .property("source-of-truth","RCT")
+ .property("fqdn","")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP4")
+ .property("resource-version","4")
+ .next();
+
+ Vertex rctP5 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","rctP5")
+ .property("source-of-truth","RCT")
+ .property("fqdn","")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP5")
+ .property("resource-version","5")
+ .next();
+
+ //pint11 does not have a match on rctP3. So, expect this to move to rctP3. Add test
+ Vertex pint11= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint11")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint11")
+ .next();
+
+ // matching interface-name on pint12 and pint31. Delete pint12. Don't move it to rctP3. Add test
+ //interface-name matches b/w vertices pint12 and pint31
+ Vertex pint12= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint12")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint12")
+ .next();
+
+ //int-name on pint31 is same as pint12
+ Vertex pint31= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint12")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/p-interfaces/p-interface/pint12")
+ .next();
+ //End matching interface-name on pint12 and pint31. Delete pint12. Don't move it to rctP3.
+
+
+ // Plink exists on both matching pints. Delete old pint, old plink, and edge b/w them - add test
+ // Vertex pint23 has physical link connected to pint14
+ Vertex pint14= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint14")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint14")
+ .next();
+ Vertex pint23= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint3RCTFqdn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2/p-interfaces/p-interface/pint23")
+ .next();
+ Vertex plink1423 = g.addV()
+ .property("aai-node-type", "physical-link")
+ .property("link-name", "rctP1:pint14|rctP2:pint23")
+ .property("aai-uri","/network/physical-links/physical-link/plink1423")
+ .next();
+
+ // Vertex pint24 has physical link connected to pint33 (Plink exists on both old and new p-int, no change)
+ // Vertex pint33 has same interface-name as pint14
+ Vertex pint33= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint14")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pint33/p-interfaces/p-interface/pint14")
+ .next();
+ Vertex pint24= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint24")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2/p-interfaces/p-interface/pint24")
+ .next();
+ Vertex plink2433 = g.addV()
+ .property("aai-node-type", "physical-link")
+ .property("link-name", "rctP2:pint24|rctP3:pint14")
+ .property("aai-uri","/network/physical-links/physical-link/plinkFqdn2443")
+ .next();
+ // End Plink exists on both matching pints. Delete old pint, old plink, and edge b/w them - add test
+
+ Vertex pint41= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pserver1RCTFqdn4")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1RCTFqdn4/p-interfaces/p-interface/pserver1RCTFqdn4")
+ .next();
+
+ Vertex pint51= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pserver1RCTFqdn5")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1RCTFqdn4/p-interfaces/p-interface/pserver1RCTFqdn5")
+ .next();
+
+ //Case physical link moves from pint13 on rctP1 to pint32 on rctP3 since latest pserver does not have plink - Add test
+ //Vertex pint13 has plink connected to pint21
+ Vertex pint21= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint21")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2/p-interfaces/p-interface/pint21")
+ .next();
+ Vertex pint13= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint13")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint13")
+ .next();
+ Vertex plink1321 = g.addV()
+ .property("aai-node-type", "physical-link")
+ .property("link-name", "rctP1:pint13|rctP2:pint21")
+ .property("aai-uri","/network/physical-links/physical-link/plink1321")
+ .next();
+
+ //int-name on pint32 is same pint13
+ Vertex pint32= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pint13")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/p-interfaces/p-interface/pint13")
+ .next();
+
+ edgeSerializer.addTreeEdge(g,rctP1,pint13);
+ edgeSerializer.addTreeEdge(g,rctP2,pint21);
+ edgeSerializer.addTreeEdge(g, rctP3, pint32);
+ edgeSerializer.addEdge(g, plink1321, pint13);
+ edgeSerializer.addEdge(g, plink1321, pint21);
+
+ // End Case physical link moves from pint13 on rctP1 to pint32 on rctP3 since latest pserver does not have plink
+
+
+ edgeSerializer.addTreeEdge(g,rctP1,pint11);
+ edgeSerializer.addTreeEdge(g,rctP1,pint12);
+ edgeSerializer.addTreeEdge(g,rctP3,pint31);
+ edgeSerializer.addTreeEdge(g,rctP3,pint33);
+ edgeSerializer.addTreeEdge(g,rctP4,pint41);
+ edgeSerializer.addTreeEdge(g,rctP5,pint51);
+
+ edgeSerializer.addTreeEdge(g, rctP2, pint23);
+ edgeSerializer.addTreeEdge(g, rctP1, pint14);
+ edgeSerializer.addTreeEdge(g, rctP2, pint24);
+
+
+ edgeSerializer.addEdge(g, plink1423, pint14);
+ edgeSerializer.addEdge(g, plink1423, pint23);
+
+ edgeSerializer.addEdge(g, plink2433, pint24);
+ edgeSerializer.addEdge(g, plink2433, pint33);
+
+ //lag-interfaces
+ //lagint11 does not have a match on rctP3. So, expect this to move to rctP3. Add test
+ Vertex lagint11= g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lagint11")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint11")
+ .next();
+ edgeSerializer.addTreeEdge(g, rctP1, lagint11);
+
+ //lagint12 matches with lagint31 on rctP3
+ Vertex lagint12= g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lagint12")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint12")
+ .next();
+ Vertex lagint31= g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lagint12")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/lag-interfaces/lag-interface/lagint12")
+ .next();
+ edgeSerializer.addTreeEdge(g, rctP1, lagint12);
+ edgeSerializer.addTreeEdge(g, rctP3, lagint31);
+
+ //Verify manytoOne edge scenario
+ pserverRCTScn6 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRCTScn6")
+ .property("source-of-truth","RCT")
+ .property("fqdn","Scn6.pserverRCTScn6")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn6")
+ .property("resource-version","1")
+ .next();
+
+ zoneScn61 = g.addV().property("aai-node-type", "zone")
+ .property("zone-id", "zone-61")
+ .next();
+
+ pserverRCT1Scn6 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","Scn6.pserverRCT1Scn6")
+ .property("source-of-truth","RCT")
+ .property("fqdn","Scn6.pserverRCT1Scn6")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCT1Scn6")
+ .property("resource-version","4")
+ .next();
+
+ zoneScn62 = g.addV().property("aai-node-type", "zone")
+ .property("zone-id", "zone-62")
+ .next();
+
+ edgeSerializer.addEdge(g, pserverRCTScn6, zoneScn61);
+ edgeSerializer.addEdge(g, pserverRCT1Scn6, zoneScn62);
+
+ //Verify manyToMany edge scenario
+ Vertex gvnf1 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnf-1")
+ .next();
+
+ Vertex gvnf2 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnf-2")
+ .next();
+
+ edgeSerializer.addEdge(g, pserverRCTScn6, gvnf1);
+ edgeSerializer.addEdge(g, pserverRCT1Scn6, gvnf2);
+
+
+ // Empty string first token test
+ Vertex pserver1EmptyFirstToken = g.addV().property("aai-node-type", "pserver")
+ .property("hostname",".pserver1EmptyFirstToken")
+ .property("source-of-truth","RO")
+ .property("fqdn","sameScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/.pserver1EmptyFirstToken")
+ .property("resource-version","1")
+ .next();
+ Vertex pserver2EmptyFirstToken= g.addV().property("aai-node-type", "pserver")
+ .property("hostname",".pserver2EmptyFirstToken.1")
+ .property("source-of-truth","RO")
+ .property("fqdn","sameScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/.pserver2EmptyFirstToken")
+ .property("resource-version","2")
+ .next();
+
+ Vertex pserver1EmptyFirstTokenFqdn = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver1EmptyFirstTokenFqdn")
+ .property("source-of-truth","RCT")
+ .property("fqdn",".rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1EmptyFirstTokenFqdn")
+ .property("resource-version","1")
+ .next();
+ Vertex pserver2EmptyFirstTokenFqdn= g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver2EmptyFirstTokenFqdn")
+ .property("source-of-truth","RCT")
+ .property("fqdn",".rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2EmptyFirstTokenFqdn")
+ .property("resource-version","2")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateSameSourcedRCTROPserverData(spy,loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Test
+ public void RCT() throws Exception {
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverNew").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld", pintOld.property("aai-uri").value().toString());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld/l-interfaces/l-interface/linterfaceold", lInterfaceold.property("aai-uri").value().toString());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2", lInterfaceold2.property("aai-uri").value().toString());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld2/sriov-pfs/sriov-pf/sriovPfOld",sriovPfOld.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "sriov-pf").has("pf-pci-id","sriovPfOld").in("org.onap.relationships.inventory.Uses").has("aai-node-type","sriov-vf").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2/sriov-vfs/sriov-vf/sriovVfOld",sriovVfOld.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverNew").out("org.onap.relationships.inventory.LocatedIn").has("aai-node-type","complex").hasNext());
+
+ }
+ @Test
+ public void RO() throws Exception {
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pintOldRo").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintOldRo", pintOldRo.property("aai-uri").value().toString());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintOldRo/l-interfaces/l-interface/linterfaceoldRo", lInterfaceoldRo.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").out("org.onap.relationships.inventory.LocatedIn").has("aai-node-type","complex").hasNext());
+// System.out.println("************** SRIOV-PF *************"+g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
+// .has("aai-node-type","p-interface").has("interface-name","pintRo1").in().has("aai-node-type", "sriov-pf").toList().get(0).property("pf-pci-id").value().toString());
+ assertEquals(true, g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintRo1").in().has("aai-node-type", "sriov-pf").hasNext());
+ //.has("pf-pci-id","sriovpfOldRo1")
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintRo1/sriov-pfs/sriov-pf/sriovpfOldRo1",
+ g.V().has("aai-node-type","sriov-pf").has("pf-pci-id","sriovpfOldRo1").toList().get(0).property("aai-uri").value().toString());
+ assertNotEquals("/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintRo1/sriov-pfs/sriov-pf/sriovpfOldRo1",
+ g.V().has("aai-node-type","sriov-pf").has("pf-pci-id","sriovpfOldRo1").toList().get(0).property("aai-uri").value().toString());
+ }
+
+ @Test
+ public void RCTplinkScenario3() throws Exception {
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverNewplink").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").out("tosca.relationships.network.LinksTo").has("aai-node-type","physical-link").has("link-name","pLinkOld").hasNext());
+
+ }
+
+ @Test
+ public void RCTpLinkMoveScn2NameChange() throws Exception {
+ assertEquals("pserver2Scn2:pint1Scn2|pserver3Scn2:pint3Scn2", pLinkMoveScn2.property("link-name").value().toString());
+
+ }
+
+ @Test
+ public void RCTpLinkMoveScn1NameChange() throws Exception {
+ assertEquals("pserver2Scn1:pint1Scn1|pserver3Scn1:pint3Scn1", pLinkMoveScn1.property("link-name").value().toString());
+
+ }
+
+ @Test
+ public void RCTplinkScenario2() throws Exception {
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverNewScn2").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").out("tosca.relationships.network.LinksTo").has("aai-node-type","physical-link").has("link-name","pLinkOldScn2").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverNewScn2/p-interfaces/p-interface/pintOld2Scn2", pintOld2Scn2.property("aai-uri").value().toString());
+
+ }
+
+ @Test
+ public void roSuccessfulMovePlinkScn1() throws Exception {
+ assertEquals("aaaa.cccc.cccc.dddd",g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").next().value("fqdn").toString());
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("pserverRo.OldOne.aaaa.bbbbb").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pint1ROOld").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint1ROOld", pint1ROOld.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint1ROOld").out("tosca.relationships.network.LinksTo").has("link-name","pLink1ROOld").hasNext());
+ }
+
+ @Test
+ public void roSuccessfulSamePIntScn() throws Exception {
+ assertEquals("aaaa.cccc.cccc.dddd",g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").next().value("fqdn").toString());
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("pserverRo.OldOne.aaaa.bbbbb").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pint2RO").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint2RO", pint2RONew.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint2RO").out("tosca.relationships.network.LinksTo").has("link-name","pLink2ROOld").hasNext());
+ }
+
+ @Test
+ public void roSuccessfulSamePIntScnPlinkExistsOnBoth() throws Exception {
+ assertEquals("aaaa.cccc.cccc.dddd",g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").next().value("fqdn").toString());
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("pserverRo.OldOne.aaaa.bbbbb").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pint3RO").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint3RO", pint3RONew.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint3RO").out("tosca.relationships.network.LinksTo").has("link-name","pLink3RONew").hasNext());
+ }
+
+ @Test
+ public void RCThandleNullFqdnSamePints() throws Exception {
+ //1. pint11 from rctP1 moves to rctP3
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint11").hasNext());
+ assertEquals(false, g.V().has("aai-node-type", "p-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint11").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "p-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/p-interfaces/p-interface/pint11").hasNext());
+
+ //2. pint12 int-name matches with pint31. So, verify that p-int does not move from rctP1 to rctP3
+ assertEquals("rctP3 has only 1 pint with name pint12", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint12").count().next());
+
+ //3. Verify that the p-interface from pserver is not moved to another pserver that has null fqdn
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","rctP2").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint11").hasNext());
+
+ //4. If the fqdn is "" within 2 RCT pservers, ignore that case. Don't move the p-int from old resource-version to new resource-version pserver
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","rctP5").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint41").hasNext());
+ assertEquals("rctP5 has only 1 p-interface", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP5").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").count().next());
+
+ //5. plink is moved from pint3 on pserver fqdn1 to pint2 on pserver fqdn3. Both p-ints have the same interface-name
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint13").out().has("aai-node-type", "physical-link").hasNext());
+ System.out.println("plink on pint13 is "+ g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pint13").out().has("aai-node-type", "physical-link").next().property("link-name").value().toString());
+
+ assertEquals(true, g.V().has("aai-node-type","physical-link").has("link-name","rctP2:pint21|rctP3:pint13").hasNext());
+
+ //6. plink is not moved from pint4 on pserver fqdn1 to pint3 on pserver fqdn3. Both p-ints have the same interface-name
+ assertEquals(true, g.V().has("aai-node-type","physical-link").has("link-name","rctP2:pint24|rctP3:pint14").hasNext());
+ assertEquals(false, g.V().has("aai-node-type","physical-link").has("link-name","rctP1:pint14|rctP2:pint23").hasNext());
+
+ }
+
+ @Test
+ public void testRCTLagInterfaces() throws Exception {
+ //1. lagint11 from rctP1 moves to rctP3
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","lag-interface").has("interface-name","lagint11").hasNext());
+ assertEquals(false, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint11").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/lag-interfaces/lag-interface/lagint11").hasNext());
+
+
+ //2. lagint12 int-name matches with lagint31. So, verify that lag-int does not move from rctP1 to rctP3
+ assertEquals("rctP3 has only 1 lag-interface with name lagint12", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","lag-interface").has("interface-name","lagint12").count().next());
+
+ }
+
+ @Test
+ public void checkRCTPserverHasRelnToOnly1Zone() throws Exception {
+
+ assertEquals("Edge to only 1 Zone exists", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","Scn6.pserverRCT1Scn6").out("org.onap.relationships.inventory.LocatedIn")
+ .has("aai-node-type","zone").count().next());
+ assertEquals(true, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").hasNext());
+ //Verify no edge exists from zone61 to lower resource-version RCT pserver
+ assertEquals(false, g.V().has("aai-node-type", "zone").has("zone-id","zone-61").in().has("aai-node-type", "pserver").hasNext());
+ }
+
+ @Test
+ public void checkRCTPserverHasRelnTo2GenericVnfs() throws Exception {
+
+ assertEquals("Edge to 2 generic-vnfs exists", new Long(2L), g.V().has("aai-node-type", "pserver").has("hostname","Scn6.pserverRCT1Scn6").in("tosca.relationships.HostedOn")
+ .has("aai-node-type","generic-vnf").count().next());
+ assertEquals(true, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-1").out().has("aai-node-type", "pserver").has("hostname", "Scn6.pserverRCT1Scn6").hasNext());
+ //Verify no edge exists from vnf-1 to lower resource-version pserver
+ assertEquals(false, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-1").out().has("aai-node-type", "pserver").has("hostname", "Scn6.pserverRCTScn6").hasNext());
+ }
+
+ @Test
+ public void roPlinkNewMovesToLongerHostNameROPserver() throws Exception {
+
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pintOldRo1").hasNext());
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.OldOne.aaaa.bbbbb").hasNext());
+ assertEquals(false, g.V().has("id", "pintOldRo1").hasNext());
+ //Verify that the physical link moves to the new pserver
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintRo1").out().has("link-name","plinkROonOldRo1").hasNext());
+ //Verify complex does not get attached to pserverRO5
+ assertEquals("Complex is related to only 1 pserver", new Long(1L), g.V().has("physical-location-id", "complexOldRO").in("org.onap.relationships.inventory.LocatedIn").count().next());
+ }
+
+ @Test
+ public void ignoreEmptyStringFirstTokenFqdn() throws Exception {
+ List<Vertex> pserverList = g.V().has("aai-node-type", "pserver").has("hostname").toList();
+ pserverList.forEach(v ->System.out.println(v.property("hostname").value().toString()));
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserver1EmptyFirstTokenFqdn").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname",".pserver1EmptyFirstToken").hasNext());
+
+
+ System.out.println(UUID.randomUUID().toString());
+ System.out.println(UUID.randomUUID().toString());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/migration/v14/MigrateSdnaIvlanDataTest.java b/src/test/java/org/onap/aai/migration/v14/MigrateSdnaIvlanDataTest.java
new file mode 100644
index 0000000..c7b11b9
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v14/MigrateSdnaIvlanDataTest.java
@@ -0,0 +1,283 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v14;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+public class MigrateSdnaIvlanDataTest extends AAISetup {
+
+ private final String CONFIGURATION_NODE_TYPE = "configuration";
+ private final String EVC_NODE_TYPE = "evc";
+ private final String FORWARDER_NODE_TYPE = "forwarder";
+ private final String FORWRDER_EVC_NODE_TYPE = "forwarder-evc";
+ private final String FORWARDING_PATH_NODE_TYPE = "forwarding-path";
+ private final String LAG_INTERFACE_NODE_TYPE = "lag-interface";
+ private final String P_INTERFACE_NODE_TYPE = "p-interface";
+ private final String PNF_NODE_TYPE = "pnf";
+ private final String SERVICE_INSTANCE_NODE_TYPE = "service-instance";
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigrateSdnaIvlanData migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ //PNF - pnf1
+ Vertex pnf1 = g.addV()
+ .property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf1")
+ .next();
+
+ //P-INTERFACE - "11111.1"
+ Vertex pInterface1 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "11111.1")
+ .next();
+
+ //LAG-INTERFACE - lag-interface1
+ Vertex lagInterface1 = g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lag-interface1")
+ .next();
+
+ //CONFIGURATION - "test/evc/one"
+ Vertex configuration1 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "test/evc/one")
+ .next();
+
+ //CONFIGURATION - "test/evc/one-1"
+ Vertex configuration1_1 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "test/evc/one-1")
+ .next();
+ //CONFIGURATION - "test/evc/one-2"
+ Vertex configuration1_2 = g.addV()
+ .property("aai-node-type", "configuration")
+ .property("configuration-id", "test/evc/one-2")
+ .next();
+
+ //FORWARDER - "test/evc/one" sequence 1
+ Vertex forwarder1_1 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", 1)
+ .property("forwarder-role", "ingress")
+ .next();
+
+ //FORWARDER - "test/evc/one" sequence 2
+ Vertex forwarder1_2 = g.addV()
+ .property("aai-node-type", "forwarder")
+ .property("sequence", 2)
+ .property("forwarder-role", "ingress")
+ .next();
+
+ //FORWARDING-PATH - "test/evc/one"
+ Vertex forwardingPath1 = g.addV()
+ .property("aai-node-type", "forwarding-path")
+ .property("forwarding-path-id", "test/evc/one")
+ .property("forwarding-path-name", "test/evc/one")
+ .next();
+
+ //EVC - "test/evc/one"
+ Vertex evc = g.addV()
+ .property("aai-node-type", "evc")
+ .property("evc-id", "test/evc/one")
+ .next();
+
+ //FORWARDER-EVC - "test/evc/one-1"
+ Vertex fwdEvc1_1 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "test/evc/one-1")
+ .next();
+
+ //FORWARDER-EVC - "test/evc/one-2"
+ Vertex fwdEvc1_2 = g.addV()
+ .property("aai-node-type", "forwarder-evc")
+ .property("forwarder-evc-id", "test/evc/one-2")
+ .next();
+
+ //pnf -> p-interface -> forwarder -> configuration -> forwarder-evc
+ //pnf1 -> pInterface1 -> forwarder1_1 -> configuration1_1 -> fwdEvc1_1
+ edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
+ edgeSerializer.addEdge(g, pInterface1,forwarder1_1);
+ edgeSerializer.addEdge(g, forwarder1_1, configuration1_1);
+
+ edgeSerializer.addEdge(g, forwardingPath1, configuration1);
+ edgeSerializer.addTreeEdge(g, forwarder1_1, forwardingPath1);
+ edgeSerializer.addTreeEdge(g, forwarder1_2, forwardingPath1);
+
+ edgeSerializer.addTreeEdge(g, configuration1_1, fwdEvc1_1);
+
+ //pnf -> lag-interface -> forwarder -> configuration -> forwarder-evc
+ //pnf1 -> lagInterface1 -> forwarder1_2 -> configuration1_2 -> fwdEvc1_2
+ edgeSerializer.addTreeEdge(g, pnf1, lagInterface1);
+ edgeSerializer.addEdge(g, forwarder1_2, configuration1_2);
+ edgeSerializer.addEdge(g, lagInterface1, forwarder1_2);
+ edgeSerializer.addTreeEdge(g, configuration1_2, fwdEvc1_2);
+
+
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateSdnaIvlanData(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+
+ }
+
+ @Test
+ public void testSdnaIvlanMigration() {
+
+ assertTrue("Value of node-type forwarder-evc, forwarder-evc-id of test/evc/one-1 has ben updated with the ivlan property value of 111 ",
+ g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf1")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, P_INTERFACE_NODE_TYPE).has("interface-name", "11111.1")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/one"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "111").hasNext());
+
+ assertTrue("Value of node-type forwarder-evc, forwarder-evc-id of test/evc/one-2 has ben updated with the ivlan property value of 222 ",
+ g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf1")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, LAG_INTERFACE_NODE_TYPE).has("interface-name", "lag-interface1")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/one"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "222").hasNext());
+
+ assertTrue("Value of node-type P-INTERFACE with an interface-name of l11111.2 does not exist in Graph. Ivlan not Updated ",
+ !g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf1")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, P_INTERFACE_NODE_TYPE).has("interface-name", "11111.2")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/one"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "333").hasNext());
+
+ assertTrue("Value of node-type LAG-INTERFACE with an interface-name of lag-interface2 does not exist in Graph. Ivlan not Updated ",
+ !g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf1")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, LAG_INTERFACE_NODE_TYPE).has("interface-name", "lag-interface2")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/one"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "444").hasNext());
+
+
+ assertTrue("Value of node-type P-INTERFACE with an interface-name of 11111.3 and evc of test/evc/one_2 does not exist in Graph. Ivlan not Updated ",
+ !g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf1")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, P_INTERFACE_NODE_TYPE).has("interface-name", "11111.3")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/one_2"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "555").hasNext());
+
+ assertTrue("Value of node-type LAG-INTERFACE with an interface-name of lag-interface3 and evc of test/evc/one_2 does not exist in Graph. Ivlan not Updated ",
+ !g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf1")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, LAG_INTERFACE_NODE_TYPE).has("interface-name", "lag-interface3")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/one_2"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "666").hasNext());
+
+ assertTrue("Value of node-type PNF with an pnf-name of pnf2 does not exist in Graph. Ivlan not Updated ",
+ !g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf2")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, P_INTERFACE_NODE_TYPE).has("interface-name", "22222.2")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/two"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "777").hasNext());
+
+ assertTrue("Value of node-type PNF with an pnf-name of pnf2 does not exist in Graph. Ivlan not Updated ",
+ !g.V()
+ .has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).has("pnf-name", "pnf2")
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, LAG_INTERFACE_NODE_TYPE).has("interface-name", "lag-interface2")
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", "test/evc/two"))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo")
+ .has("ivlan", "888").hasNext());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruthTest.java b/src/test/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruthTest.java
new file mode 100644
index 0000000..a541eca
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruthTest.java
@@ -0,0 +1,496 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v14;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class PserverDedupWithDifferentSourcesOfTruthTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ Loader loader;
+ TransactionalGraphEngine dbEngine;
+ JanusGraph graph;
+ PserverDedupWithDifferentSourcesOfTruth migration;
+ JanusGraphTransaction tx;
+ GraphTraversalSource g;
+
+//scn1
+ Vertex pIntRo;
+ Vertex lInterfaceRo;
+ Vertex pserverRCT;
+ Vertex complexRO;
+//scn2
+
+ Vertex pserverRCTScn2;
+ Vertex pIntRoScn2;
+ Vertex lInterfaceRoScn2;
+ Vertex complexROScn2;
+ Vertex lInterfaceRctScn2;
+ Vertex pIntRctScn2;
+ Vertex complexRctScn2;
+
+ //physical link
+ Vertex pintPlinkScn1;
+ Vertex samePintScn4RO;
+ Vertex samePintScn4RCT;
+ Vertex pserverRCTPlinkScn4;
+
+ //Scn3
+ Vertex pserverRCTScn3;
+ Vertex complexScn3;
+ Vertex pserverROScn3;
+
+ //ManyToOne edge scenario
+ Vertex pserverRCTScn6;
+ Vertex pserverROScn6;
+ Vertex zoneScn61;
+ Vertex zoneScn62;
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType,schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+//Scn1 empty RCT move everything over
+ pserverRCT = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRCT")
+ .property("source-of-truth","RCT")
+ .property("fqdn","tttt.bbbb.cccc.dddd")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCT")
+ .property("resource-version","1")
+ .next();
+
+ Vertex pserverRO = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","tttt.RoHostname")
+ .property("source-of-truth","RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname")
+ .property("resource-version","2")
+ .next();
+ pIntRo = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pIntRo")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pIntRo")
+ .next();
+ lInterfaceRo = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "lInterfaceRo")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pIntRo/l-interfaces/l-interface/lInterfaceRo")
+ .next();
+ complexRO = g.addV().property("aai-node-type", "complex")
+ .property("physical-location-id","complexRO")
+ .property("aai-uri","/cloud-infrastructure/complexes/complex/complexRO")
+ .next();
+
+ // physical-link tests
+ //1. p-int does not exist on RCT, p-int and p-link moves from RO to RCT
+ pintPlinkScn1= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintPlinkScn1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pintPlinkScn1")
+ .next();
+
+ Vertex pLinkScn1 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "pLinkScn1")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("aai-uri","/network/physical-links/physical-link/pLinkScn1")
+ .next();
+ edgeSerializer.addTreeEdge(g,pserverRO,pintPlinkScn1);
+ edgeSerializer.addEdge(g,pintPlinkScn1,pLinkScn1);
+
+ //2. p-int matches on RCT, p-int and p-link don't move from RO to RCT
+
+ Vertex pserverROSPlinkScn4 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","Scn4.pserverROSPlinkScn4")
+ .property("source-of-truth","RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn4.pserverROSPlinkScn4")
+ .property("resource-version","4")
+ .next();
+
+ pserverRCTPlinkScn4 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRCTPlinkScn4")
+ .property("source-of-truth","RCT")
+ .property("fqdn","Scn4.pserverRCTPlinkScn4")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4")
+ .property("resource-version","3")
+ .next();
+
+ samePintScn4RO= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintPlinkScn4")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn4.pserverROSPlinkScn4/p-interfaces/p-interface/pintPlinkScn4")
+ .next();
+
+ Vertex plinkScn2 = g.addV().property("aai-node-type", "physical-link")
+ .property("link-name", "plinkScn2")
+ .property("service-provider-bandwidth-up-value", 0)
+ .property("service-provider-bandwidth-up-units", "empty")
+ .property("service-provider-bandwidth-down-value", 0)
+ .property("service-provider-bandwidth-down-units", "empty")
+ .property("aai-uri","/network/physical-links/physical-link/pLinkScn2")
+ .next();
+
+ samePintScn4RCT= g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pintPlinkScn4")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4/p-interfaces/p-interface/pintPlinkScn4")
+ .next();
+
+ edgeSerializer.addTreeEdge(g,pserverROSPlinkScn4,samePintScn4RO);
+ edgeSerializer.addEdge(g,samePintScn4RO,plinkScn2);
+ edgeSerializer.addTreeEdge(g,pserverRCTPlinkScn4,samePintScn4RCT);
+ //End physical-links tests
+
+//Scn2 RCT has children already
+
+ pserverRCTScn2 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRCTScn2")
+ .property("source-of-truth","RCT")
+ .property("fqdn","Scn2.pserverRCTScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2")
+ .property("resource-version","3")
+ .next();
+ pIntRctScn2 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pIntRctScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRctScn2")
+ .next();
+ lInterfaceRctScn2 = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "lInterfaceRctScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRctScn2/l-interfaces/l-interface/lInterfaceRctScn2")
+ .next();
+ complexRctScn2 = g.addV().property("aai-node-type", "complex")
+ .property("physical-location-id","complexRctScn2")
+ .property("aai-uri","/cloud-infrastructure/complexes/complex/complexRctScn2")
+ .next();
+ Vertex pserverROScn2 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","Scn2.pserverROScn2")
+ .property("source-of-truth","RO")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2")
+ .property("resource-version","4")
+ .next();
+ pIntRoScn2 = g.addV()
+ .property("aai-node-type", "p-interface")
+ .property("interface-name", "pIntRoScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2/p-interfaces/p-interface/pIntRoScn2")
+ .next();
+ lInterfaceRoScn2 = g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "lInterfaceRoScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2/p-interfaces/p-interface/pIntRoScn2/l-interfaces/l-interface/lInterfaceRoScn2")
+ .next();
+ complexROScn2 = g.addV().property("aai-node-type", "complex")
+ .property("physical-location-id","complexROScn2")
+ .property("aai-uri","/cloud-infrastructure/complexes/complex/complexROScn2")
+ .next();
+
+
+ //Scn1
+ edgeSerializer.addTreeEdge(g,pserverRO,pIntRo);
+ edgeSerializer.addTreeEdge(g,pIntRo,lInterfaceRo);
+ edgeSerializer.addEdge(g,pserverRO,complexRO);
+
+
+
+ //Scn2
+ edgeSerializer.addTreeEdge(g,pserverRCTScn2,pIntRctScn2);
+ edgeSerializer.addTreeEdge(g,pIntRctScn2,lInterfaceRctScn2);
+ edgeSerializer.addEdge(g,pserverRCTScn2,complexRctScn2);
+ edgeSerializer.addTreeEdge(g,pserverROScn2,pIntRoScn2);
+ edgeSerializer.addTreeEdge(g,pIntRoScn2,lInterfaceRoScn2);
+ edgeSerializer.addEdge(g,pserverROScn2,complexROScn2);
+
+ //Scn3
+ pserverRCTScn3 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRCTScn3")
+ .property("source-of-truth","RCT")
+ .property("fqdn","Scn3.pserverRCTScn3")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn3")
+ .property("resource-version","3")
+ .next();
+
+ complexScn3 = g.addV().property("aai-node-type", "complex")
+ .property("physical-location-id","complexScn3")
+ .property("aai-uri","/cloud-infrastructure/complexes/complex/complexScn3")
+ .next();
+
+ pserverROScn3 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","Scn3.pserverROScn3")
+ .property("source-of-truth","RO")
+ .property("fqdn","Scn2.pserverRCTScn2")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn3.pserverROScn3")
+ .property("resource-version","4")
+ .next();
+
+ edgeSerializer.addEdge(g, pserverRCTScn3, complexScn3);
+ edgeSerializer.addEdge(g, pserverROScn3, complexScn3);
+
+ //Verify manytoOne edge scenario
+ pserverRCTScn6 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserverRCTScn6")
+ .property("source-of-truth","RCT")
+ .property("fqdn","Scn6.pserverRCTScn6")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn6")
+ .property("resource-version","1")
+ .next();
+
+ zoneScn61 = g.addV().property("aai-node-type", "zone")
+ .property("zone-id", "zone-61")
+ .property("aai-uri","/network/zones/zone/zone-61")
+ .next();
+
+ pserverROScn6 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","Scn6.pserverROScn6")
+ .property("source-of-truth","RO")
+ .property("fqdn","Scn6.pserverRCTScn6")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn6.pserverROScn6")
+ .property("resource-version","4")
+ .next();
+
+ zoneScn62 = g.addV().property("aai-node-type", "zone")
+ .property("zone-id", "zone-62")
+ .property("aai-uri","/network/zones/zone/zone-62")
+ .next();
+
+ edgeSerializer.addEdge(g, pserverRCTScn6, zoneScn61);
+ edgeSerializer.addEdge(g, pserverROScn6, zoneScn62);
+
+ //Verify manyToMany edge scenario
+ Vertex gvnf1 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnf-1")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn6.pserverROScn6")
+ .next();
+
+ Vertex gvnf2 = g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "vnf-2")
+ .property("aai-uri","/network/generic-vnfs/generic-vnf/vnf-2")
+ .next();
+
+ edgeSerializer.addEdge(g, pserverRCTScn6, gvnf1);
+ edgeSerializer.addEdge(g, pserverROScn6, gvnf2);
+
+ // Verify empty string scenario
+ Vertex pserver1EmptyFirstToken = g.addV().property("aai-node-type", "pserver")
+ .property("hostname",".pserver1EmptyFirstToken")
+ .property("source-of-truth","RO")
+ .property("fqdn","sameScn1.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/.pserver1EmptyFirstToken")
+ .property("resource-version","1")
+ .next();
+
+ Vertex pserver1EmptyFirstTokenFqdn = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver1EmptyFirstTokenFqdn")
+ .property("source-of-truth","RCT")
+ .property("fqdn",".rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1EmptyFirstTokenFqdn")
+ .property("resource-version","1")
+ .next();
+
+ //lag-interfaces
+
+ Vertex roP1 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","pserver.ro")
+ .property("source-of-truth","RO")
+ .property("fqdn","pserver.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver.ro")
+ .property("resource-version","1")
+ .next();
+
+ Vertex rctP1 = g.addV().property("aai-node-type", "pserver")
+ .property("hostname","rctP1")
+ .property("source-of-truth","RCT")
+ .property("fqdn","pserver.rrrr.tttt.yyyy")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1")
+ .property("resource-version","3")
+ .next();
+
+ //lagint11 does not have a match on rctP1. So, expect this to move to rctP1. Add test
+ Vertex lagint11= g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lagint11")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/roP1/lag-interfaces/lag-interface/lagint11")
+ .next();
+ edgeSerializer.addTreeEdge(g, roP1, lagint11);
+
+ //lagint12 matches with lagint31 on rctP3
+ Vertex lagint12= g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lagint12")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/roP1/lag-interfaces/lag-interface/lagint12")
+ .next();
+ Vertex lagint31= g.addV()
+ .property("aai-node-type", "lag-interface")
+ .property("interface-name", "lagint12")
+ .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/lag-interfaces/lag-interface/lagint12")
+ .next();
+ edgeSerializer.addTreeEdge(g, roP1, lagint12);
+ edgeSerializer.addTreeEdge(g, rctP1, lagint31);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new PserverDedupWithDifferentSourcesOfTruth(spy,loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.tx().rollback();
+ graph.close();
+ }
+
+ @Test
+ public void rctSuccessfulMoveScn1() throws Exception {
+
+ assertEquals("tttt.RoHostname",pserverRCT.property("fqdn").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pIntRo", pIntRo.property("aai-uri").value().toString());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pIntRo/l-interfaces/l-interface/lInterfaceRo", lInterfaceRo.property("aai-uri").value().toString());
+ assertEquals(true,pserverRCT.property("pserver-id").isPresent());
+ }
+
+ @Test
+ public void rctSuccessfulMovePlink() throws Exception {
+
+ assertEquals("tttt.RoHostname",pserverRCT.property("fqdn").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn1").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pintPlinkScn1", pintPlinkScn1.property("aai-uri").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn1").out("tosca.relationships.network.LinksTo").has("link-name","pLinkScn1").hasNext());
+ }
+
+ @Test
+ public void rctNoChangeSamePIntScenario() throws Exception {
+
+ assertEquals("Scn4.pserverROSPlinkScn4",pserverRCTPlinkScn4.property("fqdn").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTPlinkScn4").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").hasNext());
+ assertEquals("only 1 p-int is present on RCT pserver", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTPlinkScn4").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").count().next());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4/p-interfaces/p-interface/pintPlinkScn4", samePintScn4RCT.property("aai-uri").value().toString());
+ //plink is not moved from RO to RCT when p-int matches
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").out("tosca.relationships.network.LinksTo").hasNext());
+ assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverROPlinkScn4").hasNext());
+ //Verify that no orphan nodes are present in the graph
+ assertEquals(false, g.V().has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").out("tosca.relationships.network.LinksTo").has("link-name","pLinkScn2").hasNext());
+ assertEquals(false, g.V().has("aai-node-type","physical-link").has("link-name","pLinkScn2").hasNext());
+ }
+
+ @Test
+ public void rctSuccessfulMoveScn2() throws Exception {
+
+ assertEquals("Scn2.pserverROScn2",pserverRCTScn2.property("fqdn").value().toString());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn2").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRoScn2", pIntRoScn2.property("aai-uri").value().toString());
+ assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRoScn2/l-interfaces/l-interface/lInterfaceRoScn2", lInterfaceRoScn2.property("aai-uri").value().toString());
+ assertEquals(true,pserverRCTScn2.property("pserver-id").isPresent());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn2").out("org.onap.relationships.inventory.LocatedIn")
+ .has("aai-node-type","complex").has("physical-location-id","complexRctScn2").hasNext());
+ }
+
+ @Test
+ public void checkRCTPserverHasRelnToOnly1Complex() throws Exception {
+
+ assertEquals("Edge to only 1 complex exists", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn3").out("org.onap.relationships.inventory.LocatedIn")
+ .has("aai-node-type","complex").count().next());
+ }
+
+ @Test
+ public void checkRCTPserverHasRelnToOnly1Zone() throws Exception {
+
+ assertEquals("Edge to only 1 Zone exists", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn6").out("org.onap.relationships.inventory.LocatedIn")
+ .has("aai-node-type","zone").count().next());
+ assertEquals(true, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").hasNext());
+ //Verify no edge exists from zone62 to RO pserver
+ assertEquals(false, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").in().has("aai-node-type", "pserver").hasNext());
+
+ }
+
+ @Test
+ public void checkRCTPserverHasRelnTo2GenericVnfs() throws Exception {
+
+ assertEquals("Edge to 2 generic-vnfs exists", new Long(2L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn6").in("tosca.relationships.HostedOn")
+ .has("aai-node-type","generic-vnf").count().next());
+ assertEquals(true, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-2").out().has("aai-node-type", "pserver").has("hostname", "pserverRCTScn6").hasNext());
+ //Verify no edge exists from zone62 to RO pserver
+ assertEquals(false, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-2").out().has("aai-node-type", "pserver").has("hostname", "pserverROScn6").hasNext());
+ }
+
+ @Test
+ public void ignoreEmptyStringFirstTokenFqdn() throws Exception {
+// List<Vertex> pserverList = g.V().has("aai-node-type", "pserver").has("hostname").toList();
+// pserverList.forEach(v ->System.out.println(v.property("hostname").value().toString()));
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserver1EmptyFirstTokenFqdn").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname",".pserver1EmptyFirstToken").hasNext());
+
+ }
+
+ @Test
+ public void testLagInterfaces() throws Exception {
+ //1. lagint11 from roP1 moves to rctP1
+ assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP1").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","lag-interface").has("interface-name","lagint11").hasNext());
+ assertEquals(false, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/pserver.ro/lag-interfaces/lag-interface/lagint11").hasNext());
+ assertEquals(true, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint11").hasNext());
+
+
+ //2. lagint12 int-name matches with lagint31. So, verify that lag-int does not move from rctP1 to rctP3
+ assertEquals("rctP1 has only 1 lag-interface with name lagint12", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP1").in("tosca.relationships.network.BindsTo")
+ .has("aai-node-type","lag-interface").has("interface-name","lagint12").count().next());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/migration/v15/MigrateBooleanDefaultsToFalseTest.java b/src/test/java/org/onap/aai/migration/v15/MigrateBooleanDefaultsToFalseTest.java
new file mode 100644
index 0000000..1474ca1
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v15/MigrateBooleanDefaultsToFalseTest.java
@@ -0,0 +1,385 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v15;
+
+import org.onap.aai.AAISetup;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.migration.Status;
+import org.onap.aai.migration.v15.MigrateBooleanDefaultsToFalse;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import static org.junit.Assert.assertTrue;
+
+public class MigrateBooleanDefaultsToFalseTest extends AAISetup {
+
+ public static class BooleanDefaultMigrator extends MigrateBooleanDefaultsToFalse {
+ public BooleanDefaultMigrator(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions){
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+ @Override
+ public Status getStatus() {
+ return Status.SUCCESS;
+ }
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{VNF_NODE_TYPE,VSERVER_NODE_TYPE,VNFC_NODE_TYPE,L3NETWORK_NODE_TYPE,SUBNET_NODE_TYPE,LINTERFACE_NODE_TYPE,VFMODULE_NODE_TYPE});
+ }
+ @Override
+ public String getMigrationName() {
+ return "MockBooleanDefaultMigrator";
+ }
+ }
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private BooleanDefaultMigrator migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setup() throws Exception{
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ //generic-vnf
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf0")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf1")
+ .property("is-closed-loop-disabled", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf2")
+ .property("is-closed-loop-disabled", true)
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf3")
+ .property("is-closed-loop-disabled", false)
+ .next();
+ //vnfc
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc0")
+ .next();
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc1")
+ .property("is-closed-loop-disabled", "")
+ .next();
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc2")
+ .property("is-closed-loop-disabled", true)
+ .next();
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc3")
+ .property("is-closed-loop-disabled", false)
+ .next();
+ //vserver
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver0")
+ .next();
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver1")
+ .property("is-closed-loop-disabled", "")
+ .next();
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver2")
+ .property("is-closed-loop-disabled", true)
+ .next();
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver3")
+ .property("is-closed-loop-disabled", false)
+ .next();
+ //l3-network
+ g.addV().property("aai-node-type", "l3-network")
+ .property("network-id", "l3-network0")
+ .property("network-name", "l3-network-name0")
+ .next();
+ g.addV().property("aai-node-type", "l3-network")
+ .property("network-id", "l3-network1")
+ .property("network-name", "l3-network-name1")
+ .property("is-bound-to-vpn", "")
+ .property("is-provider-network", "")
+ .property("is-shared-network", "")
+ .property("is-external-network", "")
+ .next();
+ g.addV().property("aai-node-type", "l3-network")
+ .property("network-id", "l3-network2")
+ .property("network-name", "l3-network-name2")
+ .property("is-bound-to-vpn", true)
+ .property("is-provider-network", true)
+ .property("is-shared-network", true)
+ .property("is-external-network", true)
+ .next();
+ g.addV().property("aai-node-type", "l3-network")
+ .property("network-id", "l3-network3")
+ .property("network-name", "l3-network-name3")
+ .property("is-bound-to-vpn", false)
+ .property("is-provider-network", false)
+ .property("is-shared-network", false)
+ .property("is-external-network", false)
+ .next();
+ //subnet
+ g.addV().property("aai-node-type", "subnet")
+ .property("subnet-id", "subnet0")
+ .next();
+ g.addV().property("aai-node-type", "subnet")
+ .property("subnet-id", "subnet1")
+ .property("dhcp-enabled", "")
+ .next();
+ g.addV().property("aai-node-type", "subnet")
+ .property("subnet-id", "subnet2")
+ .property("dhcp-enabled", true)
+ .next();
+ g.addV().property("aai-node-type", "subnet")
+ .property("subnet-id", "subnet3")
+ .property("dhcp-enabled", false)
+ .next();
+ //l-interface
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface0")
+ .property("in-maint", false)
+ .next();
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface1")
+ .property("in-maint", false)
+ .property("is-port-mirrored", "")
+ .property("is-ip-unnumbered", "")
+ .next();
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface2")
+ .property("in-maint", false)
+ .property("is-port-mirrored", true)
+ .property("is-ip-unnumbered", true)
+ .next();
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface3")
+ .property("in-maint", false)
+ .property("is-port-mirrored", false)
+ .property("is-ip-unnumbered", false)
+ .next();
+ //vf-module
+ g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module0")
+ .next();
+ g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module1")
+ .property("is-base-vf-module", "")
+ .next();
+ g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module2")
+ .property("is-base-vf-module", true)
+ .next();
+ g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module3")
+ .property("is-base-vf-module", false)
+ .next();
+
+ //vlan
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan0")
+ .next();
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan1")
+ .property("is-ip-unnumbered", "")
+ .next();
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan2")
+ .property("is-ip-unnumbered", true)
+ .next();
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan3")
+ .property("is-ip-unnumbered", false)
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new BooleanDefaultMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+
+ }
+
+ @Test
+ public void testMissingProperty(){
+ //is-closed-loop-disabled
+ assertTrue("Value of generic-vnf should be updated since the property is-closed-loop-disabled doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf0").has("is-closed-loop-disabled", false).hasNext());
+ assertTrue("Value of vnfc should be updated since the property is-closed-loop-disabled doesn't exist",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc0").has("is-closed-loop-disabled", false).hasNext());
+ assertTrue("Value of vserver should be updated since the property is-closed-loop-disabled doesn't exist",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver0").has("is-closed-loop-disabled", false).hasNext());
+ //dhcp-enabled
+ assertTrue("Value of subnet should be updated since the property dhcp-enabled doesn't exist",
+ g.V().has("aai-node-type", "subnet").has("subnet-id", "subnet0").has("dhcp-enabled", false).hasNext());
+ //l3-network: is-bound-to-vpn, is-shared-network, is-external-network
+ assertTrue("Value of l3-network should be updated since the property is-bound-to-vpn doesn't exist",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-bound-to-vpn", false).hasNext());
+ assertTrue("Value of l3-network should be updated since the property is-provider-network doesn't exist",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-provider-network", false).hasNext());
+ assertTrue("Value of l3-network should be updated since the property is-shared-network doesn't exist",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-shared-network", false).hasNext());
+ assertTrue("Value of l3-network should be updated since the property is-external-network doesn't exist",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-external-network", false).hasNext());
+ //l-interface: is-port-mirrored, is-ip-unnumbered
+ assertTrue("Value of l-interface should be updated since the property is-port-mirrored doesn't exist",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("is-port-mirrored", false).hasNext());
+ assertTrue("Value of l-interface should be updated since the property is-ip-unnumbered doesn't exist",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("is-ip-unnumbered", false).hasNext());
+ //vf-module: is-base-vf-module
+ assertTrue("Value of vf-module should be updated since the property is-base-vf-module doesn't exist",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module0").has("is-base-vf-module", false).hasNext());
+ //vlan: is-ip-unnumbered
+ assertTrue("Value of vlan should be updated since the property is-ip-unnumbered doesn't exist",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan0").has("is-ip-unnumbered", false).hasNext());
+ }
+
+ @Test
+ public void testEmptyValue() {
+ //is-closed-loop-disabled
+ assertTrue("Value of generic-vnf should be updated since the value for is-closed-loop-disabled is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("is-closed-loop-disabled", false).hasNext());
+ assertTrue("Value of vnfc should be updated since the value for is-closed-loop-disabled is an empty string",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc1").has("is-closed-loop-disabled", false).hasNext());
+ assertTrue("Value of vserver should be updated since the value for is-closed-loop-disabled is an empty string",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver1").has("is-closed-loop-disabled", false).hasNext());
+ //dhcp-enabled
+ assertTrue("Value of subnet should be updated since the value for dhcp-enabled is an empty string",
+ g.V().has("aai-node-type", "subnet").has("subnet-id", "subnet1").has("dhcp-enabled", false).hasNext());
+ //l3-network: is-bound-to-vpn, is-shared-network, is-external-network
+ assertTrue("Value of l3-network should be updated since the value for is-bound-to-vpn is an empty string",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-bound-to-vpn", false).hasNext());
+ assertTrue("Value of l3-network should be updated since the value for is-provider-network is an empty string",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-provider-network", false).hasNext());
+ assertTrue("Value of l3-network should be updated since the value for is-shared-network is an empty string",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-shared-network", false).hasNext());
+ assertTrue("Value of l3-network should be updated since the value for is-external-network is an empty string",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-external-network", false).hasNext());
+ //l-interface: is-port-mirrored, is-ip-unnumbered
+ assertTrue("Value of l-interface should be updated since the property is-port-mirrored is an empty string",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("is-port-mirrored", false).hasNext());
+ assertTrue("Value of l-interface should be updated since the property is-ip-unnumbered is an empty string",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("is-ip-unnumbered", false).hasNext());
+ //vf-module: is-base-vf-module, is-ip-unnumbered
+ assertTrue("Value of vf-module should be updated since the property is-base-vf-module is an empty string",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module1").has("is-base-vf-module", false).hasNext());
+ //vlan: is-ip-unnumbered
+ assertTrue("Value of vlan should be updated since the property is-ip-unnumbered is an empty string",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan1").has("is-ip-unnumbered", false).hasNext());
+ }
+
+ @Test
+ public void testExistingTrueValues() {
+ //is-closed-loop-disabled
+ assertTrue("Value of generic-vnf shouldn't be update since is-closed-loop-disabled already exists",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf2").has("is-closed-loop-disabled", true).hasNext());
+ assertTrue("Value of vnfc shouldn't be update since is-closed-loop-disabled already exists",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc2").has("is-closed-loop-disabled", true).hasNext());
+ assertTrue("Value of vserver shouldn't be update since is-closed-loop-disabled already exists",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver2").has("is-closed-loop-disabled", true).hasNext());
+ //dhcp-enabled
+ assertTrue("Value of subnet shouldn't be update since dhcp-enabled already exists",
+ g.V().has("aai-node-type", "subnet").has("subnet-id", "subnet2").has("dhcp-enabled", true).hasNext());
+ //l3-network: is-bound-to-vpn, is-shared-network, is-external-network
+ assertTrue("Value of l3-network shouldn't be updated since is-bound-to-vpn already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-bound-to-vpn", true).hasNext());
+ assertTrue("Value of l3-network shouldn't be updated since is-provider-network already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-provider-network", true).hasNext());
+ assertTrue("Value of l3-network shouldn't be updated since is-shared-network already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-shared-network", true).hasNext());
+ assertTrue("Value of l3-network shouldn't be updated since is-external-network already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-external-network", true).hasNext());
+ //l-interface: is-port-mirrored, is-ip-unnumbered
+ assertTrue("Value of l-interface shouldn't be updated since is-port-mirrored already exists",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("is-port-mirrored", true).hasNext());
+ assertTrue("Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("is-ip-unnumbered", true).hasNext());
+ //vf-module: is-base-vf-module
+ assertTrue("Value of vf-module shouldn't be updated since is-base-vf-module already exists",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module2").has("is-base-vf-module", true).hasNext());
+ //vlan: is-ip-unnumbered
+ assertTrue("Value of vlan shouldn't be updated since is-ip-unnumbered already exists",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan2").has("is-ip-unnumbered", true).hasNext());
+
+ }
+
+ @Test
+ public void testExistingFalseValues() {
+ //is-closed-loop-disabled
+ assertTrue("Value of generic-vnf shouldn't be update since is-closed-loop-disabled already exists",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf3").has("is-closed-loop-disabled", false).hasNext());
+ assertTrue("Value of vnfc shouldn't be update since is-closed-loop-disabled already exists",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc3").has("is-closed-loop-disabled", false).hasNext());
+ assertTrue("Value of vserver shouldn't be update since is-closed-loop-disabled already exists",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver3").has("is-closed-loop-disabled", false).hasNext());
+ //dhcp-enabled
+ assertTrue("Value of subnet shouldn't be update since dhcp-enabled already exists",
+ g.V().has("aai-node-type", "subnet").has("subnet-id", "subnet3").has("dhcp-enabled", false).hasNext());
+ //l3-network: is-bound-to-vpn, is-shared-network, is-external-network
+ assertTrue("Value of l3-network shouldn't be updated since is-bound-to-vpn already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-bound-to-vpn", false).hasNext());
+ assertTrue("Value of l3-network shouldn't be updated since is-provider-network already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-provider-network", false).hasNext());
+ assertTrue("Value of l3-network shouldn't be updated since is-shared-network already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-shared-network", false).hasNext());
+ assertTrue("Value of l3-network shouldn't be updated since is-external-network already exists",
+ g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-external-network", false).hasNext());
+ //l-interface: is-port-mirrored, is-ip-unnumbered
+ assertTrue("Value of l-interface shouldn't be updated since is-port-mirrored already exists",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("is-port-mirrored", false).hasNext());
+ assertTrue("Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("is-ip-unnumbered", false).hasNext());
+ //vf-module: is-base-vf-module
+ assertTrue("Value of vf-module shouldn't be updated since is-base-vf-module already exists",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module3").has("is-base-vf-module", false).hasNext());
+ //vlan: is-ip-unnumbered
+ assertTrue("Value of vlan shouldn't be updated since is-ip-unnumbered already exists",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan3").has("is-ip-unnumbered", false).hasNext());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v15/MigrateCloudRegionUpgradeCycleTest.java b/src/test/java/org/onap/aai/migration/v15/MigrateCloudRegionUpgradeCycleTest.java
new file mode 100644
index 0000000..1b84d86
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v15/MigrateCloudRegionUpgradeCycleTest.java
@@ -0,0 +1,122 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v15;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+
+public class MigrateCloudRegionUpgradeCycleTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigrateCloudRegionUpgradeCycle migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ Vertex cloudRegion1;
+ Vertex cloudRegion2;
+ Vertex cloudRegion3;
+
+
+ @Before
+ public void setUp() throws Exception {
+
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ cloudRegion1 = g.addV().property("aai-node-type", MigrateCloudRegionUpgradeCycle.CLOUD_REGION_NODE_TYPE)
+ .property(MigrateCloudRegionUpgradeCycle.CLOUD_REGION_ID, "akr1")
+ .property(MigrateCloudRegionUpgradeCycle.CLOUD_OWNER, "att-aic")
+ .property( MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE, "Test")
+ .next();
+
+ cloudRegion2 = g.addV().property("aai-node-type", MigrateCloudRegionUpgradeCycle.CLOUD_REGION_NODE_TYPE)
+ .property(MigrateCloudRegionUpgradeCycle.CLOUD_REGION_ID, "amsnl1b")
+ .property(MigrateCloudRegionUpgradeCycle.CLOUD_OWNER, "att-aic")
+ //.property( MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE, "server")
+ .next();
+
+ cloudRegion3 = g.addV().property("aai-node-type", MigrateCloudRegionUpgradeCycle.CLOUD_REGION_NODE_TYPE)
+ .property(MigrateCloudRegionUpgradeCycle.CLOUD_REGION_ID, "alp1")
+ .property(MigrateCloudRegionUpgradeCycle.CLOUD_OWNER, "Test")
+ .property( MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE, "server1")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateCloudRegionUpgradeCycle(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * checks if the upgrade cycle value was changed
+ */
+
+ @Test
+ public void confirmUpgradeCycleChanged() {
+
+ assertEquals("E",cloudRegion1.property(MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE).value());
+ assertEquals("B",cloudRegion2.property(MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE).value());
+ assertEquals("server1",cloudRegion3.property(MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE).value());//Not changed
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v15/MigrateInMaintDefaultToFalseTest.java b/src/test/java/org/onap/aai/migration/v15/MigrateInMaintDefaultToFalseTest.java
new file mode 100644
index 0000000..1bf1344
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v15/MigrateInMaintDefaultToFalseTest.java
@@ -0,0 +1,411 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v15;
+
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.janusgraph.core.schema.JanusGraphManagement;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.migration.Status;
+import org.onap.aai.migration.v15.MigrateInMaintDefaultToFalse;
+import org.onap.aai.migration.v15.MigrateInMaintDefaultToFalseTest.InMaintDefaultMigrator;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+public class MigrateInMaintDefaultToFalseTest extends
+ AAISetup {
+ protected static final String VNF_NODE_TYPE = "generic-vnf";
+ protected static final String LINTERFACE_NODE_TYPE = "l-interface";
+ protected static final String LAG_INTERFACE_NODE_TYPE = "lag-interface";
+ protected static final String LOGICAL_LINK_NODE_TYPE = "logical-link";
+ protected static final String PINTERFACE_NODE_TYPE = "p-interface";
+ protected static final String VLAN_NODE_TYPE = "vlan";
+ protected static final String VNFC_NODE_TYPE = "vnfc";
+ protected static final String VSERVER_NODE_TYPE = "vserver";
+ protected static final String PSERVER_NODE_TYPE = "pserver";
+ protected static final String PNF_NODE_TYPE = "pnf";
+ protected static final String NOS_SERVER_NODE_TYPE = "nos-server";
+
+ public static class InMaintDefaultMigrator extends MigrateInMaintDefaultToFalse {
+ public InMaintDefaultMigrator(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions){
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+ @Override
+ public Status getStatus() {
+ return Status.SUCCESS;
+ }
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{VNF_NODE_TYPE,LINTERFACE_NODE_TYPE,LAG_INTERFACE_NODE_TYPE,LOGICAL_LINK_NODE_TYPE,PINTERFACE_NODE_TYPE,VLAN_NODE_TYPE,VNFC_NODE_TYPE,VSERVER_NODE_TYPE,PSERVER_NODE_TYPE,PNF_NODE_TYPE,NOS_SERVER_NODE_TYPE});
+ }
+ @Override
+ public String getMigrationName() {
+ return "MockInMaintDefaultMigrator";
+ }
+ }
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private InMaintDefaultMigrator migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setup() throws Exception{
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ //generic-vnf
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf0")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf3")
+ .property("in-maint", false)
+ .next();
+ //l-interface
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface0")
+ .next();
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "l-interface")
+ .property("interface-name", "l-interface3")
+ .property("in-maint", false)
+ .next();
+ //lag-interface
+ g.addV().property("aai-node-type", "lag-interface")
+ .property("interface-name", "lag-interface0")
+ .next();
+ g.addV().property("aai-node-type", "lag-interface")
+ .property("interface-name", "lag-interface1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "lag-interface")
+ .property("interface-name", "lag-interface2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "lag-interface")
+ .property("interface-name", "lag-interface3")
+ .property("in-maint", false)
+ .next();
+ //logical-link
+ g.addV().property("aai-node-type", "logical-link")
+ .property("link-name", "logical-link0")
+ .next();
+ g.addV().property("aai-node-type", "logical-link")
+ .property("link-name", "logical-link1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "logical-link")
+ .property("link-name", "logical-link2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "logical-link")
+ .property("link-name", "logical-link3")
+ .property("in-maint", false)
+ .next();
+ //p-interface
+ g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface0")
+ .next();
+ g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "p-interface")
+ .property("interface-name", "p-interface3")
+ .property("in-maint", false)
+ .next();
+ //pnf
+ g.addV().property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf0")
+ .next();
+ g.addV().property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "pnf")
+ .property("pnf-name", "pnf3")
+ .property("in-maint", false)
+ .next();
+ //pserver
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver0")
+ .next();
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "pserver")
+ .property("pserver-id", "pserver3")
+ .property("in-maint", false)
+ .next();
+ //vlan
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan0")
+ .next();
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "vlan")
+ .property("vlan-interface", "vlan3")
+ .property("in-maint", false)
+ .next();
+ //vnfc
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc0")
+ .next();
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "vnfc")
+ .property("vnfc-name", "vnfc3")
+ .property("in-maint", false)
+ .next();
+ //vserver
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver0")
+ .next();
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver2")
+ .property("in-maint", true)
+ .property("is-closed-loop-disabled", true)
+ .next();
+ g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver3")
+ .property("in-maint", false)
+ .next();
+ //nos-server
+ g.addV().property("aai-node-type", "nos-server")
+ .property("nos-server-id", "nos-server0")
+ .property("nos-server-name", "nos-server-name0")
+ .property("vendor", "vendor0")
+ .property("nos-server-selflink", "nos-server-selflink0")
+ .next();
+ g.addV().property("aai-node-type", "nos-server")
+ .property("nos-server-id", "nos-server1")
+ .property("nos-server-name", "nos-server-name1")
+ .property("vendor", "vendor1")
+ .property("nos-server-selflink", "nos-server-selflink1")
+ .property("in-maint", "")
+ .next();
+ g.addV().property("aai-node-type", "nos-server")
+ .property("nos-server-id", "nos-server2")
+ .property("nos-server-name", "nos-server-name2")
+ .property("vendor", "vendor2")
+ .property("nos-server-selflink", "nos-server-selflink2")
+ .property("in-maint", true)
+ .next();
+ g.addV().property("aai-node-type", "nos-server")
+ .property("nos-server-id", "nos-server3")
+ .property("nos-server-name", "nos-server-name3")
+ .property("vendor", "vendor3")
+ .property("nos-server-selflink", "nos-server-selflink3")
+ .property("in-maint", false)
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new InMaintDefaultMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @Test
+ public void testMissingProperty(){
+ assertTrue("Value of generic-vnf should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf0").has("in-maint", false).hasNext());
+ assertTrue("Value of l-interface should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("in-maint", false).hasNext());
+ assertTrue("Value of lag-interface should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "lag-interface").has("interface-name", "lag-interface0").has("in-maint", false).hasNext());
+ assertTrue("Value of logical-link should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "logical-link").has("link-name", "logical-link0").has("in-maint", false).hasNext());
+ assertTrue("Value of p-interface should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "p-interface").has("interface-name", "p-interface0").has("in-maint", false).hasNext());
+ assertTrue("Value of pnf should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf0").has("in-maint", false).hasNext());
+ assertTrue("Value of pserver should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver0").has("in-maint", false).hasNext());
+ assertTrue("Value of vlan should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan0").has("in-maint", false).hasNext());
+ assertTrue("Value of vnfc should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc0").has("in-maint", false).hasNext());
+ assertTrue("Value of vserver should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver0").has("in-maint", false).hasNext());
+ assertTrue("Value of nos-server should be updated since the property in-maint doesn't exist",
+ g.V().has("aai-node-type", "nos-server").has("nos-server-id", "nos-server0").has("in-maint", false).hasNext());
+ }
+
+ @Test
+ public void testEmptyValue() {
+ assertTrue("Value of generic-vnf should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("in-maint", false).hasNext());
+ assertTrue("Value of l-interface should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("in-maint", false).hasNext());
+ assertTrue("Value of lag-interface should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "lag-interface").has("interface-name", "lag-interface1").has("in-maint", false).hasNext());
+ assertTrue("Value of logical-link should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "logical-link").has("link-name", "logical-link1").has("in-maint", false).hasNext());
+ assertTrue("Value of p-interface should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "p-interface").has("interface-name", "p-interface1").has("in-maint", false).hasNext());
+ assertTrue("Value of pnf should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf1").has("in-maint", false).hasNext());
+ assertTrue("Value of pserver should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver1").has("in-maint", false).hasNext());
+ assertTrue("Value of vlan should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan1").has("in-maint", false).hasNext());
+ assertTrue("Value of vnfc should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc1").has("in-maint", false).hasNext());
+ assertTrue("Value of vserver should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver1").has("in-maint", false).hasNext());
+ assertTrue("Value of nos-server should be updated since the value for in-maint is an empty string",
+ g.V().has("aai-node-type", "nos-server").has("nos-server-id", "nos-server1").has("in-maint", false).hasNext());
+ }
+
+ @Test
+ public void testExistingTrueValues() {
+ assertTrue("Value of generic-vnf shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf2").has("in-maint", true).hasNext());
+ assertTrue("Value of l-interface shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("in-maint", true).hasNext());
+ assertTrue("Value of lag-interface shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "lag-interface").has("interface-name", "lag-interface2").has("in-maint", true).hasNext());
+ assertTrue("Value of logical-link shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "logical-link").has("link-name", "logical-link2").has("in-maint", true).hasNext());
+ assertTrue("Value of p-interface shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "p-interface").has("interface-name", "p-interface2").has("in-maint", true).hasNext());
+ assertTrue("Value of pnf shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf2").has("in-maint", true).hasNext());
+ assertTrue("Value of pserver shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver2").has("in-maint", true).hasNext());
+ assertTrue("Value of vlan shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan2").has("in-maint", true).hasNext());
+ assertTrue("Value of vnfc shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc2").has("in-maint", true).hasNext());
+ assertTrue("Value of vserver shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver2").has("in-maint", true).hasNext());
+ assertTrue("Value of nos-server shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "nos-server").has("nos-server-id", "nos-server2").has("in-maint", true).hasNext());
+ }
+
+ @Test
+ public void testExistingFalseValues() {
+ assertTrue("Value of generic-vnf shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf3").has("in-maint", false).hasNext());
+ assertTrue("Value of l-interface shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("in-maint", false).hasNext());
+ assertTrue("Value of lag-interface shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "lag-interface").has("interface-name", "lag-interface3").has("in-maint", false).hasNext());
+ assertTrue("Value of logical-link shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "logical-link").has("link-name", "logical-link3").has("in-maint", false).hasNext());
+ assertTrue("Value of p-interface shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "p-interface").has("interface-name", "p-interface3").has("in-maint", false).hasNext());
+ assertTrue("Value of pnf shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf3").has("in-maint", false).hasNext());
+ assertTrue("Value of pserver shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "pserver").has("pserver-id", "pserver3").has("in-maint", false).hasNext());
+ assertTrue("Value of vlan shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan3").has("in-maint", false).hasNext());
+ assertTrue("Value of vnfc shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "vnfc").has("vnfc-name", "vnfc3").has("in-maint", false).hasNext());
+ assertTrue("Value of vserver shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver3").has("in-maint", false).hasNext());
+ assertTrue("Value of nos-server shouldn't be updated since in-maint already exists",
+ g.V().has("aai-node-type", "nos-server").has("nos-server-id", "nos-server3").has("in-maint", false).hasNext());
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/aai/migration/v15/MigrateRadcomChangesTest.java b/src/test/java/org/onap/aai/migration/v15/MigrateRadcomChangesTest.java
new file mode 100644
index 0000000..ad101ed
--- /dev/null
+++ b/src/test/java/org/onap/aai/migration/v15/MigrateRadcomChangesTest.java
@@ -0,0 +1,509 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.migration.v15;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.*;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+public class MigrateRadcomChangesTest extends AAISetup {
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigrateRadcomChanges migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setUp() throws Exception {
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
+
+ Vertex genericVnf1 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-1")
+ .property("vnf-name", "name-1").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf2 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-2")
+ .property("vnf-name", "name-2").property("vnf-type", "test")
+ .property("model-invariant-id-local", "change").property("model-version-id-local", "change").property("model-customization-id", "change").next();
+ Vertex genericVnf3 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-3")
+ .property("vnf-name", "no-service").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf4 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-4")
+ .property("vnf-name", "no-invariant").property("vnf-type", "test")
+ .property("model-version-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf5 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-5")
+ .property("vnf-name", "no-version").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf6 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-6")
+ .property("vnf-name", "no-customization").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
+ Vertex genericVnf7 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-7")
+ .property("vnf-name", "no ids").property("vnf-type", "test").next();
+ Vertex genericVnf8 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-8")
+ .property("vnf-name", "many-service-1").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf9 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-9")
+ .property("vnf-name", "many-service-2").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf10 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-10")
+ .property("vnf-name", "multi-name").property("vnf-type", "test").next();
+ Vertex genericVnf11 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-11")
+ .property("vnf-name", "multi-name").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
+ Vertex genericVnf12 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-12")
+ .property("vnf-name", "wrong-type").property("vnf-type", "none").next();
+ Vertex genericVnf13 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "test-13")
+ .property("vnf-name", "wrong-name").property("vnf-type", "test")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").property("model-customization-id", "test").next();
+
+ Vertex serviceInstance1 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "service-1")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
+ Vertex serviceInstance2 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "service-2")
+ .property("model-invariant-id-local", "diff").property("model-version-id-local", "diff").next();
+ Vertex serviceInstance3 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "no-invariant")
+ .property("model-version-id-local", "test").next();
+ Vertex serviceInstance4 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "no-version")
+ .property("model-invariant-id-local", "test").next();
+ Vertex serviceInstance5 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "no ids").next();
+ Vertex serviceInstance6 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "service-many")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
+ Vertex serviceInstance7 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "wrong").next();
+ Vertex serviceInstance8 = g.addV().property("aai-node-type", "service-instance")
+ .property("service-instance-id", "connected-wrong")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
+
+ Vertex serviceModel = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-service-inv").property("model-type", "Service").next();
+ Vertex serviceModelVer = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-service-ver").property("model-name", "test-service")
+ .property("version", "test").next();
+ Vertex resourceModel = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-resource-inv").property("model-type", "VNF-resource").next();
+ Vertex resourceModelVer = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-resource-ver").property("model-name", "test-resource")
+ .property("version", "test").next();
+ Vertex resourceModelElement1 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "resource-element-start").property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded").next();
+ Vertex newVfModuleModelVer2 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-vf-module-ver-2").property("model-name", "model-2")
+ .property("version", "test").next();
+ Vertex newVfModuleModel2 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-vf-module-inv-2").property("model-type", "2").next();
+ Vertex resourceModelElement2 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "resource-element-depth-1").property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded").next();
+ Vertex newVfModuleModelVer3 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-vf-module-ver-3").property("model-name", "model-3")
+ .property("version", "test").next();
+ Vertex newVfModuleModel3 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-vf-module-inv-3").property("model-type", "3").next();
+ Vertex resourceModelElement3 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "resource-element-depth-2-1").property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded").next();
+ Vertex newVfModuleModelVer4 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-vf-module-ver-4").property("model-name", "model-4")
+ .property("version", "test").next();
+ Vertex newVfModuleModel4 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-vf-module-inv-4").property("model-type", "4").next();
+ Vertex resourceModelElement4 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "resource-element-depth-2-2").property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded").next();
+ Vertex newVfModuleModelVer5 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-vf-module-ver-5").property("model-name", "model-5")
+ .property("version", "test").next();
+ Vertex newVfModuleModel5 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-vf-module-inv-5").property("model-type", "5").next();
+ Vertex resourceModelElement5 = g.addV().property("aai-node-type", "model-element")
+ .property("model-element-uuid", "resource-element-depth-2-3").property("new-data-del-flag", "T")
+ .property("cardinality", "unbounded").next();
+ Vertex newVfModuleModelVer1 = g.addV().property("aai-node-type", "model-ver")
+ .property("model-version-id", "new-vf-module-ver-1").property("model-name", "model-1")
+ .property("version", "test").next();
+ Vertex newVfModuleModel1 = g.addV().property("aai-node-type", "model")
+ .property("model-invariant-id", "new-vf-module-inv-1").property("model-type", "1").next();
+
+ Vertex vfModule1 = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module-1")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
+ Vertex vfModule2 = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "vf-module-2")
+ .property("model-invariant-id-local", "test").property("model-version-id-local", "test").next();
+ Vertex vfModule3 = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "no-invariant")
+ .property("model-version-id-local", "test").next();
+ Vertex vfModule4 = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "no-ver")
+ .property("model-invariant-id-local", "test").next();
+ Vertex vfModule5 = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "no-ids").next();
+ Vertex badVfModule = g.addV().property("aai-node-type", "vf-module")
+ .property("vf-module-id", "bad").next();
+
+ Vertex vserver1 = g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver-1").property("vserver-name", "vname-1").next();
+ Vertex vserver2 = g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "vserver-2").property("vserver-name", "vname-2").next();
+ Vertex unchangedVserver = g.addV().property("aai-node-type", "vserver")
+ .property("vserver-id", "unchanged").property("vserver-name", "unchanged").next();
+
+ Vertex image1 = g.addV().property("aai-node-type", "image")
+ .property("image-id", "image-id-1").property("image-name", "image-1").next();
+ Vertex image2 = g.addV().property("aai-node-type", "image")
+ .property("image-id", "image-id-2").property("image-name", "image-2").next();
+ Vertex oldImage = g.addV().property("aai-node-type", "image")
+ .property("image-id", "image-old").property("image-name", "image-old-name").next();
+ Vertex badImage = g.addV().property("aai-node-type", "image")
+ .property("image-id", "image-bad").property("image-name", "image-bad").next();
+
+ Vertex tenant1 = g.addV().property("aai-node-type", "tenant")
+ .property("tenant-id", "tenant-id-1").property("tenant-name", "tenant-1").next();
+ Vertex tenant2 = g.addV().property("aai-node-type", "tenant")
+ .property("tenant-id", "tenant-id-2").property("tenant-name", "tenant-2").next();
+ Vertex cloudRegion1 = g.addV().property("aai-node-type", "cloud-region")
+ .property("cloud-region-id", "region-1").property("cloud-owner", "owner-1").next();
+ Vertex cloudRegion2 = g.addV().property("aai-node-type", "cloud-region")
+ .property("cloud-region-id", "region-2").property("cloud-owner", "owner-2").next();
+
+
+ edgeSerializer.addEdge(g, genericVnf1, serviceInstance1);
+ edgeSerializer.addEdge(g, genericVnf2, serviceInstance2);
+ edgeSerializer.addEdge(g, genericVnf4, serviceInstance3);
+ edgeSerializer.addEdge(g, genericVnf5, serviceInstance4);
+ edgeSerializer.addEdge(g, genericVnf6, serviceInstance5);
+ edgeSerializer.addEdge(g, genericVnf8, serviceInstance6);
+ edgeSerializer.addEdge(g, genericVnf9, serviceInstance6);
+ edgeSerializer.addEdge(g, genericVnf12, serviceInstance8);
+
+ edgeSerializer.addTreeEdge(g, genericVnf2, vfModule1);
+ edgeSerializer.addTreeEdge(g, genericVnf4, vfModule2);
+ edgeSerializer.addTreeEdge(g, genericVnf5, vfModule3);
+ edgeSerializer.addTreeEdge(g, genericVnf6, vfModule4);
+ edgeSerializer.addTreeEdge(g, genericVnf7, vfModule5);
+ edgeSerializer.addTreeEdge(g, genericVnf12, badVfModule);
+
+ edgeSerializer.addTreeEdge(g, serviceModel, serviceModelVer);
+ edgeSerializer.addTreeEdge(g, resourceModel, resourceModelVer);
+ edgeSerializer.addTreeEdge(g, resourceModelVer, resourceModelElement1);
+ edgeSerializer.addEdge(g, resourceModelElement1, newVfModuleModelVer2);
+ edgeSerializer.addTreeEdge(g, newVfModuleModelVer2, newVfModuleModel2);
+ edgeSerializer.addTreeEdge(g, resourceModelElement1, resourceModelElement2);
+ edgeSerializer.addEdge(g, resourceModelElement2, newVfModuleModelVer3);
+ edgeSerializer.addTreeEdge(g, newVfModuleModelVer3, newVfModuleModel3);
+ edgeSerializer.addTreeEdge(g, resourceModelElement2, resourceModelElement3);
+ edgeSerializer.addTreeEdge(g, resourceModelElement2, resourceModelElement4);
+ edgeSerializer.addTreeEdge(g, resourceModelElement2, resourceModelElement5);
+ edgeSerializer.addEdge(g, resourceModelElement3, newVfModuleModelVer4);
+ edgeSerializer.addTreeEdge(g, newVfModuleModelVer4, newVfModuleModel4);
+ edgeSerializer.addEdge(g, resourceModelElement4, newVfModuleModelVer5);
+ edgeSerializer.addTreeEdge(g, newVfModuleModelVer5, newVfModuleModel5);
+ edgeSerializer.addEdge(g, resourceModelElement5, newVfModuleModelVer1);
+ edgeSerializer.addTreeEdge(g, newVfModuleModelVer1, newVfModuleModel1);
+
+ edgeSerializer.addEdge(g, vfModule1, vserver1);
+ edgeSerializer.addEdge(g, vfModule2, vserver2);
+ edgeSerializer.addEdge(g, vfModule4, unchangedVserver);
+ edgeSerializer.addEdge(g, vserver2, oldImage);
+ edgeSerializer.addEdge(g, unchangedVserver, badImage);
+ edgeSerializer.addTreeEdge(g, image1, cloudRegion1);
+ edgeSerializer.addTreeEdge(g, tenant1, cloudRegion1);
+ edgeSerializer.addTreeEdge(g, tenant1, vserver1);
+ edgeSerializer.addTreeEdge(g, image2, cloudRegion2);
+ edgeSerializer.addTreeEdge(g, tenant2, cloudRegion2);
+ edgeSerializer.addTreeEdge(g, tenant2, vserver2);
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+
+ GraphTraversalSource traversal = g;
+ GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
+ when (spy.tx()).thenReturn(tx);
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
+
+ migration = new MigrateRadcomChanges(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @Test
+ public void testGenericVnfsUpdated() throws Exception {
+ // check if generic-vnf nodes are updated
+
+ assertEquals("First generic-vnf updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "name-1").next().value("model-invariant-id-local"));
+ assertEquals("First generic-vnf updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "name-1").next().value("model-version-id-local"));
+ assertEquals("First generic-vnf updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "name-1").next().value("model-customization-id"));
+
+ assertEquals("Second generic-vnf updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "name-2").next().value("model-invariant-id-local"));
+ assertEquals("Second generic-vnf updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "name-2").next().value("model-version-id-local"));
+ assertEquals("Second generic-vnf updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "name-2").next().value("model-customization-id"));
+
+ assertEquals("Generic-vnf with no service updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-service").next().value("model-invariant-id-local"));
+ assertEquals("Generic-vnf with no service updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-service").next().value("model-version-id-local"));
+ assertEquals("Generic-vnf with no service updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-service").next().value("model-customization-id"));
+
+ assertEquals("Generic-vnf with no invariant updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-invariant").next().value("model-invariant-id-local"));
+ assertEquals("Generic-vnf with no invariant updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-invariant").next().value("model-version-id-local"));
+ assertEquals("Generic-vnf with no invariant updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-invariant").next().value("model-customization-id"));
+
+ assertEquals("Generic-vnf with no version updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-version").next().value("model-invariant-id-local"));
+ assertEquals("Generic-vnf with no version updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-version").next().value("model-version-id-local"));
+ assertEquals("Generic-vnf with no version updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-version").next().value("model-customization-id"));
+
+ assertEquals("Generic-vnf with no customization updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-customization").next().value("model-invariant-id-local"));
+ assertEquals("Generic-vnf with no customization updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-customization").next().value("model-version-id-local"));
+ assertEquals("Generic-vnf with no customization updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-customization").next().value("model-customization-id"));
+
+ assertEquals("Generic-vnf with no ids updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no ids").next().value("model-invariant-id-local"));
+ assertEquals("Generic-vnf with no ids updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no ids").next().value("model-version-id-local"));
+ assertEquals("Generic-vnf with no version updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "no-version").next().value("model-customization-id"));
+
+ assertEquals("First generic-vnf for many-to-service test updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "many-service-1").next().value("model-invariant-id-local"));
+ assertEquals("First generic-vnf for many-to-service test updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "many-service-1").next().value("model-version-id-local"));
+ assertEquals("First generic-vnf for many-to-service test updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "many-service-1").next().value("model-customization-id"));
+
+ assertEquals("Second generic-vnf for many-to-service test updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "many-service-2").next().value("model-invariant-id-local"));
+ assertEquals("Second generic-vnf for many-to-service test updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "many-service-2").next().value("model-version-id-local"));
+ assertEquals("Second generic-vnf for many-to-service test updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "many-service-2").next().value("model-customization-id"));
+
+
+ assertEquals("First generic-vnf for multi-name test updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "test-10").next().value("model-invariant-id-local"));
+ assertEquals("First generic-vnf for multi-name test updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "test-10").next().value("model-version-id-local"));
+ assertEquals("First generic-vnf for multi-name test updated customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "test-10").next().value("model-customization-id"));
+
+ assertEquals("Second generic-vnf for multi-name test updated invariant", "new-resource-inv",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "test-11").next().value("model-invariant-id-local"));
+ assertEquals("Second generic-vnf for multi-name test updated version", "new-resource-ver",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "test-11").next().value("model-version-id-local"));
+ assertEquals("Second generic-vnf for multi-name test customization", "new-resource-cust",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "test-11").next().value("model-customization-id"));
+ }
+
+
+ @Test
+ public void testServiceInstancesUpdated() throws Exception {
+ // check if service-instance nodes are updated
+
+ assertEquals("First service-instance updated invariant", "new-service-inv",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "service-1").next().value("model-invariant-id-local"));
+ assertEquals("First service-instance-updated version", "new-service-ver",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "service-1").next().value("model-version-id-local"));
+
+ assertEquals("Second service-instance updated invariant", "new-service-inv",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "service-2").next().value("model-invariant-id-local"));
+ assertEquals("Second service-instance-updated version", "new-service-ver",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "service-2").next().value("model-version-id-local"));
+
+ assertEquals("Service-instance with no invariant updated invariant", "new-service-inv",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "no-invariant").next().value("model-invariant-id-local"));
+ assertEquals("Service-instance with no invariant updated version", "new-service-ver",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "no-invariant").next().value("model-version-id-local"));
+
+ assertEquals("Service-instance with no version updated invariant", "new-service-inv",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "no-version").next().value("model-invariant-id-local"));
+ assertEquals("Service-instance with no version updated version", "new-service-ver",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "no-version").next().value("model-version-id-local"));
+
+ assertEquals("Service-instance with no ids updated invariant", "new-service-inv",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "no ids").next().value("model-invariant-id-local"));
+ assertEquals("Service-instance with no ids updated version", "new-service-ver",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "no ids").next().value("model-version-id-local"));
+
+ assertEquals("Service-instance for many-to-service test updated invariant", "new-service-inv",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "service-many").next().value("model-invariant-id-local"));
+ assertEquals("Service-instance for many-to-service test updated version", "new-service-ver",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "service-many").next().value("model-version-id-local"));
+ }
+
+ @Test
+ public void testVfModulesUpdated() throws Exception {
+ //test if vf-module nodes are updated
+
+ assertEquals("First vf-module updated invariant", "new-vf-module-inv-1",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module-1").next().value("model-invariant-id-local"));
+ assertEquals("First vf-module updated version", "new-vf-module-ver-1",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module-1").next().value("model-version-id-local"));
+
+ assertEquals("Second vf-module updated invariant", "new-vf-module-inv-2",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module-2").next().value("model-invariant-id-local"));
+ assertEquals("Second vf-module updated version", "new-vf-module-ver-2",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module-2").next().value("model-version-id-local"));
+
+ assertEquals("Vf-module with no invariant updated invariant", "new-vf-module-inv-3",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "no-invariant").next().value("model-invariant-id-local"));
+ assertEquals("Vf-module with no invariant updated version", "new-vf-module-ver-3",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "no-invariant").next().value("model-version-id-local"));
+
+ assertEquals("Vf-module with no version updated invariant", "new-vf-module-inv-4",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "no-ver").next().value("model-invariant-id-local"));
+ assertEquals("Vf-module with no version updated version", "new-vf-module-ver-4",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "no-ver").next().value("model-version-id-local"));
+
+ assertEquals("Vf-module with no ids updated invariant", "new-vf-module-inv-5",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "no-ids").next().value("model-invariant-id-local"));
+ assertEquals("Vf-module with no ids updated version", "new-vf-module-ver-5",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "no-ids").next().value("model-version-id-local"));
+ }
+
+ @Test
+ public void testVserverAndImageUpdated() throws Exception {
+ //test if vserver-image relationships are updated
+ assertTrue("Vserver not connected to image is connected to new image",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver-1").out("org.onap.relationships.inventory.Uses")
+ .has("aai-node-type", "image").has("image-id", "image-id-1").hasNext());
+ assertTrue("Vserver connected to existing image is connected to new image",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver-2").out("org.onap.relationships.inventory.Uses")
+ .has("aai-node-type", "image").has("image-id", "image-id-2").hasNext());
+ assertFalse("Vserver connected to existing image is not connected to that image",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "vserver-2").out("org.onap.relationships.inventory.Uses")
+ .has("aai-node-type", "image").has("image-id", "image-old").hasNext());
+ assertTrue("Existing image still exists",
+ g.V().has("aai-node-type", "image").has("image-id", "image-old").hasNext());
+ }
+
+ @Test
+ public void testNodesNotUpdated() throws Exception {
+ // negative tests
+
+ assertFalse("Generic-vnf with wrong type has unchanged invariant",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "wrong-type").next()
+ .property("model-invariant-id-local").isPresent());
+ assertFalse("Generic-vnf with wrong type has unchanged version",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "wrong-type").next()
+ .property("model-version-id-local").isPresent());
+ assertFalse("Generic-vnf with wrong type has unchanged customization",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "wrong-type").next()
+ .property("model-customizaiton-id").isPresent());
+
+ assertEquals("Generic-vnf with wrong name has unchanged invariant", "test",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "wrong-name").next().value("model-invariant-id-local"));
+ assertEquals("Generic-vnf with wrong name has unchanged version", "test",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "wrong-name").next().value("model-version-id-local"));
+ assertEquals("Generic-vnf with wrong name has unchanged customization", "test",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-name", "wrong-name").next().value("model-customization-id"));
+
+ assertFalse("Unconnected service-instance has unchanged invariant",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "wrong").next()
+ .property("model-invariant-id-local").isPresent());
+ assertFalse("Unconnected service-instance has unchanged version",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "wrong").next()
+ .property("model-version-id-local").isPresent());
+
+ assertEquals("Service-instance connected to unctouched generic-vnf has unchanged invariant", "test",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "connected-wrong")
+ .next().value("model-invariant-id-local"));
+ assertEquals("Service-instance connected to untouched generic-vnf has unchanged version", "test",
+ g.V().has("aai-node-type", "service-instance").has("service-instance-id", "connected-wrong")
+ .next().value("model-version-id-local"));
+
+ assertFalse("Vf-module connected to untouched generic-vnf has unchanged invariant",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "bad")
+ .next().property("model-invariant-id-local").isPresent());
+ assertFalse("Vf-module connected to untouched generic-vnf has unchanged version",
+ g.V().has("aai-node-type", "vf-module").has("vf-module-id", "bad")
+ .next().property("model-version-id-local").isPresent());
+
+ assertTrue("Untouched vserver still connected to image",
+ g.V().has("aai-node-type", "vserver").has("vserver-id", "unchanged").out("org.onap.relationships.inventory.Uses")
+ .has("aai-node-type", "image").has("image-id", "image-bad").hasNext());
+ }
+
+ @Test
+ public void testGetAffectedNodeTypes() {
+ Optional<String[]> types = migration.getAffectedNodeTypes();
+ Optional<String[]> expected = Optional.of(new String[]{"generic-vnf", "service-instance", "vf-module", "vserver", "image"});
+
+ assertNotNull(types);
+ assertArrayEquals(expected.get(), types.get());
+ }
+
+ @Test
+ public void testGetMigrationName() {
+ String migrationName = migration.getMigrationName();
+
+ assertNotNull(migrationName);
+ assertEquals("MigrateRadcomChanges", migrationName);
+ }
+}
diff --git a/src/test/java/org/onap/aai/util/SendMigrationNotificationsTest.java b/src/test/java/org/onap/aai/util/SendMigrationNotificationsTest.java
index 6719d0f..c7ca3d3 100644
--- a/src/test/java/org/onap/aai/util/SendMigrationNotificationsTest.java
+++ b/src/test/java/org/onap/aai/util/SendMigrationNotificationsTest.java
@@ -71,30 +71,35 @@ public class SendMigrationNotificationsTest extends AAISetup {
Vertex pnf1 = g.addV()
.property("aai-node-type", "pnf")
.property("pnf-name", SendMigrationNotifications.class.getSimpleName()+"-pnf-1")
+ .property("aai-uri", "/network/pnfs/pnf/" + SendMigrationNotifications.class.getSimpleName()+"-pnf-1")
.property(AAIProperties.RESOURCE_VERSION, "123")
.next();
Vertex pnf2 = g.addV()
.property("aai-node-type", "pnf")
.property("pnf-name", SendMigrationNotifications.class.getSimpleName()+"-pnf-2")
+ .property("aai-uri", "/network/pnfs/pnf/" + SendMigrationNotifications.class.getSimpleName()+"-pnf-2")
.property(AAIProperties.RESOURCE_VERSION, "456")
.next();
Vertex pnf3 = g.addV()
.property("aai-node-type", "pnf")
.property("pnf-name", SendMigrationNotifications.class.getSimpleName()+"-pnf-3")
+ .property("aai-uri", "/network/pnfs/pnf/" + SendMigrationNotifications.class.getSimpleName()+"-pnf-3")
.property(AAIProperties.RESOURCE_VERSION, "111")
.next();
Vertex pinterface1 = g.addV()
.property("aai-node-type", "p-interface")
.property("interface-name", SendMigrationNotifications.class.getSimpleName()+"-pinterface-1")
+ .property("aai-uri", "/network/pnfs/pnf/" + SendMigrationNotifications.class.getSimpleName()+"-pnf-1" + "/p-interfaces/p-interface/" + SendMigrationNotifications.class.getSimpleName()+"-pinterface-1")
.property(AAIProperties.RESOURCE_VERSION, "789")
.next();
Vertex pserver1 = g.addV()
.property("aai-node-type", "pserver")
.property("hostname", SendMigrationNotifications.class.getSimpleName()+"-pserver-1")
+ .property("aai-uri", "/cloud-infrastructure/pservers/pserver/" + SendMigrationNotifications.class.getSimpleName()+"-pserver-1")
.property(AAIProperties.RESOURCE_VERSION, "333")
.next();