Change all the packages from openecomp to onap
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / PserverfromConfigurationFilterInterfaceIdTest.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
32 import org.onap.aai.exceptions.AAIException;
33 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
34
35 public class PserverfromConfigurationFilterInterfaceIdTest extends QueryTest {
36         public PserverfromConfigurationFilterInterfaceIdTest() 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
48                 // Set up the test graph
49                 Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
50                 Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
51                 Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername1");
52                 Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "loglink1", "in-maint", "false",
53                                 "link-type", "link-type1");
54                 Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
55                                 "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
56
57                 // Following are extra nodes that should not be picked up in
58                 // expectedResults
59                 Vertex config2 = graph.addVertex(T.label, "configuration", T.id, "11", "aai-node-type", "configuration", "configuration-id", "configuration2");
60                 Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "12", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
61                 Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "13", "aai-node-type", "pserver", "hostname", "pservername2");
62                 Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "14", "aai-node-type", "logical-link", "link-name", "loglink2", "in-maint", "false",
63                                 "link-type", "link-type2");
64                 Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored",
65                                 "true", "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id2");
66
67                 GraphTraversalSource g = graph.traversal();
68                 rules.addEdge(g, config1, loglink1);
69                 rules.addEdge(g, config1, loglink2);
70                 rules.addEdge(g, lint1, loglink1);
71                 rules.addEdge(g, lint2, loglink1);
72                 rules.addEdge(g, loglink1, pserver1);
73                 rules.addEdge(g, loglink1, gvnf1);
74
75                 // These should not be picked up in expectedResults
76                 //rules.addEdge(g, config2, loglink2);
77                 rules.addEdge(g, lint2, loglink2);
78                 rules.addEdge(g, loglink2, pserver2);
79                 rules.addEdge(g, loglink2, gvnf2);
80
81                 // Note lint2 is not in expectedResults as the filter is based on
82                 // interface-id1
83                 expectedResult.add(config1);
84                 expectedResult.add(lint1);
85                 expectedResult.add(pserver1);
86                 expectedResult.add(gvnf1);
87
88         }
89
90         @Override
91         protected String getQueryName() {
92                 return "pserver-fromConfigurationFilterInterfaceId";
93         }
94
95         @Override
96         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
97                 g.has("configuration-id", "configuration1");
98         }
99
100         @Override
101         protected void addParam(Map<String, Object> params) {
102                 params.put("interfaceId", "interface-id1");
103         }
104 }