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 PserverfromConfigurationTest extends QueryTest {
34 public PserverfromConfigurationTest() throws AAIException, NoEdgeRuleFoundException {
44 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
46 // Set up the test graph
47 Vertex config1 = graph.addVertex(T.label, "configuration", T.id, "1", "aai-node-type", "configuration", "configuration-id", "configuration1");
48 Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "2", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1");
49 Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "3", "aai-node-type", "pserver", "hostname", "pservername1");
50 Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "loglink1", "in-maint", "false",
51 "link-type", "link-type1");
52 Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "5", "aai-node-type", "l-interface", "interface-name", "lint1", "is-port-mirrored", "true",
53 "in-maint", "true", "is-ip-unnumbered", "false", "interface-id", "interface-id1");
54 Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "17", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
57 // Following are extra nodes that should not be picked up in
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, "16", "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 Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "18", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor2", "equip-model",
69 GraphTraversalSource g = graph.traversal();
70 rules.addEdge(g, config1, loglink1);
71 rules.addEdge(g, lint1, loglink1);
72 rules.addEdge(g, lint2, loglink1);
73 rules.addEdge(g, loglink1, pserver1);
74 rules.addEdge(g, loglink1, gvnf1);
75 rules.addEdge(g, gvnf1, pnf1);
77 // These should not be picked up in expectedResults
78 rules.addEdge(g, config2, loglink2);
79 rules.addEdge(g, loglink2, pserver2);
80 rules.addEdge(g, loglink2, gvnf2);
81 rules.addEdge(g, gvnf2, pnf2);
83 expectedResult.add(config1);
84 expectedResult.add(lint1);
85 expectedResult.add(lint2);
86 expectedResult.add(pserver1);
87 expectedResult.add(gvnf1);
88 expectedResult.add(pnf1);
93 protected String getQueryName() {
94 return "pserver-fromConfiguration";
98 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
99 g.has("configuration-id", "configuration1");
103 protected void addParam(Map<String, Object> params) {