Add the service model custom query 31/25931/1
authorVenkata Harish K Kajur <vk250x@att.com>
Fri, 8 Dec 2017 22:10:09 +0000 (17:10 -0500)
committerVenkata Harish K Kajur <vk250x@att.com>
Fri, 8 Dec 2017 22:10:14 +0000 (17:10 -0500)
Issue-ID: AAI-557
Change-Id: Ibe6ab6a565d0db65edd29e110ad1283c1af4e3f0
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java [new file with mode: 0644]

index 6a7c344..0ea6ab6 100644 (file)
@@ -406,4 +406,13 @@ queryvnfFromModelbyRegion=builder.createEdgeTraversal(EdgeType.COUSIN, 'service-
                             .createEdgeTraversal(EdgeType.TREE, 'tenant', 'cloud-region')\
                             .getVerticesByProperty('cloud-region-id', cloudRegionId)\
                         ).store('x')\
-                        .cap('x').unfold().dedup()
\ No newline at end of file
+                        .cap('x').unfold().dedup()
+
+serviceModels-byDistributionStatus=builder.where(\
+                                                                       builder.newInstance().createEdgeTraversal(EdgeType.TREE,'model', 'model-ver')\
+                                                                               .getVerticesByProperty('distribution-status', distributionStatus)\
+                                                                                       ).store('x')\
+                                                                       .createEdgeTraversal(EdgeType.TREE,'model', 'model-ver')\
+                                                                               .getVerticesByProperty('distribution-status', distributionStatus)\
+                                                                                       .store('x').cap('x').unfold().dedup()
+                               
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ServiceModelsByDistributionStatusTest.java
new file mode 100644 (file)
index 0000000..abf9139
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.aai.rest.search;
+
+import java.util.Map;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class ServiceModelsByDistributionStatusTest extends QueryTest {
+       public ServiceModelsByDistributionStatusTest() throws AAIException, NoEdgeRuleFoundException {
+               super();
+       }
+
+       @Test
+       public void run() {
+               super.run();
+       }
+       @Override
+       protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+               //Set up the test graph 
+        Vertex model1 = graph.addVertex(T.label, "model", T.id, "1", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-1", "model-type", "resource");
+        Vertex modelver1 = graph.addVertex(T.label, "model-ver", T.id, "2", "aai-node-type", "model-ver", "model-version-id", "model-version-id-1","model-name","model-name1", "model-version","model-version-1", "distribution-status", "distribution-status1");
+        Vertex modelver11 = graph.addVertex(T.label, "model-ver", T.id, "21", "aai-node-type", "model-ver", "model-version-id", "model-version-id-11","model-name","model-name11", "model-version","model-version-1", "distribution-status", "distribution-status2");
+        
+        Vertex model2 = graph.addVertex(T.label, "model", T.id, "3", "aai-node-type", "model", "model-invariant-id", "model-invariant-id-2", "model-type", "resource");
+        Vertex modelver2 = graph.addVertex(T.label, "model-ver", T.id, "4", "aai-node-type", "model-ver", "model-version-id", "model-version-id-2","model-name","model-name2", "model-version","model-version-1", "distribution-status", "distribution-status2");
+               GraphTraversalSource g = graph.traversal();
+
+               rules.addTreeEdge(g, modelver1, model1);
+               rules.addTreeEdge(g, modelver11, model1);
+               rules.addTreeEdge(g, modelver2, model1);
+               
+               expectedResult.add(model1);
+               expectedResult.add(modelver11);
+               expectedResult.add(modelver2);
+
+       }
+       @Override
+       protected String getQueryName() {
+               return "serviceModels-byDistributionStatus";
+       }
+       @Override
+       protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+               g.has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1");
+       }
+       
+       @Override
+       protected void addParam(Map<String, Object> params) {
+               params.put("distributionStatus", "distribution-status2");
+               return;
+       }
+}