Force depth zero on all dsl queries 25/116725/1
authorBenjamin, Max (mb388a) <mb388a@att.com>
Mon, 11 Jan 2021 15:55:22 +0000 (10:55 -0500)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Mon, 11 Jan 2021 15:55:22 +0000 (10:55 -0500)
Force depth zero on all dsl queries by default
A&AI queries take too long otherwise

Issue-ID: SO-3475
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I57576384d8de01b7cc56df77cc1b20fa951d6e93

graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java
graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryQueryClient.java
graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIQueryClientTest.java

index 378db87..8b8707e 100644 (file)
@@ -25,6 +25,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIFluentTypeReverseLookup;
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
 import org.onap.aaiclient.client.graphinventory.GraphInventoryQueryClient;
 import org.onap.aaiclient.client.graphinventory.entities.DSLQuery;
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
 import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri;
 import com.google.common.collect.ImmutableMap;
 
@@ -41,7 +42,7 @@ public class AAIDSLQueryClient
 
     @Override
     protected GraphInventoryUri getQueryUri() {
-        return AAIUriFactory.createResourceUri(AAIObjectType.DSL);
+        return AAIUriFactory.createResourceUri(AAIObjectType.DSL).depth(Depth.ZERO);
     }
 
 
index a192e38..1438dbe 100644 (file)
@@ -32,6 +32,7 @@ import org.onap.aaiclient.client.aai.entities.Results;
 import org.onap.aaiclient.client.graphinventory.entities.GraphInventoryResultWrapper;
 import org.onap.aaiclient.client.graphinventory.entities.Pathed;
 import org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl;
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
 import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri;
 import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
 import com.fasterxml.jackson.core.type.TypeReference;
@@ -39,7 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInventoryResultWrapper<?>, Type extends GraphInventoryObjectType> {
 
-    private Optional<String> depth = Optional.empty();
+    private Optional<Depth> depth = Optional.empty();
     private boolean nodesOnly = false;
     private Optional<GraphInventorySubgraphType> subgraph = Optional.empty();
     private GraphInventoryClient client;
@@ -108,7 +109,7 @@ public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInven
 
     public abstract Type createType(String name, String uri);
 
-    public S depth(String depth) {
+    public S depth(Depth depth) {
         this.depth = Optional.of(depth);
         return (S) this;
     }
@@ -128,7 +129,7 @@ public abstract class GraphInventoryQueryClient<S, I, Wrapper extends GraphInven
     protected GraphInventoryUri setupQueryParams(GraphInventoryUri uri) {
         GraphInventoryUri clone = uri.clone();
         if (this.depth.isPresent()) {
-            clone.queryParam("depth", depth.get());
+            clone.queryParam("depth", depth.get().toString());
         }
         if (this.nodesOnly) {
             clone.queryParam("nodesOnly", "");
index 29d8624..a3b026a 100644 (file)
@@ -54,6 +54,7 @@ import org.onap.aaiclient.client.graphinventory.GraphInventoryClient;
 import org.onap.aaiclient.client.graphinventory.GraphInventorySubgraphType;
 import org.onap.aaiclient.client.graphinventory.entities.Pathed;
 import org.onap.aaiclient.client.graphinventory.entities.ResourceAndUrl;
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
 import org.onap.so.client.RestClient;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -92,7 +93,7 @@ public class AAIQueryClientTest {
 
     @Test
     public void testCreateClient() {
-        String depth = "testDepth";
+        Depth depth = Depth.ZERO;
         GraphInventorySubgraphType subgraph = GraphInventorySubgraphType.STAR;
 
         aaiQueryClient.depth(depth);
@@ -103,7 +104,7 @@ public class AAIQueryClientTest {
         doReturn(aaiUri).when(aaiUri).clone();
         aaiQueryClient.setupQueryParams(aaiUri);
 
-        verify(aaiUri, times(1)).queryParam("depth", depth);
+        verify(aaiUri, times(1)).queryParam("depth", "0");
         verify(aaiUri, times(1)).queryParam("nodesOnly", "");
         verify(aaiUri, times(1)).queryParam("subgraph", subgraph.toString());
     }