Update the license for 2017-2018 license
[aai/traversal.git] / aai-traversal / src / test / java / org / onap / aai / rest / search / VnfInstancesFromServiceInstancebyModelVersionTest.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 java.util.Map;
23
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;
29 import org.onap.aai.exceptions.AAIException;
30 import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
31
32 public class VnfInstancesFromServiceInstancebyModelVersionTest extends QueryTest {
33         public VnfInstancesFromServiceInstancebyModelVersionTest() throws AAIException, NoEdgeRuleFoundException {
34                 super();
35         }
36         
37         @Test
38         public void run() {
39                 super.run();
40         }
41         @Override
42         protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
43                 
44                 
45                 //Set up the test graph 
46         Vertex serviceinstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1");
47         Vertex servicesubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", "service-subscription-id", "service-subscription-id-1","service-subscription-name","service-subscription-name1");
48         Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "customer-id", "customer-id-1", "customer-name", "customer-name1");
49         
50                 Vertex model1 = graph.addVertex(T.label, "model", T.id, "4", "aai-node-type", "model", "model-invariant-id", "modinvariant-id1", "model-type", "modtype");
51                 Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "5", "aai-node-type", "model-ver", "model-version-id", "modver-id1", "model-name", "modname1", "model-version", "v1.0");
52                 Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "6", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "vnfname1", "vnf-type", "vnftype1", "model-invariant-id-local", "modinvariant-id1", "model-version-id-local", "modver-id1");
53                 
54 //              Vertex model2 = graph.addVertex(T.label, "model", T.id, "7", "aai-node-type", "model", "model-invariant-id", "modinvariant-id2", "model-type", "modtype");
55 //              Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "8", "aai-node-type", "model-ver", "model-version-id", "modver-id2", "model-name", "modname2", "model-version", "v1.0");
56                 Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2", "vnf-name", "vnfname2", "vnf-type", "vnftype2", "model-invariant-id-local", "modinvariant-id1", "model-version-id-local", "modver-id1");
57
58                 
59                 GraphTraversalSource g = graph.traversal();
60                 rules.addTreeEdge(g, model1, modelver1);//true
61                 rules.addEdge(g, vnf1, serviceinstance);//true
62                 rules.addEdge(g, vnf2, serviceinstance);//false
63         rules.addTreeEdge(g, serviceinstance, servicesubscription);//true
64         rules.addTreeEdge(g, servicesubscription, customer);//true
65        
66                 expectedResult.add(vnf1);
67
68         }
69         @Override
70         protected String getQueryName() {
71                 return "vnf-instances-fromServiceInstancebyModelVersion";
72         }
73         @Override
74         protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
75                 g.has("aai-node-type", "service-instance").has("service-instance-id", "service-instance-id-1");
76         }
77         
78         @Override
79         protected void addParam(Map<String, Object> params) {
80                 params.put("vnfType", "vnftype1");
81                 params.put("modelVersionId", "modver-id1");
82         }
83 }