use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-aai-common by onap.
the class OwnerCheckTest method shouldPassIfDataOwnerIsEmpty.
@Test
public void shouldPassIfDataOwnerIsEmpty() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
obj.setValue("pnf-name", "my-pnf");
obj.setValue("model-invariant-id", "key1");
obj.setValue("model-version-id", "key2");
obj.setValue("data-owner", "");
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
Graph g = graph.newTransaction();
GraphTraversalSource traversal = g.traversal();
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
DBSerializer serializer = new DBSerializer(schemaVersions.getDefaultVersion(), spy, introspectorFactoryType, "AAI_TEST");
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
OwnerCheck ownerCheck = new OwnerCheck(obj, selfV, spy, serializer);
assertNotNull(ownerCheck);
ownerCheck.execute();
g.tx().rollback();
}
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();
}
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);
// zone
g.addV().property("aai-node-type", "zone").property("zone-id", "zone0").next();
g.addV().property("aai-node-type", "zone").property("zone-id", "zone1").property("in-maint", "").next();
g.addV().property("aai-node-type", "zone").property("zone-id", "zone2").property("in-maint", true).next();
g.addV().property("aai-node-type", "zone").property("zone-id", "zone3").property("in-maint", false).next();
// cloud-region
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region0").next();
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region1").property("in-maint", "").next();
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region2").property("in-maint", true).next();
g.addV().property("aai-node-type", "cloud-region").property("cloud-region-id", "cloud-region3").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();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class MigrateGenericVnfMgmtOptionsTest 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").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();
}
use of org.onap.aai.serialization.engines.TransactionalGraphEngine in project aai-graphadmin by onap.
the class MigrateNetworkTechToCloudRegionTest method setUp.
@Before
public void setUp() throws Exception {
g = tx.traversal();
loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
dbEngine = new JanusGraphDBEngine(queryStyle, 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();
}*/
}
Aggregations