Aai Simulator for CQ 60/85060/3
authorpramod.jamkhedkar <pramod@research.att.com>
Thu, 11 Apr 2019 14:03:23 +0000 (10:03 -0400)
committerpramod.jamkhedkar <pramod@research.att.com>
Thu, 11 Apr 2019 15:40:24 +0000 (11:40 -0400)
Added the aai simulator for custom query. Minor change to AaiManager

Issue-ID: POLICY-1278
Change-Id: I4d5d2a616d2ce85f3b6c539a1d90fe85ee55e093
Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
models-interactions/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java
models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/aai/AaiCqResponse.json [new file with mode: 0644]
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java

index f50f0cb..891114a 100644 (file)
@@ -50,9 +50,10 @@ public final class AaiManager {
     private final RestManager restManager;
 
     /** custom query URLs. */
-    private static String cqUrl =  "/aai/v16/query?format=resource";
-    private static String tenantUrl = "/aai/v16/search/nodes-query?search-node-type=vserver&filter=vserver-name:";
-    private static String prefix = "/aai/v16";
+    private static final String CQ_URL = "/aai/v16/query?format=resource";
+    private static final String TENANT_URL =
+            "/aai/v16/search/nodes-query?search-node-type=vserver&filter=vserver-name:EQUALS:";
+    private static final String PREFIX = "/aai/v16";
 
 
     /**
@@ -83,7 +84,7 @@ public final class AaiManager {
                 return null;
             }
             String resourceLink = resultsArray.getJSONObject(0).getString("resource-link");
-            String start = resourceLink.replace(prefix, "");
+            String start = resourceLink.replace(PREFIX, "");
             String query = "query/closed-loop";
             JSONObject payload = new JSONObject();
             payload.put("start", start);
@@ -107,7 +108,8 @@ public final class AaiManager {
     private String getCustomQueryRequestPayload(String url, String username, String password, UUID requestId,
             String vserver) {
 
-        String urlGet = url + tenantUrl;
+        String urlGet = url + TENANT_URL;
+
         String getResponse = getStringQuery(urlGet, username, password, requestId, vserver);
         return createCustomQueryPayload(getResponse);
     }
@@ -129,11 +131,12 @@ public final class AaiManager {
 
         final Map<String, String> headers = createHeaders(requestId);
 
-        url = url + cqUrl;
-
         logger.debug("RestManager.put before");
         String requestJson = getCustomQueryRequestPayload(url, username, password, requestId, vserver);
         NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson);
+
+        url = url + CQ_URL;
+
         Pair<Integer, String> httpDetails =
                 this.restManager.put(url, username, password, headers, "application/json", requestJson);
         logger.debug("RestManager.put after");
index a4694b6..756253c 100644 (file)
@@ -8,9 +8,9 @@
  * 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.
@@ -27,10 +27,10 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.TreeMap;
 import java.util.UUID;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
@@ -50,7 +50,7 @@ public class AaiSimulatorJaxRs {
 
     /**
      * A&AI get query.
-     * 
+     *
      * @param vnfId the VNF Id
      * @return the result
      */
@@ -64,9 +64,41 @@ public class AaiSimulatorJaxRs {
                 + "\"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}";
     }
 
+    /**
+     * A&AI get query.
+     *
+     * @return the result
+     */
+    @GET
+    @Path("/v16/search/nodes-query")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces("application/json")
+    public String aaiGetVserverQuery() {
+        return "{\"result-data\":[{\"resource-type\": \"vserver\",\"resource-link\":\"/aai/v15/"
+                + "cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants"
+                + "/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/"
+                + "6c3b3714-e36c-45af-9f16-7d3a73d99497\"}]}}";
+    }
+
+
+    /**
+     * A&AI put query.
+     *
+     * @param req the request
+     * @return the response
+     * @throws IOException if a response file cannot be read
+     */
+    @PUT
+    @Path("/v16/query")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces("application/json")
+    public String aaiPutQuery(final String req) throws IOException {
+        return IOUtils.toString(getClass().getResource("aai/AaiCqResponse.json"), StandardCharsets.UTF_8);
+    }
+
     /**
      * A&AI post query.
-     * 
+     *
      * @param req the request
      * @return the response
      * @throws IOException if a response file cannot be read
@@ -82,7 +114,7 @@ public class AaiSimulatorJaxRs {
             final String vserverName =
                     request.getInstanceFilters().getInstanceFilter().get(0).get(VSERVER).get("vserver-name");
             if (ERROR.equals(vserverName)) {
-                Map<String,String> params = new TreeMap<>();
+                Map<String, String> params = new TreeMap<>();
                 params.put("type", VSERVER);
                 return load("aai/AaiNqResponse-Error.json", params);
             } else {
@@ -94,7 +126,7 @@ public class AaiSimulatorJaxRs {
             final String vnfId =
                     request.getInstanceFilters().getInstanceFilter().get(0).get("generic-vnf").get("vnf-id");
             if (ERROR.equals(vnfId)) {
-                Map<String,String> params = new TreeMap<>();
+                Map<String, String> params = new TreeMap<>();
                 params.put("type", "generic-vnf");
                 return load("aai/AaiNqResponse-Error.json", params);
             } else {
@@ -105,7 +137,7 @@ public class AaiSimulatorJaxRs {
                 params.put("pnfVnfId", getUuidValue(params.get("pnfVndName"), "jimmy-test"));
 
                 params.put("serviceInstanceVnfName", "service-instance-test-" + vnfId);
-                params.put("serviceInstanceVnfId", 
+                params.put("serviceInstanceVnfId",
                         getUuidValue(params.get("serviceInstanceVnfName"), "jimmy-test-vnf2"));
 
                 return load("aai/AaiNqResponse-GenericVnf.json", params);
@@ -115,7 +147,7 @@ public class AaiSimulatorJaxRs {
 
     /**
      * Get by VNF name.
-     * 
+     *
      * @param vnfName the VNF name
      * @return the response
      */
@@ -190,7 +222,7 @@ public class AaiSimulatorJaxRs {
 
     /**
      * Get by VNF Id.
-     * 
+     *
      * @param vnfId the VNF Id
      * @return the response
      */
@@ -212,9 +244,9 @@ public class AaiSimulatorJaxRs {
                 + "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status"
                 + "\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \""
                 + "ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345"
-                + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, " 
-                + "\"prov-status\":\"ACTIVE\", \"" + ""
-                + "is-closed-loop-disabled\": " + isDisabled + ", \"resource-version\": \"1493389458092\", \""
+                + "\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, "
+                + "\"prov-status\":\"ACTIVE\", \"" + "" + "is-closed-loop-disabled\": " + isDisabled
+                + ", \"resource-version\": \"1493389458092\", \""
                 + "relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link"
                 + "\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions"
                 + "/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \""
@@ -236,7 +268,7 @@ public class AaiSimulatorJaxRs {
 
     /**
      * Get by VServer name.
-     * 
+     *
      * @param vserverName the VServer name
      * @return the response
      */
@@ -254,8 +286,7 @@ public class AaiSimulatorJaxRs {
         final String vserverId = getUuidValue(vserverName, "d0668d4f-c25e-4a1b-87c4-83845c01efd8");
         return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + vserverName
                 + "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": "
-                + isDisabled
-                + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", " 
+                + isDisabled + ", \"prov-status\":\"ACTIVE\", \"resource-version\": \"1494001931513\", "
                 + "\"relationship-list\": {\"relationship\":[{ \"related-to"
                 + "\": \"generic-vnf\", \"related-link\": \"/aai/v11/network/generic-vnfs/generic-vnf/"
                 + "e1a41e99-4ede-409a-8f9d-b5e12984203a\", \"relationship-data\": [ {\"relationship-key\": \""
@@ -272,9 +303,8 @@ public class AaiSimulatorJaxRs {
     }
 
     /**
-     * Loads a JSON response from a file and then replaces parameters of the form, ${xxx},
-     * with values.
-     * 
+     * Loads a JSON response from a file and then replaces parameters of the form, ${xxx}, with values.
+     *
      * @param fileName name of the file containing the JSON
      * @param params parameters to be substituted
      * @return the JSON response, after parameter substitution
diff --git a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/aai/AaiCqResponse.json b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/aai/AaiCqResponse.json
new file mode 100644 (file)
index 0000000..63d6f79
--- /dev/null
@@ -0,0 +1,673 @@
+{
+    "results": [
+        {
+            "vserver": {
+                "vserver-id": "e7f1db09-ff78-44fc-b256-69095c5556fb",
+                "vserver-name": "vfw-vm-0201-2",
+                "vserver-name2": "vfw-vm-0201-2",
+                "prov-status": "ACTIVE",
+                "vserver-selflink": "http://ecompctl1.research.att.com:8774/v2/3f2aaef74ecb4b19b35e26d0849fe9a2/servers/e7f1db09-ff78-44fc-b256-69095c5556fb",
+                "in-maint": false,
+                "is-closed-loop-disabled": false,
+                "resource-version": "1549553422524",
+                "relationship-list": {
+                    "relationship": [
+                        {
+                            "related-to": "generic-vnf",
+                            "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "generic-vnf.vnf-id",
+                                    "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "generic-vnf.vnf-name",
+                                    "property-value": "TestVM-Vnf-0201-1"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "vnfc",
+                            "related-link": "/aai/v11/network/vnfcs/vnfc/vfw",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "vnfc.vnfc-name",
+                                    "relationship-value": "vfw"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "vf-module",
+                            "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "generic-vnf.vnf-id",
+                                    "relationship-value": "17044ef4-e7f3-46a1-af03-e2aa562f23ac"
+                        },
+                                {
+                                    "relationship-key": "vf-module.vf-module-id",
+                                    "relationship-value": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "flavor",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/2",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "flavor.flavor-id",
+                                    "relationship-value": "2"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "flavor.flavor-name",
+                                    "property-value": "m1.small"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "image",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/84be7136-301f-4f47-9585-3a2e0f9534af",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "image.image-id",
+                                    "relationship-value": "84be7136-301f-4f47-9585-3a2e0f9534af"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "image.image-name",
+                                    "property-value": "unknown"
+                        }
+                     ]
+                  }
+               ]
+                }
+            }
+      },
+        {
+            "generic-vnf": {
+                "vnf-id": "7b202620-2936-4b0d-b09c-60b411f10f64",
+                "vnf-name": "vLoadBalancerMS-Vnf-0211-1",
+                "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0",
+                "prov-status": "ACTIVE",
+                "equipment-role": "vLB",
+                "orchestration-status": "Active",
+                "ipv4-oam-address": "10.0.150.1",
+                "in-maint": true,
+                "is-closed-loop-disabled": false,
+                "resource-version": "1552311656338",
+                "model-invariant-id": "724ab1cf-6120-49e8-b909-849963bed1d6",
+                "model-version-id": "9d5944d8-2267-4799-824a-0f824e9a978d",
+                "model-customization-id": "efcd576d-a05e-4798-bb68-79e7d9c80f4c",
+                "nf-type": "ONAP-LOADBALANCER",
+                "nf-function": "LOADBALANCER",
+                "nf-role": "vLB",
+                "nf-naming-code": "vlb",
+                "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vnf-topology/",
+                "relationship-list": {
+                    "relationship": [
+                        {
+                            "related-to": "service-instance",
+                            "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "customer.global-customer-id",
+                                    "relationship-value": "Demonstration"
+                        },
+                                {
+                                    "relationship-key": "service-subscription.service-type",
+                                    "relationship-value": "vLB"
+                        },
+                                {
+                                    "relationship-key": "service-instance.service-instance-id",
+                                    "relationship-value": "101b8fc1-1796-4db1-a4e7-fe39c6a51558"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "service-instance.service-instance-name",
+                                    "property-value": "vLoadBalancerMS-0211-1"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "platform",
+                            "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "platform.platform-name",
+                                    "relationship-value": "Test-Platform"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "line-of-business",
+                            "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "line-of-business.line-of-business-name",
+                                    "relationship-value": "Test-Business"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "vserver",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "tenant.tenant-id",
+                                    "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                        },
+                                {
+                                    "relationship-key": "vserver.vserver-id",
+                                    "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "vserver.vserver-name",
+                                    "property-value": "vdns-ms-0211-1"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "vserver",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "tenant.tenant-id",
+                                    "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                        },
+                                {
+                                    "relationship-key": "vserver.vserver-id",
+                                    "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "vserver.vserver-name",
+                                    "property-value": "vlb-ms-0211-1"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "availability-zone",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "availability-zone.availability-zone-name",
+                                    "relationship-value": "nova"
+                        }
+                     ]
+                  }
+               ]
+                },
+                "vf-modules": {
+                    "vf-module": [
+                        {
+                            "vf-module-id": "e46c6636-9ce5-4b77-bb1b-455ce9edc892",
+                            "vf-module-name": "vLoadBalancerMS-0211-1",
+                            "heat-stack-id": "vLoadBalancerMS-0211-1/73360253-2dfe-46f6-bcd6-8662a81238ea",
+                            "orchestration-status": "Active",
+                            "is-base-vf-module": true,
+                            "resource-version": "1552311559802",
+                            "model-invariant-id": "d263fc6d-cfce-4e20-8337-e06f48b474e6",
+                            "model-version-id": "24c0aa10-3979-402c-ad98-20124751b551",
+                            "model-customization-id": "65382eb1-db84-466c-b9d7-4e0f1ba7105f",
+                            "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/vnfs/vnf/7b202620-2936-4b0d-b09c-60b411f10f64/vnf-data/vf-modules/vf-module/e46c6636-9ce5-4b77-bb1b-455ce9edc892/vf-module-data/vf-module-topology/",
+                            "relationship-list": {
+                                "relationship": [
+                                    {
+                                        "related-to": "vserver",
+                                        "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/58ca8df0-17b8-4aa2-8766-9c6c1a12cec8",
+                                        "relationship-data": [
+                                            {
+                                                "relationship-key": "cloud-region.cloud-owner",
+                                                "relationship-value": "CloudOwner"
+                                 },
+                                            {
+                                                "relationship-key": "cloud-region.cloud-region-id",
+                                                "relationship-value": "RegionOne"
+                                 },
+                                            {
+                                                "relationship-key": "tenant.tenant-id",
+                                                "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                                 },
+                                            {
+                                                "relationship-key": "vserver.vserver-id",
+                                                "relationship-value": "58ca8df0-17b8-4aa2-8766-9c6c1a12cec8"
+                                 }
+                              ],
+                                        "related-to-property": [
+                                            {
+                                                "property-key": "vserver.vserver-name",
+                                                "property-value": "vdns-ms-0211-1"
+                                 }
+                              ]
+                           },
+                                    {
+                                        "related-to": "vserver",
+                                        "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/6c3b3714-e36c-45af-9f16-7d3a73d99497",
+                                        "relationship-data": [
+                                            {
+                                                "relationship-key": "cloud-region.cloud-owner",
+                                                "relationship-value": "CloudOwner"
+                                 },
+                                            {
+                                                "relationship-key": "cloud-region.cloud-region-id",
+                                                "relationship-value": "RegionOne"
+                                 },
+                                            {
+                                                "relationship-key": "tenant.tenant-id",
+                                                "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                                 },
+                                            {
+                                                "relationship-key": "vserver.vserver-id",
+                                                "relationship-value": "6c3b3714-e36c-45af-9f16-7d3a73d99497"
+                                 }
+                              ],
+                                        "related-to-property": [
+                                            {
+                                                "property-key": "vserver.vserver-name",
+                                                "property-value": "vlb-ms-0211-1"
+                                 }
+                              ]
+                           }
+                        ]
+                            }
+                  }
+               ]
+                }
+            }
+      },
+        {
+            "service-instance": {
+                "service-instance-id": "101b8fc1-1796-4db1-a4e7-fe39c6a51558",
+                "service-instance-name": "vLoadBalancerMS-0211-1",
+                "environment-context": "General_Revenue-Bearing",
+                "workload-context": "Production",
+                "model-invariant-id": "1008a768-1b67-407e-88c6-58c82b34ef42",
+                "model-version-id": "81f8c1cd-f664-4450-b3a4-be645613ab32",
+                "resource-version": "1552311350334",
+                "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/101b8fc1-1796-4db1-a4e7-fe39c6a51558/service-data/service-topology/",
+                "orchestration-status": "Active",
+                "relationship-list": {
+                    "relationship": [
+                        {
+                            "related-to": "project",
+                            "related-link": "/aai/v11/business/projects/project/Test-Project",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "project.project-name",
+                                    "relationship-value": "Test-Project"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "generic-vnf",
+                            "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/7b202620-2936-4b0d-b09c-60b411f10f64",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "generic-vnf.vnf-id",
+                                    "relationship-value": "7b202620-2936-4b0d-b09c-60b411f10f64"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "generic-vnf.vnf-name",
+                                    "property-value": "vLoadBalancerMS-Vnf-0211-1"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "owning-entity",
+                            "related-link": "/aai/v11/business/owning-entities/owning-entity/bb94a687-4f3b-40a3-914e-e98037d5ebd2",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "owning-entity.owning-entity-id",
+                                    "relationship-value": "bb94a687-4f3b-40a3-914e-e98037d5ebd2"
+                        }
+                     ]
+                  }
+               ]
+                }
+            }
+      },
+        {
+            "generic-vnf": {
+                "vnf-id": "17044ef4-e7f3-46a1-af03-e2aa562f23ac",
+                "vnf-name": "TestVM-Vnf-0201-1",
+                "vnf-type": "TestVM/TestVM 0",
+                "prov-status": "ACTIVE",
+                "equipment-role": "",
+                "orchestration-status": "Active",
+                "ipv4-oam-address": "10.0.70.1",
+                "in-maint": true,
+                "is-closed-loop-disabled": false,
+                "resource-version": "1549041636264",
+                "model-invariant-id": "6a4d7971-0778-4655-9eab-9d6031c7ad57",
+                "model-version-id": "fb6c673c-e5b6-4e0a-9baf-5e0089784de9",
+                "model-customization-id": "706a3100-dbe5-442e-86c3-c7b823abbec2",
+                "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vnf-topology/",
+                "relationship-list": {
+                    "relationship": [
+                        {
+                            "related-to": "service-instance",
+                            "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFW/service-instances/service-instance/d41f8217-d464-4458-bf0a-fba33a0f1b31",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "customer.global-customer-id",
+                                    "relationship-value": "Demonstration"
+                        },
+                                {
+                                    "relationship-key": "service-subscription.service-type",
+                                    "relationship-value": "vFW"
+                        },
+                                {
+                                    "relationship-key": "service-instance.service-instance-id",
+                                    "relationship-value": "d41f8217-d464-4458-bf0a-fba33a0f1b31"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "service-instance.service-instance-name",
+                                    "property-value": "TestVM-Service-0201-1"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "platform",
+                            "related-link": "/aai/v11/business/platforms/platform/Test-Platform",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "platform.platform-name",
+                                    "relationship-value": "Test-Platform"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "line-of-business",
+                            "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "line-of-business.line-of-business-name",
+                                    "relationship-value": "Test-Business"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "vserver",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "tenant.tenant-id",
+                                    "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                        },
+                                {
+                                    "relationship-key": "vserver.vserver-id",
+                                    "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "vserver.vserver-name",
+                                    "property-value": "vfw-vm-0201-2"
+                        }
+                     ]
+                  },
+                        {
+                            "related-to": "availability-zone",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionTwo/availability-zones/availability-zone/zone-1",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionTwo"
+                        },
+                                {
+                                    "relationship-key": "availability-zone.availability-zone-name",
+                                    "relationship-value": "zone-1"
+                        }
+                     ]
+                  }
+               ]
+                },
+                "vf-modules": {
+                    "vf-module": [
+                        {
+                            "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+                            "vf-module-name": "TestVM-0201-1",
+                            "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+                            "orchestration-status": "Active",
+                            "is-base-vf-module": true,
+                            "resource-version": "1549039401119",
+                            "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+                            "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+                            "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+                            "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+                  },
+                        {
+                            "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+                            "vf-module-name": "TestVM-0201-2",
+                            "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+                            "orchestration-status": "Active",
+                            "is-base-vf-module": true,
+                            "resource-version": "1549041447373",
+                            "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+                            "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+                            "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+                            "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+                            "relationship-list": {
+                                "relationship": [
+                                    {
+                                        "related-to": "vserver",
+                                        "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+                                        "relationship-data": [
+                                            {
+                                                "relationship-key": "cloud-region.cloud-owner",
+                                                "relationship-value": "CloudOwner"
+                                 },
+                                            {
+                                                "relationship-key": "cloud-region.cloud-region-id",
+                                                "relationship-value": "RegionOne"
+                                 },
+                                            {
+                                                "relationship-key": "tenant.tenant-id",
+                                                "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                                 },
+                                            {
+                                                "relationship-key": "vserver.vserver-id",
+                                                "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+                                 }
+                              ],
+                                        "related-to-property": [
+                                            {
+                                                "property-key": "vserver.vserver-name",
+                                                "property-value": "vfw-vm-0201-2"
+                                 }
+                              ]
+                           }
+                        ]
+                            }
+                  }
+               ]
+                }
+            }
+      },
+        {
+            "vf-module": {
+                "vf-module-id": "0afde97a-3e3f-4597-aec3-e5488c0f20b7",
+                "vf-module-name": "TestVM-0201-1",
+                "heat-stack-id": "TestVM-0201-1/aee4d7e5-b4a0-4261-b3cf-bb23348a3d99",
+                "orchestration-status": "Active",
+                "is-base-vf-module": true,
+                "resource-version": "1549039401119",
+                "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+                "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+                "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+                "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/0afde97a-3e3f-4597-aec3-e5488c0f20b7/vf-module-data/vf-module-topology/"
+            }
+      },
+        {
+            "vf-module": {
+                "vf-module-id": "33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2",
+                "vf-module-name": "TestVM-0201-2",
+                "heat-stack-id": "TestVM-0201-2/1b9db6b8-620b-46f1-935a-8a61c294a98b",
+                "orchestration-status": "Active",
+                "is-base-vf-module": true,
+                "resource-version": "1549041447373",
+                "model-invariant-id": "6af68fdb-6479-43e2-8989-938f06c994bd",
+                "model-version-id": "16d1834e-d834-431f-b064-98c469c6505d",
+                "model-customization-id": "29ffb122-22c8-48d2-b152-b52d9e81e910",
+                "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/d41f8217-d464-4458-bf0a-fba33a0f1b31/service-data/vnfs/vnf/17044ef4-e7f3-46a1-af03-e2aa562f23ac/vnf-data/vf-modules/vf-module/33f9e03d-2fbd-4e9c-8e73-ce6b12f0b3d2/vf-module-data/vf-module-topology/",
+                "relationship-list": {
+                    "relationship": [
+                        {
+                            "related-to": "vserver",
+                            "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3f2aaef74ecb4b19b35e26d0849fe9a2/vservers/vserver/e7f1db09-ff78-44fc-b256-69095c5556fb",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "cloud-region.cloud-owner",
+                                    "relationship-value": "CloudOwner"
+                        },
+                                {
+                                    "relationship-key": "cloud-region.cloud-region-id",
+                                    "relationship-value": "RegionOne"
+                        },
+                                {
+                                    "relationship-key": "tenant.tenant-id",
+                                    "relationship-value": "3f2aaef74ecb4b19b35e26d0849fe9a2"
+                        },
+                                {
+                                    "relationship-key": "vserver.vserver-id",
+                                    "relationship-value": "e7f1db09-ff78-44fc-b256-69095c5556fb"
+                        }
+                     ],
+                            "related-to-property": [
+                                {
+                                    "property-key": "vserver.vserver-name",
+                                    "property-value": "vfw-vm-0201-2"
+                        }
+                     ]
+                  }
+               ]
+                }
+            }
+      },
+        {
+            "tenant": {
+                "tenant-id": "tenant1-16197-as988q",
+                "tenant-name": "tenant-name-16197-as988q",
+                "resource-version": "1550769793637",
+                "vservers": {
+                    "vserver": [
+                        {
+                            "vserver-id": "vserver1-16197-as988q",
+                            "vserver-name": "vserverName",
+                            "vserver-name2": "vserverTE-name2-as988q",
+                            "prov-status": "ACTIVE",
+                            "vserver-selflink": "TRINITY vserverLink",
+                            "in-maint": false,
+                            "is-closed-loop-disabled": false,
+                            "resource-version": "1550769794551",
+                            "relationship-list": {
+                                "relationship": [
+                                    {
+                                        "related-to": "generic-vnf",
+                                        "relationship-label": "tosca.relationships.HostedOn",
+                                        "related-link": "/aai/v16/network/generic-vnfs/generic-vnf/VNF1-16197-as988q",
+                                        "relationship-data": [
+                                            {
+                                                "relationship-key": "generic-vnf.vnf-id",
+                                                "relationship-value": "VNF1-16197-as988q"
+                                 }
+                              ],
+                                        "related-to-property": [
+                                            {
+                                                "property-key": "generic-vnf.vnf-name",
+                                                "property-value": "vnf1Name"
+                                 }
+                              ]
+                           }
+                        ]
+                            }
+                  }
+               ]
+                }
+            }
+      },
+        {
+            "cloud-region": {
+                "cloud-owner": "co-16197-01-as988q",
+                "cloud-region-id": "cr-16197-01-as988q",
+                "resource-version": "1550769792672",
+                "orchestration-disabled": false,
+                "in-maint": false,
+                "tenants": {
+                    "tenant": [
+                        {
+                            "tenant-id": "tenant1-16197-as988q",
+                            "tenant-name": "tenant-name-16197-as988q",
+                            "resource-version": "1550769793637"
+                  }
+               ]
+                }
+            }
+      }
+   ]
+}
index 53daf54..dfc34e0 100644 (file)
@@ -21,6 +21,7 @@
 
 package org.onap.policy.simulators;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -31,10 +32,10 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.onap.policy.aai.AaiCqResponse;
 import org.onap.policy.aai.AaiGetVnfResponse;
 import org.onap.policy.aai.AaiManager;
 import org.onap.policy.aai.AaiNqInstanceFilters;
@@ -73,6 +74,14 @@ public class AaiSimulatorTest {
         assertNotNull(response.getRelationshipList());
     }
 
+    @Test
+    public void testCqGet() {
+        final AaiCqResponse response = new AaiManager(new RestManager()).getCustomQueryResponse("http://localhost:6666",
+                "testUser", "testPass", UUID.randomUUID(), "vfw-vm-0201-2");
+        assertNotNull(response);
+        assertEquals(response.getVserver().getVserverName(), "vfw-vm-0201-2");
+    }
+
     @Test
     public void testPost() {
         // check vserver named query
@@ -96,7 +105,7 @@ public class AaiSimulatorTest {
                 "testPass", request, UUID.randomUUID());
         assertNotNull(response);
         assertNotNull(response.getInventoryResponseItems());
-        
+
         // check error response for vserver query
         tempInnerMap.put("vserver-name", "error");
 
@@ -125,7 +134,7 @@ public class AaiSimulatorTest {
         assertNotNull(response);
         assertNotNull(response.getInventoryResponseItems());
         assertNull(response.getRequestError());
-        
+
         // check error response for generic-vnf query
         tempInnerMap.put("vnf-id", "error");