2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.rest.search;
24 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
26 import org.apache.tinkerpop.gremlin.structure.T;
27 import org.apache.tinkerpop.gremlin.structure.Vertex;
28 import org.junit.Test;
30 import org.onap.aai.exceptions.AAIException;
31 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
33 public class GfpVserverDataQueryTest extends QueryTest {
34 public GfpVserverDataQueryTest() throws AAIException, NoEdgeRuleFoundException {
42 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
44 Vertex genericvnf = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnfid0", "nf-type", "sample-nf-type");
45 Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "1", "aai-node-type", "cloud-region", "cloud-region-id", "regionid0", "cloud-owner", "cloudOwnername0");
46 Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "2", "aai-node-type", "tenant", "tenant-id", "tenantid0", "tenant-name", "tenantName0");
47 Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "3", "aai-node-type", "vserver", "vserver-id", "vserverid0");
48 Vertex linterface = graph.addVertex(T.label, "l-interface", T.id, "4", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id0", "l-interface-name", "l-interface-name0");
49 Vertex l3inter1ipv4addresslist = graph.addVertex(T.label, "interface-ipv4-address-list", T.id, "5", "aai-node-type", "l3-interface-ipv4-address-list", "l3-interface-ipv4-address", "l3-interface-ipv4-address-0");
50 Vertex l3inter1ipv6addresslist = graph.addVertex(T.label, "l3-interface-ipv6-address-list", T.id, "8", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address", "l3-interface-ipv6-address-0");
51 Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "9", "aai-node-type", "vlan", "vlan-interface", "vlan-interface0");
52 Vertex sriovVf = graph.addVertex(T.label, "sriov-vf", T.id, "10", "aai-node-type", "sriov-vf", "pci-id", "pci-id0");
54 GraphTraversalSource g = graph.traversal();
56 rules.addTreeEdge(g, tenant, cloudregion);
57 rules.addTreeEdge(g, vserver, tenant);
58 rules.addEdge(g, genericvnf, vserver);
59 rules.addTreeEdge(g, linterface, vserver);
60 rules.addTreeEdge(g, l3inter1ipv4addresslist, linterface);
61 rules.addTreeEdge(g, l3inter1ipv6addresslist, linterface);
62 rules.addTreeEdge(g, vlan, linterface);
63 rules.addTreeEdge(g, sriovVf, linterface);
65 expectedResult.add(l3inter1ipv4addresslist);
66 expectedResult.add(l3inter1ipv6addresslist);
67 expectedResult.add(vlan);
70 protected String getQueryName() {
71 return "gfp-vserver-data";
74 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
75 g.has("aai-node-type", "vserver");
79 protected void addParam(Map<String, Object> params) {