Search in sources :

Example 16 with TransactionalGraphEngine

use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.

the class MigrateInMaintDefaultToFalseTest method setup.

@Before
public void setup() throws Exception {
    g = tx.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    dbEngine = new JanusGraphDBEngine(queryStyle, 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();
}
Also used : TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) InMaintDefaultMigrator(org.onap.aai.migration.v13.MigrateInMaintDefaultToFalseTest.InMaintDefaultMigrator) Before(org.junit.Before)

Example 17 with TransactionalGraphEngine

use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.

the class MigrateInstanceGroupModelVersionIdTest method setUp.

@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, loader);
    Vertex instancegroup1 = g.addV().property("aai-node-type", "instance-group").property("id", "instance-id-1").property("description", "instance-description-1").property("instanceGroupType", "instance-type-1").property("model-version-id", "instance-version-id-1").next();
    Vertex instancegroup2 = g.addV().property("aai-node-type", "instance-group").property("id", "instance-id-2").property("description", "instance-description-2").property("instanceGroupType", "instance-type-1").property("model-version-id-local", "instance-version-id-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 MigrateInstanceGroupModelVersionId(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
    migration.run();
}
Also used : TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 18 with TransactionalGraphEngine

use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.

the class MigrateInstanceGroupSubTypeTest method setUp.

@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, loader);
    instanceGroup = g.addV().property("aai-node-type", MigrateInstanceGroupSubType.INSTANCE_GROUP_NODE_TYPE).property(MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY, SUB_TYPE_VALUE).next();
    instanceGroupWithoutTSubType = g.addV().property("aai-node-type", MigrateInstanceGroupSubType.INSTANCE_GROUP_NODE_TYPE).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 MigrateInstanceGroupSubType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
}
Also used : TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 19 with TransactionalGraphEngine

use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.

the class MigrateModelVerTest method setUp.

