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;
22 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
23 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
24 import org.apache.tinkerpop.gremlin.structure.T;
25 import org.apache.tinkerpop.gremlin.structure.Vertex;
26 import org.junit.Test;
27 import org.onap.aai.exceptions.AAIException;
28 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
32 public class QueryPnfFromModelByRegionTest extends QueryTest {
33 public QueryPnfFromModelByRegionTest() throws AAIException, NoEdgeRuleFoundException {
43 protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
46 //serviceInstance 1,2,3 are good and 4 is bad based upon the filters
47 Vertex serviceInst1 = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id",
48 "service-instance1", "model-invariant-id", "miid1", "model-version-id", "mvid1");
49 Vertex serviceInst2 = graph.addVertex(T.label, "service-instance", T.id, "2", "aai-node-type", "service-instance", "service-instance-id",
50 "service-instance2", "model-invariant-id", "miid1", "model-version-id", "mvid1");
51 Vertex serviceInst3 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id",
52 "service-instance3", "model-invariant-id", "miid1", "model-version-id", "mvid1");
53 Vertex serviceInst4 = graph.addVertex(T.label, "service-instance", T.id, "4", "aai-node-type", "service-instance", "service-instance-id",
54 "service-instance4", "model-invariant-id", "miid2", "model-version-id", "mvid2");
56 //pnf 1,2 & 3 are good based upon the filters
57 Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "5", "aai-node-type", "pnf", "pnf-name", "pnf1name", "equip-vendor", "equip-vendor1", "equip-model",
59 Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "6", "aai-node-type", "pnf", "pnf-name", "pnf2name", "equip-vendor", "equip-vendor1", "equip-model",
61 Vertex pnf3 = graph.addVertex(T.label, "pnf", T.id, "7", "aai-node-type", "pnf", "pnf-name", "pnf3name", "equip-vendor", "equip-vendor1", "equip-model",
63 Vertex pnf4 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnf4name", "equip-vendor", "equip-vendor4",
64 "equip-model", "equip-model4");
66 Vertex complex1 = graph.addVertex(T.label, "complex", T.id, "8", "aai-node-type", "complex", "physical-location-id", "physical-location-id-1");
67 Vertex complex2 = graph.addVertex(T.label, "complex", T.id, "9", "aai-node-type", "complex", "physical-location-id", "physical-location-id-2");
69 //cr 1 is good based upon the filter
70 Vertex cloudRegion1 = graph.addVertex(T.label, "cloud-region", T.id, "10", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region1");
71 Vertex cloudRegion2 = graph.addVertex(T.label, "cloud-region", T.id, "11", "aai-node-type", "cloud-region", "cloud-region-id", "cloud-region2");
74 GraphTraversalSource g = graph.traversal();
75 rules.addEdge(g, serviceInst1, pnf1);
76 rules.addEdge(g, serviceInst2, pnf2);
77 rules.addEdge(g, serviceInst3, pnf3);
78 rules.addEdge(g, serviceInst4, pnf4);
80 rules.addEdge(g, pnf1, complex1);
81 rules.addEdge(g, pnf2, complex1);
82 rules.addEdge(g, pnf3, complex2);
83 rules.addEdge(g, pnf4, complex2);
85 rules.addEdge(g, cloudRegion1, complex1);
86 rules.addEdge(g, cloudRegion2, complex2);
89 expectedResult.add(pnf1);
90 expectedResult.add(pnf2);
94 protected String getQueryName() {
95 return "pnf-fromModel-byRegion";
99 protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
100 g.has("model-invariant-id", "miid1").has("model-version-id", "mvid1");
104 protected void addParam(Map<String, Object> params) {
105 params.put("cloudRegionId", "cloud-region1");
106 params.put("equipVendor", "equip-vendor1");
107 params.put("equipModel", "equip-model1");