Change all the packages from openecomp to onap
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / LinkedDevices_ComplicatedGVtoGV.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  *
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.rest.search;
23
24 import java.util.Map;
25
26 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
27 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
28 import org.apache.tinkerpop.gremlin.structure.T;
29 import org.apache.tinkerpop.gremlin.structure.Vertex;
30 import org.junit.Test;
31 import org.onap.aai.exceptions.AAIException;
32 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
33
34 public class LinkedDevices_ComplicatedGVtoGV extends QueryTest {
35
36         public LinkedDevices_ComplicatedGVtoGV() throws AAIException, NoEdgeRuleFoundException {
37                 super();
38         }
39         
40         @Test
41         public void run() {
42                 super.run();
43         }
44
45         @Override
46         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
47                 Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf", 
48                                                 "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
49                 
50                 Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
51                                                 "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
52                 
53                 Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
54                                                 "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
55                 
56                 Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
57                                                 "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
58
59                 Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "30", "aai-node-type", "vlan",
60                                                 "vlan-interface", "vlan1");
61                 
62                 Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link",
63                                                 "link-name", "loglink2", "in-maint", "false", "link-type", "sausage");
64                 
65                 Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "40", "aai-node-type", "lag-interface", 
66                                                 "interface-name", "lagint1");
67                 
68                 Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf", 
69                                                 "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
70                 
71                 GraphTraversalSource g = graph.traversal();
72                 rules.addTreeEdge(g, gvnf1, lint1);
73                 rules.addEdge(g, lint1, loglink1);
74                 rules.addEdge(g, lint2, loglink1);
75                 rules.addTreeEdge(g, lint2, vlan);
76                 rules.addEdge(g, vlan, loglink2);
77                 rules.addEdge(g, loglink2, lagint);
78                 rules.addTreeEdge(g, gvnf2, lagint);
79                 
80                 expectedResult.add(gvnf1);
81                 expectedResult.add(gvnf2);
82         }
83
84         @Override
85         protected String getQueryName() {
86                 return "linked-devices";
87         }
88
89         @Override
90         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
91                 g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvnf1");
92         }
93
94         @Override
95         protected void addParam(Map<String, Object> params) {
96                 // n/a for this query
97         }
98
99 }