Update the license for 2017-2018 license
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / LinkedDevices_SimpleGVtoGVQueryTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
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 package org.onap.aai.rest.search;
21
22 import java.util.Map;
23
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;
29 import org.onap.aai.exceptions.AAIException;
30 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
31
32 public class LinkedDevices_SimpleGVtoGVQueryTest extends QueryTest {
33
34         public LinkedDevices_SimpleGVtoGVQueryTest() throws AAIException, NoEdgeRuleFoundException {
35                 super();
36         }
37         
38         @Test
39         public void run() {
40                 super.run();
41         }
42
43         @Override
44         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
45                 Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf", 
46                                                         "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
47                 
48                 Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
49                                                         "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
50                 
51                 Vertex loglink = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
52                                                         "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
53                 
54                 Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
55                                 "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
56                 
57                 Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf", 
58                                 "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
59                 
60                 GraphTraversalSource g = graph.traversal();
61                 rules.addTreeEdge(g, gvnf1, lint1);
62                 rules.addTreeEdge(g, gvnf2, lint2);
63                 rules.addEdge(g, lint1, loglink);
64                 rules.addEdge(g, lint2, loglink);
65                 
66                 expectedResult.add(gvnf1);
67                 expectedResult.add(gvnf2);
68         }
69
70         @Override
71         protected String getQueryName() {
72                 return "linked-devices";
73         }
74
75         @Override
76         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
77                 g.has("aai-node-type","generic-vnf").has("vnf-id","gvnf1");
78         }
79
80         @Override
81         protected void addParam(Map<String, Object> params) {
82                 // n/a for this test
83         }
84
85 }