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 ComplexFromVnfTest extends QueryTest {
34 public ComplexFromVnfTest() throws AAIException, NoEdgeRuleFoundException {
44 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
45 //Set up the test graph
46 Vertex gnvf1 = graph.addVertex(T.label, "generic-vnf", T.id, "0", "aai-node-type", "generic-vnf", "vnf-id", "vnf-id-1", "vnf-name", "vnf-name-1");
47 Vertex vserver1 = graph.addVertex(T.label, "vserver", T.id, "1", "aai-node-type", "vserver", "vserver-id", "vserver-id-1", "vserver-name", "vserver-name-1");
48 Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "hostname-1");
49 Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "3", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1", "country", "US");
51 Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "hostname-2");
52 Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "6", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2", "country", "US");
54 GraphTraversalSource g = graph.traversal();
55 rules.addEdge(g, gnvf1, vserver1);
56 rules.addEdge(g, vserver1, pserver1);
57 rules.addEdge(g, pserver1, complex1);
58 rules.addEdge(g, gnvf1, pserver2);
59 rules.addEdge(g, pserver2, complex2);
61 expectedResult.add(gnvf1);
62 expectedResult.add(pserver1);
63 expectedResult.add(complex1);
64 expectedResult.add(pserver2);
65 expectedResult.add(complex2);
69 protected String getQueryName() {
70 return "complex-fromVnf";
73 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
74 g.has("vnf-name", "vnf-name-1");
78 protected void addParam(Map<String, Object> params) {