Update traversal from AJSC 2 to Spring Boot
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / UcpeInstanceQueryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright (C) 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
21 package org.onap.aai.rest.search;
22
23 import java.util.Map;
24
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
26 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
27 import org.apache.tinkerpop.gremlin.structure.T;
28 import org.apache.tinkerpop.gremlin.structure.Vertex;
29 import org.junit.Test;
30
31 import org.onap.aai.exceptions.AAIException;
32 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
33
34 public class UcpeInstanceQueryTest extends QueryTest {
35
36         public UcpeInstanceQueryTest() 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 complex = graph.addVertex(T.label, "complex", T.id, "0", "aai-node-type", "complex", "physical-location-id", "clli");
48                 Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "1", "aai-node-type", "pserver", "hostname", "pservername");
49                 Vertex pnf = graph.addVertex(T.label, "pnf", T.id, "11", "aai-node-type", "pnf", "pnf-name", "pnfname");
50                 Vertex vnf = graph.addVertex(T.label, "generic-vnf", T.id, "7", "aai-node-type", "generic-vnf", "vnf-id", "vnfuuid");
51                 Vertex pserverint = graph.addVertex(T.label, "p-interface", T.id, "2", "aai-node-type", "p-interface", "interface-name", "xe0/0/0");
52                 Vertex pnfint = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "ge0/0/0");
53                 
54                 GraphTraversalSource g = graph.traversal();
55                 rules.addEdge(g, pserver, complex);
56                 rules.addEdge(g, pnf, complex);
57                 rules.addEdge(g, vnf, pserver);
58                 rules.addTreeEdge(g, pserver, pserverint);
59                 rules.addTreeEdge(g, pnf, pnfint);
60                 
61                 expectedResult.add(complex);
62                 expectedResult.add(pserver);
63                 //expectedResult.add(pnf);
64                 
65         }
66
67         @Override
68         protected String getQueryName() {
69                 return "ucpe-instance";
70         }
71
72         @Override
73         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
74                 g.has("hostname", "pservername");
75                 //g.has("pnf-name", "pnfname");
76         }
77
78         @Override
79         protected void addParam(Map<String, Object> params) {
80                 return;
81                 
82         }
83
84 }