Update the license for 2017-2018 license
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / OwningEntityfromServiceInstance.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 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;
29
30 import java.util.Map;
31
32 public class OwningEntityfromServiceInstance extends QueryTest {
33         public OwningEntityfromServiceInstance () throws AAIException, NoEdgeRuleFoundException {
34                 super();
35         }
36
37         @Test
38         public void run() {
39                 super.run();
40         }
41
42         @Override
43         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
44
45                 // Set up the test graph
46                 Vertex service_instance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-1");
47                 Vertex owning_entity = graph.addVertex(T.label, "owning-entity", T.id, "2", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-1",  "owning-entity-name", "owning-entity-name1");
48
49                 // adding extra vertices and edges which shouldn't be picked.
50                 Vertex service_instance2 = graph.addVertex(T.label, "service-instance", T.id, "3", "aai-node-type", "service-instance", "service-instance-id", "service-instance-2");
51                 Vertex owning_entity2 = graph.addVertex(T.label, "owning-entity", T.id, "4", "aai-node-type", "owning-entity", "owning-entity-id", "owning-entity-id-2",  "owning-entity-name", "owning-entity-name2");
52
53                 GraphTraversalSource g = graph.traversal();
54                 rules.addEdge(g, owning_entity, service_instance);
55                 rules.addEdge(g, owning_entity2, service_instance2);
56
57                 expectedResult.add(owning_entity);
58         }
59
60         @Override
61         protected String getQueryName() {
62                 return "owning-entity-fromService-instance";
63         }
64
65         @Override
66         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
67                 g.has("service-instance-id", "service-instance-1");
68         }
69
70         @Override
71         protected void addParam(Map<String, Object> params) {
72                 return;
73         }
74 }