@Before
public void setUp() throws Exception {
    graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
    JanusGraphManagement janusgraphManagement = graph.openManagement();
    tx = graph.newTransaction();
    g = graph.traversal();
    loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    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();
    // 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();
    Vertex modelVer1 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-1").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-1/model-vers/model-ver/model-version-id-1").property("model-name", "connector").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model1, modelVer1);
    // connector
    Vertex connector1 = g.addV().property("aai-node-type", "connector").property("resource-instance-id", "connector1").property("model-invariant-id-local", "model-invariant-id-1").property("model-version-id-local", "model-version-id-1").next();
    Vertex connector2 = g.addV().property("aai-node-type", "connector").property("resource-instance-id", "connector2").property("model-invariant-id-local", "model-invariant-id-x").property("model-version-id-local", "model-version-id-x").next();
    Vertex connector3 = g.addV().property("aai-node-type", "connector").property("resource-instance-id", "connector3").property("model-invariant-id-local", "model-invariant-id-1").property("model-version-id-local", "model-version-id-1").next();
    edgeSerializer.addPrivateEdge(traversal, connector3, modelVer1, null);
    // Add model1/model-ver1 -- invalid model/model-ver
    Vertex model2 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-2").property("model-type", "widget").next();
    Vertex modelVer2 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-2").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-2/model-vers/model-ver/model-version-id-2").property("model-name", "service-instance").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model2, modelVer2);
    // serivce-instance
    Vertex serviceInstance1 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "serviceinstance1").property("model-invariant-id-local", "model-invariant-id-2").property("model-version-id-local", "model-version-id-2").next();
    Vertex serviceInstance2 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "serviceinstance2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex serviceInstance3 = g.addV().property("aai-node-type", "service-instance").property("service-instance-id", "serviceinstance3").property("model-invariant-id-local", "model-invariant-id-2").property("model-version-id-local", "model-version-id-2").next();
    edgeSerializer.addPrivateEdge(traversal, serviceInstance3, modelVer2, null);
    // Add model3/model-ver3
    Vertex model3 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-3").property("model-type", "widget").next();
    Vertex modelVer3 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-3").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-3/model-vers/model-ver/model-version-id-3").property("model-name", "pnf").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model3, modelVer3);
    // pnf
    Vertex pnfName1 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnfName1").property("model-invariant-id-local", "model-invariant-id-3").property("model-version-id-local", "model-version-id-3").next();
    Vertex pnfName2 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnfName2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex pnfName3 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnfName3").property("model-invariant-id-local", "model-invariant-id-3").property("model-version-id-local", "model-version-id-3").next();
    edgeSerializer.addPrivateEdge(traversal, pnfName3, modelVer3, null);
    // Add model4/model-ver4
    Vertex model4 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-4").property("model-type", "widget").next();
    Vertex modelVer4 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-4").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-4/model-vers/model-ver/model-version-id-4").property("model-name", "logical-link").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model4, modelVer4);
    // logical-link
    Vertex linkName1 = g.addV().property("aai-node-type", "logical-link").property("link-name", "linkName1").property("model-invariant-id-local", "model-invariant-id-4").property("model-version-id-local", "model-version-id-4").next();
    Vertex linkName2 = g.addV().property("aai-node-type", "logical-link").property("link-name", "linkName2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex linkName3 = g.addV().property("aai-node-type", "logical-link").property("link-name", "linkName3").property("model-invariant-id-local", "model-invariant-id-4").property("model-version-id-local", "model-version-id-4").next();
    edgeSerializer.addPrivateEdge(traversal, linkName3, modelVer4, null);
    // Add model5/model-ver5
    Vertex model5 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-5").property("model-type", "widget").next();
    Vertex modelVer5 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-5").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-5/model-vers/model-ver/model-version-id-5").property("model-name", "vnfc").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model5, modelVer5);
    // vnfc
    Vertex vnfc1 = g.addV().property("aai-node-type", "vnfc").property("vnfc-name", "vnfc1").property("model-invariant-id-local", "model-invariant-id-5").property("model-version-id-local", "model-version-id-5").next();
    Vertex vnfc2 = g.addV().property("aai-node-type", "vnfc").property("vnfc-name", "vnfc2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex vnfc3 = g.addV().property("aai-node-type", "vnfc").property("vnfc-name", "vnfc3").property("model-invariant-id-local", "model-invariant-id-5").property("model-version-id-local", "model-version-id-5").next();
    edgeSerializer.addPrivateEdge(traversal, vnfc3, modelVer5, null);
    // Add model6/model-ver6
    Vertex model6 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-6").property("model-type", "widget").next();
    Vertex modelVer6 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-6").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-6/model-vers/model-ver/model-version-id-6").property("model-name", "vnf").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model6, modelVer6);
    // generic-vnf
    Vertex vnf1 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnf1").property("model-invariant-id-local", "model-invariant-id-6").property("model-version-id-local", "model-version-id-6").next();
    Vertex vnf2 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnf2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex vnf3 = g.addV().property("aai-node-type", "generic-vnf").property("vnf-id", "vnf3").property("model-invariant-id-local", "model-invariant-id-6").property("model-version-id-local", "model-version-id-6").next();
    edgeSerializer.addPrivateEdge(traversal, vnf3, modelVer6, null);
    // Add model7/model-ver7
    Vertex model7 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-7").property("model-type", "widget").next();
    Vertex modelVer7 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-7").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-7/model-vers/model-ver/model-version-id-7").property("model-name", "configuration").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model7, modelVer7);
    // configuration
    Vertex configuration1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "configuration1").property("model-invariant-id-local", "model-invariant-id-7").property("model-version-id-local", "model-version-id-7").next();
    Vertex configuration2 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "configuration2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex configuration3 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "configuration3").property("model-invariant-id-local", "model-invariant-id-7").property("model-version-id-local", "model-version-id-7").next();
    edgeSerializer.addPrivateEdge(traversal, configuration3, modelVer7, null);
    // Add model8/model-ver8
    Vertex model8 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-8").property("model-type", "widget").next();
    Vertex modelVer8 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-8").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-8/model-vers/model-ver/model-version-id-8").property("model-name", "l3-network").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model8, modelVer8);
    // l3-network
    Vertex l3Network1 = g.addV().property("aai-node-type", "l3-network").property("network-id", "l3Network1").property("model-invariant-id-local", "model-invariant-id-8").property("model-version-id-local", "model-version-id-8").next();
    Vertex l3Network2 = g.addV().property("aai-node-type", "l3-network").property("network-id", "l3Network2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex l3Network3 = g.addV().property("aai-node-type", "l3-network").property("network-id", "l3Network3").property("model-invariant-id-local", "model-invariant-id-8").property("model-version-id-local", "model-version-id-8").next();
    edgeSerializer.addPrivateEdge(traversal, l3Network3, modelVer8, null);
    // Add model9/model-ver9
    Vertex model9 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-9").property("model-type", "widget").next();
    Vertex modelVer9 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-9").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-9/model-vers/model-ver/model-version-id-9").property("model-name", "vf-module").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model9, modelVer9);
    // vf-module
    Vertex vfModule1 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "vfModule1").property("model-invariant-id-local", "model-invariant-id-9").property("model-version-id-local", "model-version-id-9").next();
    Vertex vfModule2 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "vfModule2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex vfModule3 = g.addV().property("aai-node-type", "vf-module").property("vf-module-id", "vfModule3").property("model-invariant-id-local", "model-invariant-id-9").property("model-version-id-local", "model-version-id-9").next();
    edgeSerializer.addPrivateEdge(traversal, vfModule3, modelVer9, null);
    // Add model10/model-ver10
    Vertex model10 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-10").property("model-type", "widget").next();
    Vertex modelVer10 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-10").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-10/model-vers/model-ver/model-version-id-10").property("model-name", "collection").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model10, modelVer10);
    // collection
    Vertex collection1 = g.addV().property("aai-node-type", "collection").property("collection-id", "collection1").property("model-invariant-id-local", "model-invariant-id-10").property("model-version-id-local", "model-version-id-10").next();
    Vertex collection2 = g.addV().property("aai-node-type", "collection").property("collection-id", "collection2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex collection3 = g.addV().property("aai-node-type", "collection").property("collection-id", "collection3").property("model-invariant-id-local", "model-invariant-id-10").property("model-version-id-local", "model-version-id-10").next();
    edgeSerializer.addPrivateEdge(traversal, collection3, modelVer10, null);
    // Add model11/model-ver11
    Vertex model11 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-11").property("model-type", "widget").next();
    Vertex modelVer11 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-11").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-11/model-vers/model-ver/model-version-id-11").property("model-name", "instance-group").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model11, modelVer11);
    // instance-group
    Vertex instanceGroup1 = g.addV().property("aai-node-type", "instance-group").property("id", "instanceGroup1").property("model-invariant-id-local", "model-invariant-id-11").property("model-version-id-local", "model-version-id-11").next();
    Vertex instanceGroup2 = g.addV().property("aai-node-type", "instance-group").property("id", "instanceGroup2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex instanceGroup3 = g.addV().property("aai-node-type", "instance-group").property("id", "instanceGroup3").property("model-invariant-id-local", "model-invariant-id-11").property("model-version-id-local", "model-version-id-11").next();
    edgeSerializer.addPrivateEdge(traversal, instanceGroup3, modelVer11, null);
    // Add model12/model-ver12
    Vertex model12 = g.addV().property("aai-node-type", "model").property("model-invariant-id", "model-invariant-id-12").property("model-type", "widget").next();
    Vertex modelVer12 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-12").property("aai-uri", "/service-design-and-creation/models/model/model-invariant-id-12/model-vers/model-ver/model-version-id-12").property("model-name", "allotted-resource").property("model-version", "v1.0").next();
    edgeSerializer.addTreeEdge(g, model12, modelVer12);
    // allotted-resource
    Vertex allottedResource1 = g.addV().property("aai-node-type", "allotted-resource").property("id", "allottedResource1").property("model-invariant-id-local", "model-invariant-id-12").property("model-version-id-local", "model-version-id-12").next();
    Vertex allottedResource2 = g.addV().property("aai-node-type", "allotted-resource").property("id", "allottedResource2").property("model-invariant-id-local", "model-invariant-id-y").property("model-version-id-local", "model-version-id-y").next();
    Vertex allottedResource3 = g.addV().property("aai-node-type", "allotted-resource").property("id", "allottedResource3").property("model-invariant-id-local", "model-invariant-id-12").property("model-version-id-local", "model-version-id-12").next();
    edgeSerializer.addPrivateEdge(traversal, allottedResource3, modelVer12, null);
    migration = new MigrateModelVer(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
    migration.run();
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Before(org.junit.Before)

Example 20 with TransactionalGraphEngine

use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.

the class EdgeMigratorTest method setUp.

@Before
public void setUp() {
    graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
    JanusGraphManagement janusgraphManagement = graph.openManagement();
    tx = graph.newTransaction();
    g = tx.traversal();
    Loader loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
    TransactionalGraphEngine dbEngine = new JanusGraphDBEngine(queryStyle, loader);
    Vertex gvnf = g.addV().property(AAIProperties.NODE_TYPE, "generic-vnf").property("vnf-id", "toscaMigration-test-vnf").next();
    Vertex lInterface = g.addV().property(AAIProperties.NODE_TYPE, "l-interface").property("interface-name", "toscaMigration-test-lint").next();
    Vertex logicalLink = g.addV().property(AAIProperties.NODE_TYPE, "logical-link").property("link-name", "toscaMigration-logical-link").next();
    gvnf.addEdge("has", lInterface, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(), EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
    lInterface.addEdge("usesLogicalLink", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
    lInterface.addEdge("sourceLInterface", logicalLink, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
    Vertex pserver = g.addV().next();
    pserver.property("aai-node-type", "pserver", "hostname", "a-name");
    Vertex vnfc = g.addV().next();
    vnfc.property("aai-node-type", "vnfc", "vnfc-name", "a-name");
    pserver.addEdge("blah", vnfc, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(), EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
    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();
    edgeMigrator = new EdgeMigratorImpl(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
}
Also used : JanusGraphManagement(org.janusgraph.core.schema.JanusGraphManagement) TransactionalGraphEngine(org.onap.aai.serialization.engines.TransactionalGraphEngine) GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) JanusGraphDBEngine(org.onap.aai.serialization.engines.JanusGraphDBEngine) Loader(org.onap.aai.introspection.Loader) Before(org.junit.Before)

Aggregations

TransactionalGraphEngine (org.onap.aai.serialization.engines.TransactionalGraphEngine)86 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)60 JanusGraphDBEngine (org.onap.aai.serialization.engines.JanusGraphDBEngine)45 Loader (org.onap.aai.introspection.Loader)42 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)33 Before (org.junit.Before)31 Test (org.junit.Test)24 Introspector (org.onap.aai.introspection.Introspector)23 Graph (org.apache.tinkerpop.gremlin.structure.Graph)18 Matchers.containsString (org.hamcrest.Matchers.containsString)18 JanusGraph (org.janusgraph.core.JanusGraph)18 DBSerializer (org.onap.aai.serialization.db.DBSerializer)18 AAIException (org.onap.aai.exceptions.AAIException)9 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)8 SchemaVersion (org.onap.aai.setup.SchemaVersion)8 URI (java.net.URI)6 QueryParser (org.onap.aai.parsers.query.QueryParser)6 JsonObject (com.google.gson.JsonObject)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 URIToObject (org.onap.aai.parsers.uri.URIToObject)4