aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-08-24 14:00:30 -0400
committerJim Hahn <jrh3@att.com>2018-08-24 14:36:49 -0400
commit57ac9eac8ac0f8236ddb52e5226f475368d4de33 (patch)
tree25bd93e9556becc78742c5bfeeb943de99f20d32
parent51e88a932274a3ff8a93996332bb4f1d55d4a773 (diff)
use new vf-walk code in SO request
Methods were added to AaiNqResponseWrapper to extract VF modules and generate the new VF module name. This step modifies the SO code to use those methods. It was also determined that the SO code needs the VF module container object, not just the VF module, itself. As a result, AaiNqResponseWrapper was modified to return a list of the containers instead of a list of the VF modules. Also modified the AAI simulator to return two VF modules in the response to the vserver named query. As part of that, a method was added to the simulator so that JSON responses can be read from files rather than having to convert them to Java Strings. Modified simulator to work even if vnf-id is null. Change-Id: I68fdf07ea80ee0daf9e16403e35b11710315a8a8 Issue-ID: POLICY-1037 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java52
-rw-r--r--controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java55
-rw-r--r--controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json267
-rw-r--r--controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json230
-rw-r--r--controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json197
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java22
-rw-r--r--controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java24
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java150
-rw-r--r--controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json15
-rw-r--r--controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json77
-rw-r--r--controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json267
-rw-r--r--controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java23
12 files changed, 1179 insertions, 200 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
index c934c6110..f68c6f676 100644
--- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
@@ -145,11 +145,11 @@ public class SOActorServiceProvider implements Actor {
}
// Find the index for base vf module and non-base vf module
- int baseIndex = findIndex(vnfItem.getItems().getInventoryResponseItems(), true);
- int nonBaseIndex = findIndex(vnfItem.getItems().getInventoryResponseItems(), false);
+ AaiNqInventoryResponseItem baseItem = findVfModule(aaiResponseWrapper, true);
+ AaiNqInventoryResponseItem vfModuleItem = findVfModule(aaiResponseWrapper, false);
// Report the error if either base vf module or non-base vf module is not found
- if (baseIndex == -1 || nonBaseIndex == -1) {
+ if (baseItem == null || vfModuleItem == null) {
logger.error("Either base or non-base vf module is not found from AAI response.");
return null;
}
@@ -177,8 +177,6 @@ public class SOActorServiceProvider implements Actor {
//
// modelInfo
//
- AaiNqInventoryResponseItem vfModuleItem = vnfItem.getItems().getInventoryResponseItems().get(nonBaseIndex);
-
request.getRequestDetails().getModelInfo().setModelType("vfModule");
request.getRequestDetails().getModelInfo()
.setModelInvariantId(vfModuleItem.getVfModule().getModelInvariantId());
@@ -195,8 +193,7 @@ public class SOActorServiceProvider implements Actor {
//
// requestInfo
//
- request.getRequestDetails().getRequestInfo().setInstanceName(vnfItem.getItems().getInventoryResponseItems()
- .get(baseIndex).getVfModule().getVfModuleName().replace("Vfmodule", "vDNS"));
+ request.getRequestDetails().getRequestInfo().setInstanceName(aaiResponseWrapper.genVfModuleName());
request.getRequestDetails().getRequestInfo().setSource("POLICY");
request.getRequestDetails().getRequestInfo().setSuppressRollback(false);
request.getRequestDetails().getRequestInfo().setRequestorId("policy");
@@ -278,41 +275,16 @@ public class SOActorServiceProvider implements Actor {
}
/**
- * Find the base index or non base index in a list of inventory response items.
- *
- * @param inventoryResponseItems the list of inventory response items
- * @param baseIndexFlag true if we are searching for the base index, false if we are searching
- * for the non base index
- * @return the base or non base index or -1 if the index was not found
- */
- private int findIndex(List<AaiNqInventoryResponseItem> inventoryResponseItems, boolean baseIndexFlag) {
- for (AaiNqInventoryResponseItem inventoryResponseItem : inventoryResponseItems) {
- if (inventoryResponseItem.getVfModule() != null
- && baseIndexFlag == inventoryResponseItem.getVfModule().getIsBaseVfModule()) {
- return inventoryResponseItems.indexOf(inventoryResponseItem);
- }
- }
-
- return -1;
- }
-
- /**
- * Find the number of non base modules present in API response object.
+ * Find the base or non base VF module item in an AAI response.
*
- * @param inventoryResponseItems the list of inventory response items
- * @return number of non base index modules
+ * @param aaiResponseWrapper the AAI response containing the VF modules
+ * @param baseFlag true if we are searching for the base, false if we are searching
+ * for the non base
+ * @return the base or non base VF module item or null if the module was not found
*/
-
- @SuppressWarnings("unused")
- private int findNonBaseModules(List<AaiNqInventoryResponseItem> inventoryResponseItems) {
- int nonBaseModuleCount = 0;
- for (AaiNqInventoryResponseItem inventoryResponseItem : inventoryResponseItems) {
- if (inventoryResponseItem.getVfModule() != null
- && (!inventoryResponseItem.getVfModule().getIsBaseVfModule())) {
- nonBaseModuleCount++;
- }
- }
- return nonBaseModuleCount;
+ private AaiNqInventoryResponseItem findVfModule(AaiNqResponseWrapper aaiResponseWrapper, boolean baseFlag) {
+ List<AaiNqInventoryResponseItem> lst = aaiResponseWrapper.getVfModuleItems(baseFlag);
+ return (lst == null || lst.isEmpty() ? null : lst.get(0));
}
/**
diff --git a/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
index d75d859d8..25bbda0f4 100644
--- a/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
@@ -26,38 +26,26 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-import java.util.HashMap;
-import java.util.Map;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.UUID;
-import org.junit.AfterClass;
+import org.apache.commons.io.IOUtils;
import org.junit.Test;
-import org.onap.policy.aai.AaiNqInstanceFilters;
-import org.onap.policy.aai.AaiNqRequest;
import org.onap.policy.aai.AaiNqResponse;
import org.onap.policy.aai.AaiNqResponseWrapper;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.simulators.AaiSimulatorJaxRs;
import org.onap.policy.so.SORequest;
import org.onap.policy.so.util.Serialization;
public class TestSOActorServiceProvider {
- /**
- * Tear down after test class.
- */
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
- }
-
@Test
- public void testConstructRequest() {
+ public void testConstructRequest() throws Exception {
VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
final ControlLoopOperation operation = new ControlLoopOperation();
- final AaiNqResponseWrapper aaiNqResp = getNqVserverFromAai(onset);
+ final AaiNqResponseWrapper aaiNqResp = loadAaiResponse(onset, "aai/AaiNqResponse-Full.json");
final UUID requestId = UUID.randomUUID();
onset.setRequestId(requestId);
@@ -74,8 +62,20 @@ public class TestSOActorServiceProvider {
SORequest request = new SOActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
assertNotNull(request);
+ assertEquals("my_module_3", request.getRequestDetails().getRequestInfo().getInstanceName());
assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId());
assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId());
+
+ // null response
+ assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy, null));
+
+ // response has no base VF module
+ assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy,
+ loadAaiResponse(onset, "aai/AaiNqResponse-NoBase.json")));
+
+ // response has no non-base VF modules (other than the "dummy")
+ assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy,
+ loadAaiResponse(onset, "aai/AaiNqResponse-NoNonBase.json")));
}
@Test
@@ -98,25 +98,16 @@ public class TestSOActorServiceProvider {
}
/**
- * Queries the AAI simulator directly (i.e., bypassing the REST API) to get the
- * vserver named-query response.
+ * Reads an AAI vserver named-query response from a file.
*
* @param onset the ONSET event
+ * @param fileName name of the file containing the JSON response
* @return output from the AAI vserver named-query
+ * @throws IOException if the file cannot be read
*/
- private AaiNqResponseWrapper getNqVserverFromAai(VirtualControlLoopEvent onset) {
- AaiNqRequest aaiNqRequest = new AaiNqRequest();
- final AaiNqInstanceFilters aaiNqInstanceFilter = new AaiNqInstanceFilters();
-
- Map<String, Map<String, String>> aaiNqInstanceFilterMap = new HashMap<>();
- Map<String, String> aaiNqInstanceFilterMapItem = new HashMap<>();
- aaiNqInstanceFilterMapItem.put("vserver-name", "my-vserver-name");
- aaiNqInstanceFilterMap.put("vserver", aaiNqInstanceFilterMapItem);
- aaiNqInstanceFilter.getInstanceFilter().add(aaiNqInstanceFilterMap);
- aaiNqRequest.setInstanceFilters(aaiNqInstanceFilter);
-
- String req = Serialization.gsonPretty.toJson(aaiNqRequest);
- String resp = new AaiSimulatorJaxRs().aaiPostQuery(req);
+ private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName)
+ throws IOException {
+ String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
AaiNqResponse aaiNqResponse = Serialization.gsonPretty.fromJson(resp, AaiNqResponse.class);
return new AaiNqResponseWrapper(onset.getRequestId(), aaiNqResponse);
diff --git a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json
new file mode 100644
index 000000000..af40be948
--- /dev/null
+++ b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json
@@ -0,0 +1,267 @@
+{
+ "inventory-response-item": [
+ {
+ "vserver": {
+ "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "vserver-name": "zdfw1lb01lb02",
+ "vserver-name2": "zdfw1lb01lb02",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510606403522"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer",
+ "generic-vnf": {
+ "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vnf-name": "Vfmodule_vLB1113",
+ "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0",
+ "service-id": "66f157fc-4148-4880-95f5-e120677e98d1",
+ "prov-status": "PREPROV",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510604011851",
+ "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc",
+ "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "cee050ed-92a5-494f-ab04-234307a846dc"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer-1106",
+ "service-instance": {
+ "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941",
+ "service-instance-name": "vLoadBalancer-1113",
+ "resource-version": "1510603936425",
+ "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a",
+ "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer-1106"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "service"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..base_vlb..module-0",
+ "vf-module": {
+ "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12",
+ "vf-module-name": "Vfmodule_vLB1113-1",
+ "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db",
+ "orchestration-status": "active",
+ "is-base-vf-module": true,
+ "resource-version": "1510604612557",
+ "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2",
+ "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..base_vlb..module-0"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "my_module_1",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "my_module_2",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd",
+ "tenant-name": "Integration-SB-00",
+ "resource-version": "1509587770200"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "cloud-region": {
+ "cloud-owner": "CloudOwner",
+ "cloud-region-id": "RegionOne",
+ "cloud-region-version": "v1",
+ "resource-version": "1509587770092"
+ },
+ "extra-properties": {
+ "extra-property": []
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json
new file mode 100644
index 000000000..7101f60f2
--- /dev/null
+++ b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json
@@ -0,0 +1,230 @@
+{
+ "inventory-response-item": [
+ {
+ "vserver": {
+ "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "vserver-name": "zdfw1lb01lb02",
+ "vserver-name2": "zdfw1lb01lb02",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510606403522"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer",
+ "generic-vnf": {
+ "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vnf-name": "Vfmodule_vLB1113",
+ "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0",
+ "service-id": "66f157fc-4148-4880-95f5-e120677e98d1",
+ "prov-status": "PREPROV",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510604011851",
+ "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc",
+ "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "cee050ed-92a5-494f-ab04-234307a846dc"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer-1106",
+ "service-instance": {
+ "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941",
+ "service-instance-name": "vLoadBalancer-1113",
+ "resource-version": "1510603936425",
+ "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a",
+ "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer-1106"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "service"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "my_module_1",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "my_module_2",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd",
+ "tenant-name": "Integration-SB-00",
+ "resource-version": "1509587770200"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "cloud-region": {
+ "cloud-owner": "CloudOwner",
+ "cloud-region-id": "RegionOne",
+ "cloud-region-version": "v1",
+ "resource-version": "1509587770092"
+ },
+ "extra-properties": {
+ "extra-property": []
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json
new file mode 100644
index 000000000..a58100bc5
--- /dev/null
+++ b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json
@@ -0,0 +1,197 @@
+{
+ "inventory-response-item": [
+ {
+ "vserver": {
+ "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "vserver-name": "zdfw1lb01lb02",
+ "vserver-name2": "zdfw1lb01lb02",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510606403522"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer",
+ "generic-vnf": {
+ "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vnf-name": "Vfmodule_vLB1113",
+ "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0",
+ "service-id": "66f157fc-4148-4880-95f5-e120677e98d1",
+ "prov-status": "PREPROV",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510604011851",
+ "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc",
+ "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "cee050ed-92a5-494f-ab04-234307a846dc"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer-1106",
+ "service-instance": {
+ "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941",
+ "service-instance-name": "vLoadBalancer-1113",
+ "resource-version": "1510603936425",
+ "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a",
+ "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer-1106"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "service"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..base_vlb..module-0",
+ "vf-module": {
+ "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12",
+ "vf-module-name": "Vfmodule_vLB1113-1",
+ "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db",
+ "orchestration-status": "active",
+ "is-base-vf-module": true,
+ "resource-version": "1510604612557",
+ "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2",
+ "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..base_vlb..module-0"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd",
+ "tenant-name": "Integration-SB-00",
+ "resource-version": "1509587770200"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "cloud-region": {
+ "cloud-owner": "CloudOwner",
+ "cloud-region-id": "RegionOne",
+ "cloud-region-version": "v1",
+ "resource-version": "1509587770092"
+ },
+ "extra-properties": {
+ "extra-property": []
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java
index 9d10cfd26..be84fdfa8 100644
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java
+++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java
@@ -68,7 +68,7 @@ public class AaiNqResponseWrapper implements Serializable {
* @return the number of VF modules, or {@code 0} if there are none
*/
public int countVfModules() {
- List<AaiNqVfModule> lst = getVfModules(false);
+ List<AaiNqInventoryResponseItem> lst = getVfModuleItems(false);
return (lst == null ? 0 : lst.size());
}
@@ -80,7 +80,7 @@ public class AaiNqResponseWrapper implements Serializable {
* which to model it)
*/
public String genVfModuleName() {
- List<AaiNqVfModule> lst = getVfModules(false);
+ List<AaiNqInventoryResponseItem> lst = getVfModuleItems(false);
if (lst == null) {
return null;
}
@@ -92,8 +92,8 @@ public class AaiNqResponseWrapper implements Serializable {
String prefix = null;
int maxSuffix = -1;
- for (AaiNqVfModule vfmod : lst) {
- String name = vfmod.getVfModuleName();
+ for (AaiNqInventoryResponseItem item : lst) {
+ String name = item.getVfModule().getVfModuleName();
Matcher matcher = VF_MODULE_NAME_PAT.matcher(name);
if (matcher.matches()) {
int suffix = Integer.parseInt(matcher.group(2));
@@ -116,9 +116,9 @@ public class AaiNqResponseWrapper implements Serializable {
*
* @param wantBaseModule {@code true} if the the base VF module(s) is desired,
* {@code false} otherwise
- * @return the list of VF modules, or {@code null} if there are no VF modules
+ * @return the list of VF module items, or {@code null} if there are no VF modules
*/
- public List<AaiNqVfModule> getVfModules(boolean wantBaseModule) {
+ public List<AaiNqInventoryResponseItem> getVfModuleItems(boolean wantBaseModule) {
// get the list of items
List<AaiNqInventoryResponseItem> itemList;
try {
@@ -138,7 +138,7 @@ public class AaiNqResponseWrapper implements Serializable {
* Walk the items looking for VF modules, allocating the list only when an item is
* found.
*/
- List<AaiNqVfModule> vfModules = null;
+ List<AaiNqInventoryResponseItem> vfModuleItems = null;
for (AaiNqInventoryResponseItem inventoryResponseItem : itemList) {
AaiNqVfModule vfmod = inventoryResponseItem.getVfModule();
@@ -146,16 +146,16 @@ public class AaiNqResponseWrapper implements Serializable {
continue;
}
- if (vfModules == null) {
- vfModules = new ArrayList<>(itemList.size());
+ if (vfModuleItems == null) {
+ vfModuleItems = new ArrayList<>(itemList.size());
}
if (vfmod.getIsBaseVfModule() == wantBaseModule
&& (wantBaseModule || VF_MODULE_NAME_PAT.matcher(vfmod.getVfModuleName()).matches())) {
- vfModules.add(vfmod);
+ vfModuleItems.add(inventoryResponseItem);
}
}
- return vfModules;
+ return vfModuleItems;
}
}
diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java
index 3c5502802..9acaa117c 100644
--- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java
+++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java
@@ -207,47 +207,47 @@ public class AaiNqResponseWrapperTest {
// null item
resp = new AaiNqResponseWrapper();
- assertNull(resp.getVfModules(true));
+ assertNull(resp.getVfModuleItems(true));
// missing item
resp = new AaiNqResponseWrapper();
resp.setAaiNqResponse(new AaiNqResponse());
- assertNull(resp.getVfModules(false));
+ assertNull(resp.getVfModuleItems(false));
// null item list
resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoItems.json"));
resp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0)
.getItems().setInventoryResponseItems(null);
- assertNull(resp.getVfModules(false));
+ assertNull(resp.getVfModuleItems(false));
// no modules
resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoModules.json"));
- assertNull(resp.getVfModules(false));
+ assertNull(resp.getVfModuleItems(false));
// no names
resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json"));
- List<AaiNqVfModule> lst;
- lst = resp.getVfModules(false);
+ List<AaiNqInventoryResponseItem> lst;
+ lst = resp.getVfModuleItems(false);
assertNotNull(lst);
assertEquals(0, lst.size());
// base VF modules
resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json"));
- lst = resp.getVfModules(true);
+ lst = resp.getVfModuleItems(true);
assertNotNull(lst);
assertEquals(1, lst.size());
- assertEquals("Vfmodule_vLBMS-0809-1", lst.get(0).getVfModuleName());
+ assertEquals("Vfmodule_vLBMS-0809-1", lst.get(0).getVfModule().getVfModuleName());
// non base VF modules
resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json"));
- lst = resp.getVfModules(false);
+ lst = resp.getVfModuleItems(false);
assertNotNull(lst);
assertEquals(3, lst.size());
int index;
index = 0;
- assertEquals("my-module-abc_1", lst.get(index++).getVfModuleName());
- assertEquals("my-module-abc_123", lst.get(index++).getVfModuleName());
- assertEquals("my-module-abc_34", lst.get(index++).getVfModuleName());
+ assertEquals("my-module-abc_1", lst.get(index++).getVfModule().getVfModuleName());
+ assertEquals("my-module-abc_123", lst.get(index++).getVfModule().getVfModuleName());
+ assertEquals("my-module-abc_34", lst.get(index++).getVfModule().getVfModuleName());
}
/**
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index 8d651f253..f5a4f6e53 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -20,6 +20,11 @@
package org.onap.policy.simulators;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
import java.util.UUID;
import javax.ws.rs.Consumes;
@@ -30,7 +35,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-
+import org.apache.commons.io.IOUtils;
import org.onap.policy.aai.AaiNqRequest;
import org.onap.policy.aai.util.Serialization;
@@ -58,132 +63,45 @@ public class AaiSimulatorJaxRs {
*
* @param req the request
* @return the response
+ * @throws IOException if a response file cannot be read
*/
@POST
@Path("/search/named-query")
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
- public String aaiPostQuery(final String req) {
+ public String aaiPostQuery(final String req) throws IOException {
final AaiNqRequest request = Serialization.gsonPretty.fromJson(req, AaiNqRequest.class);
if (request.getInstanceFilters().getInstanceFilter().get(0).containsKey("vserver")) {
final String vserverName =
request.getInstanceFilters().getInstanceFilter().get(0).get("vserver").get("vserver-name");
if ("error".equals(vserverName)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not "
- + "found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"POST Search\",\""
- + "getNamedQueryResponse\",\"Node Not Found:No Node of type vserver found for properties\""
- + ",\"ERR.5.4.6114\"]}}}";
+ Map<String,String> params = new TreeMap<>();
+ params.put("type", "vserver");
+ return load("aai/AaiNqResponse-Error.json", params);
} else {
// vll format - new
// new aai response from Brian 11/13/2017
- return "{\"inventory-response-item\":[{\"vserver\":{\"vserver-id\":\""
- + "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb\",\"vserver-name\":\"zdfw1lb01lb02\",\"vserver-name2\""
- + ":\"zdfw1lb01lb02\",\"prov-status\":\"ACTIVE\",\"vserver-selflink\":\""
- + "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/"
- + "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb\",\"in-maint\":false,\"prov-status\":\"ACTIVE\",\"is-closed-loop-disabled\":false"
- + ",\"resource-version\":\"1510606403522\"},\"extra-properties\":{},\"inventory-response-items"
- + "\":{\"inventory-response-item\":[{\"model-name\":\"vLoadBalancer\",\"generic-vnf\":{\"vnf-id"
- + "\":\"db373a8d-f7be-4d02-8ac8-6ca4c305d144\",\"vnf-name\":\"Vfmodule_vLB1113\",\"vnf-type"
- + "\":\"vLoadBalancer-1106/vLoadBalancer 0\",\"service-id\":\""
- + "66f157fc-4148-4880-95f5-e120677e98d1\",\"prov-status\":\"PREPROV\",\"orchestration-status\":"
- + "\"Created\",\"in-maint\":false,\"is-closed-loop-disabled\":false,\"resource-version\":\""
- + "1510604011851\",\"model-invariant-id\":\"cee050ed-92a5-494f-ab04-234307a846dc\",\""
- + "model-version-id\":\"fd65becc-6b2c-4fe8-ace9-cc29db9a3da2\",\"model-customization-id\":\""
- + "1983c783-444f-4e79-af3a-85e5d49628f3\",\"nf-type\":\"\",\"nf-function\":\"\",\"nf-role"
- + "\":\"\",\"nf-naming-code\":\"\"},\"extra-properties\":{\"extra-property\":[{\"property-name"
- + "\":\"model-ver.model-version-id\",\"property-value\":\"fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
- + "\"},{\"property-name\":\"model-ver.model-name\",\"property-value\":\"vLoadBalancer\"},{\""
- + "property-name\":\"model.model-type\",\"property-value\":\"resource\"},{\"property-name\":\""
- + "model.model-invariant-id\",\"property-value\":\"cee050ed-92a5-494f-ab04-234307a846dc\"},{\""
- + "property-name\":\"model-ver.model-version\",\"property-value\":\"1.0\"}]},\""
- + "inventory-response-items\":{\"inventory-response-item\":[{\"model-name\":\""
- + "vLoadBalancer-1106\",\"service-instance\":{\"service-instance-id\":\""
- + "3b12f31f-8f2d-4f5c-b875-61ff1194b941\",\"service-instance-name\":\"vLoadBalancer-1113\",\""
- + "model-invariant-id\":\"1321d60d-f7ff-4300-96c2-6bf0b3268b7a\",\"model-version-id\":\""
- + "732d4692-4b97-46f9-a996-0b3339e88c50\",\"resource-version\":\"1510603936425\"},\""
- + "extra-properties\":{\"extra-property\":[{\"property-name\":\"model-ver.model-version-id"
- + "\",\"property-value\":\"732d4692-4b97-46f9-a996-0b3339e88c50\"},{\"property-name\":\""
- + "model-ver.model-name\",\"property-value\":\"vLoadBalancer-1106\"},{\"property-name\":\""
- + "model.model-type\",\"property-value\":\"service\"},{\"property-name\":\""
- + "model.model-invariant-id\",\"property-value\":\"1321d60d-f7ff-4300-96c2-6bf0b3268b7a"
- + "\"},{\"property-name\":\"model-ver.model-version\",\"property-value\":\"1.0\"}]}},{\""
- + "model-name\":\"Vloadbalancer..base_vlb..module-0\",\"vf-module\":{\"vf-module-id\":\""
- + "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12\",\"vf-module-name\":\"Vfmodule_vLB1113-1\",\""
- + "heat-stack-id\":\"Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db\",\""
- + "orchestration-status\":\"active\",\"is-base-vf-module\":true,\"resource-version\":\""
- + "1510604612557\",\"model-invariant-id\":\"6d760188-9a24-451a-b05b-e08b86cb94f2\",\""
- + "model-version-id\":\"93facad9-55f2-4fe0-9574-814c2bc2d071\",\"model-customization-id\":\""
- + "93fd5bd4-8051-4074-8530-c0c504604df5\",\"module-index\":0},\"extra-properties\":{\""
- + "extra-property\":[{\"property-name\":\"model-ver.model-version-id\",\"property-value"
- + "\":\"93facad9-55f2-4fe0-9574-814c2bc2d071\"},{\"property-name\":\"model-ver.model-name"
- + "\",\"property-value\":\"Vloadbalancer..base_vlb..module-0\"},{\"property-name\":\""
- + "model.model-type\",\"property-value\":\"resource\"},{\"property-name\":\""
- + "model.model-invariant-id\",\"property-value\":\"6d760188-9a24-451a-b05b-e08b86cb94f2\"},"
- + "{\"property-name\":\"model-ver.model-version\",\"property-value\":\"1\"}]}},{\"model-name"
- + "\":\"Vloadbalancer..dnsscaling..module-1\",\"vf-module\":{\"vf-module-id\":\""
- + "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144\",\"vf-module-name\":\""
- + "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144\",\"is-base-vf-module\":false,\"resource-version"
- + "\":\"1510610079687\",\"model-invariant-id\":\"356a1cff-71f2-4086-9980-a2927ce11c1c\",\""
- + "model-version-id\":\"6b93d804-cfc8-4be3-92cc-9336d135859a\"},\"extra-properties\":{\""
- + "extra-property\":[{\"property-name\":\"model-ver.model-version-id\",\"property-value\":\""
- + "6b93d804-cfc8-4be3-92cc-9336d135859a\"},{\"property-name\":\"model-ver.model-name\",\""
- + "property-value\":\"Vloadbalancer..dnsscaling..module-1\"},{\"property-name\":\""
- + "model.model-type\",\"property-value\":\"resource\"},{\"property-name\":\""
- + "model.model-invariant-id\",\"property-value\":\"356a1cff-71f2-4086-9980-a2927ce11c1c\"},"
- + "{\"property-name\":\"model-ver.model-version\",\"property-value\":\"1\"}]}}]}},{\"tenant"
- + "\":{\"tenant-id\":\"41d6d38489bd40b09ea8a6b6b852dcbd\",\"tenant-name\":\"Integration-SB-00"
- + "\",\"resource-version\":\"1509587770200\"},\"extra-properties\":{},\""
- + "inventory-response-items\":{\"inventory-response-item\":[{\"cloud-region\":{\"cloud-owner"
- + "\":\"CloudOwner\",\"cloud-region-id\":\"RegionOne\",\"cloud-type\":\"SharedNode\",\""
- + "owner-defined-type\":\"OwnerType\",\"cloud-region-version\":\"v1\",\"cloud-zone\":\""
- + "CloudZone\",\"sriov-automation\":false,\"resource-version\":\"1509587770092\"},\""
- + "extra-properties\":{}}]}}]}}]}";
+ return load("aai/AaiNqResponse-Vserver.json", new TreeMap<>());
}
} else {
final String vnfId =
request.getInstanceFilters().getInstanceFilter().get(0).get("generic-vnf").get("vnf-id");
if ("error".equals(vnfId)) {
- return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not "
- + "found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"POST Search\",\""
- + "getNamedQueryResponse\",\"Node Not Found:No Node of type generic-vnf found for properties"
- + "\",\"ERR.5.4.6114\"]}}}";
+ Map<String,String> params = new TreeMap<>();
+ params.put("type", "generic-vnf");
+ return load("aai/AaiNqResponse-Error.json", params);
} else {
- final String vnfName = getUUIDValue(vnfId, "ZRDM2MMEX39");
- final String pnfVndName = "pnf-test-" + vnfId;
- final String pnfVnfId = getUUIDValue(pnfVndName, "jimmy-test");
+ Map<String, String> params = new TreeMap<>();
+ params.put("vnfId", "" + vnfId);
+ params.put("vnfName", getUUIDValue(vnfId, "ZRDM2MMEX39"));
+ params.put("pnfVndName", "pnf-test-" + vnfId);
+ params.put("pnfVnfId", getUUIDValue(params.get("pnfVndName"), "jimmy-test"));
- final String serviceInstanceVnfName = "service-instance-test-" + vnfId;
- final String serviceInstanceVnfId = getUUIDValue(serviceInstanceVnfName, "jimmy-test-vnf2");
+ params.put("serviceInstanceVnfName", "service-instance-test-" + vnfId);
+ params.put("serviceInstanceVnfId", getUUIDValue(params.get("serviceInstanceVnfName"), "jimmy-test-vnf2"));
- return "{\"inventory-response-item\": [{\"model-name\": \"service-instance\",\"generic-vnf\": {\""
- + "vnf-id\": \"" + vnfId + "\",\"vnf-name\": \"" + vnfName + "\",\"vnf-type\": \"vMME Svc Jul "
- + "14/vMME VF Jul 14 1\",\"service-id\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\""
- + "orchestration-status\": \"active\",\"prov-status\":\"ACTIVE\",\"in-maint\": false,\"is-closed-loop-disabled\": false"
- + ",\"resource-version\": \"1503082370097\",\"model-invariant-id\": \""
- + "82194af1-3c2c-485a-8f44-420e22a9eaa4\",\"model-version-id\": \""
- + "46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": {},\""
- + "inventory-response-items\": {\"inventory-response-item\": [{\"model-name\": \""
- + "service-instance\",\"service-instance\": {\"service-instance-id\": \""
- + "37b8cdb7-94eb-468f-a0c2-4e3c3546578e\",\"service-instance-name\": \"Changed Service "
- + "Instance NAME\",\"model-invariant-id\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\",\""
- + "model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\",\"resource-version\": \""
- + "1503082993532\",\"orchestration-status\": \"Active\"},\"extra-properties\": {},\""
- + "inventory-response-items\": {\"inventory-response-item\": [{\"model-name\": \"pnf\",\""
- + "generic-vnf\": {\"vnf-id\": \"" + pnfVnfId + "\",\"vnf-name\": \"" + pnfVndName
- + "\",\"vnf-type" + "\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id\": \""
- + "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\"in-maint\":"
- + " false,\"is-closed-loop-disabled\": false,\"resource-version\": \"1504013830207\",\""
- + "model-invariant-id\": \"862b25a1-262a-4961-bdaa-cdc55d69785a\",\"model-version-id\": \""
- + "e9f1fa7d-c839-418a-9601-03dc0d2ad687\"},\"extra-properties\": {}},{\"model-name\": \""
- + "service-instance\",\"generic-vnf\": {\"vnf-id\": \"" + serviceInstanceVnfId
- + "\",\"vnf-name\": \"" + "" + serviceInstanceVnfName
- + "\",\"vnf-type\": \"vMME Svc Jul 14/vMME VF Jul 14 1\",\"service-id"
- + "\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\",\"orchestration-status\": \"active\",\""
- + "in-maint\": false,\"is-closed-loop-disabled\": false,\"resource-version\": \""
- + "1504014833841\",\"model-invariant-id\": \"Eace933104d443b496b8.nodes.heat.vpg\",\""
- + "model-version-id\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"},\"extra-properties\": "
- + "{}}]}}]}}]}";
+ return load("aai/AaiNqResponse-GenericVnf.json", params);
}
}
}
@@ -341,4 +259,26 @@ public class AaiSimulatorJaxRs {
private String getUUIDValue(final String value, final String defaultValue) {
return value != null ? UUID.nameUUIDFromBytes(value.getBytes()).toString() : defaultValue;
}
+
+ /**
+ * 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
+ * @throws IOException if the file cannot be read
+ */
+ private String load(String fileName, Map<String, String> params) throws IOException {
+ String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
+
+ // perform parameter substitution
+ for (Entry<String, String> ent : params.entrySet()) {
+ String name = "${" + ent.getKey() + "}";
+ String value = ent.getValue();
+ json = json.replace(name, value);
+ }
+
+ return json;
+ }
}
diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json
new file mode 100644
index 000000000..77b30bdb1
--- /dev/null
+++ b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Error.json
@@ -0,0 +1,15 @@
+{
+ "inventory-response-item": [],
+ "requestError": {
+ "serviceException": {
+ "messageId": "SVC3001",
+ "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
+ "variables": [
+ "POST Search",
+ "getNamedQueryResponse",
+ "Node Not Found:No Node of type ${type} found for properties",
+ "ERR.5.4.6114"
+ ]
+ }
+ }
+}
diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json
new file mode 100644
index 000000000..906e4afbb
--- /dev/null
+++ b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-GenericVnf.json
@@ -0,0 +1,77 @@
+{
+ "inventory-response-item": [
+ {
+ "model-name": "service-instance",
+ "generic-vnf": {
+ "vnf-id": "${vnfId}",
+ "vnf-name": "${vnfName}",
+ "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
+ "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "prov-status": "ACTIVE",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1503082370097",
+ "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
+ "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "service-instance",
+ "service-instance": {
+ "service-instance-id": "37b8cdb7-94eb-468f-a0c2-4e3c3546578e",
+ "service-instance-name": "Changed Service Instance NAME",
+ "resource-version": "1503082993532",
+ "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4",
+ "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "pnf",
+ "generic-vnf": {
+ "vnf-id": "${pnfVnfId}",
+ "vnf-name": "${pnfVndName}",
+ "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
+ "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1504013830207",
+ "model-invariant-id": "862b25a1-262a-4961-bdaa-cdc55d69785a",
+ "model-version-id": "e9f1fa7d-c839-418a-9601-03dc0d2ad687"
+ },
+ "extra-properties": {
+ "extra-property": []
+ }
+ },
+ {
+ "model-name": "service-instance",
+ "generic-vnf": {
+ "vnf-id": "${serviceInstanceVnfId}",
+ "vnf-name": "${serviceInstanceVnfName}",
+ "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1",
+ "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1504014833841",
+ "model-invariant-id": "Eace933104d443b496b8.nodes.heat.vpg",
+ "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9"
+ },
+ "extra-properties": {
+ "extra-property": []
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json
new file mode 100644
index 000000000..af40be948
--- /dev/null
+++ b/controlloop/common/simulators/src/main/resources/org/onap/policy/simulators/aai/AaiNqResponse-Vserver.json
@@ -0,0 +1,267 @@
+{
+ "inventory-response-item": [
+ {
+ "vserver": {
+ "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "vserver-name": "zdfw1lb01lb02",
+ "vserver-name2": "zdfw1lb01lb02",
+ "prov-status": "ACTIVE",
+ "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510606403522"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer",
+ "generic-vnf": {
+ "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vnf-name": "Vfmodule_vLB1113",
+ "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0",
+ "service-id": "66f157fc-4148-4880-95f5-e120677e98d1",
+ "prov-status": "PREPROV",
+ "in-maint": false,
+ "is-closed-loop-disabled": false,
+ "resource-version": "1510604011851",
+ "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc",
+ "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "cee050ed-92a5-494f-ab04-234307a846dc"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "model-name": "vLoadBalancer-1106",
+ "service-instance": {
+ "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941",
+ "service-instance-name": "vLoadBalancer-1113",
+ "resource-version": "1510603936425",
+ "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a",
+ "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "vLoadBalancer-1106"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "service"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..base_vlb..module-0",
+ "vf-module": {
+ "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12",
+ "vf-module-name": "Vfmodule_vLB1113-1",
+ "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db",
+ "orchestration-status": "active",
+ "is-base-vf-module": true,
+ "resource-version": "1510604612557",
+ "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2",
+ "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..base_vlb..module-0"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "my_module_1",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ },
+ {
+ "model-name": "Vloadbalancer..dnsscaling..module-1",
+ "vf-module": {
+ "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144",
+ "vf-module-name": "my_module_2",
+ "is-base-vf-module": false,
+ "resource-version": "1510610079687",
+ "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c",
+ "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "Vloadbalancer..dnsscaling..module-1"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "resource"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "tenant": {
+ "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd",
+ "tenant-name": "Integration-SB-00",
+ "resource-version": "1509587770200"
+ },
+ "extra-properties": {
+ "extra-property": []
+ },
+ "inventory-response-items": {
+ "inventory-response-item": [
+ {
+ "cloud-region": {
+ "cloud-owner": "CloudOwner",
+ "cloud-region-id": "RegionOne",
+ "cloud-region-version": "v1",
+ "resource-version": "1509587770092"
+ },
+ "extra-properties": {
+ "extra-property": []
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
index 606db6cf7..79a484be7 100644
--- a/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
+++ b/controlloop/common/simulators/src/test/java/org/onap/policy/simulators/AaiSimulatorTest.java
@@ -21,6 +21,8 @@
package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
@@ -75,6 +77,7 @@ public class AaiSimulatorTest {
@Test
public void testPost() {
+ // check vserver named query
final AaiNqRequest request = new AaiNqRequest();
final AaiNqQueryParameters tempQueryParameters = new AaiNqQueryParameters();
final AaiNqNamedQuery tempNamedQuery = new AaiNqNamedQuery();
@@ -95,7 +98,17 @@ public class AaiSimulatorTest {
"testPass", request, UUID.randomUUID());
assertNotNull(response);
assertNotNull(response.getInventoryResponseItems());
+
+ // check error response for vserver query
+ tempInnerMap.put("vserver-name", "error");
+ response = new AaiManager(new RESTManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
+ UUID.randomUUID());
+ assertNotNull(response);
+ assertNotNull(response.getRequestError());
+ assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("vserver"));
+
+ // check generic-vnf named query
tempNamedQuery.setNamedQueryUuid(UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"));
tempQueryParameters.setNamedQuery(tempNamedQuery);
request.setQueryParameters(tempQueryParameters);
@@ -113,5 +126,15 @@ public class AaiSimulatorTest {
UUID.randomUUID());
assertNotNull(response);
assertNotNull(response.getInventoryResponseItems());
+ assertNull(response.getRequestError());
+
+ // check error response for generic-vnf query
+ tempInnerMap.put("vnf-id", "error");
+
+ response = new AaiManager(new RESTManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
+ UUID.randomUUID());
+ assertNotNull(response);
+ assertNotNull(response.getRequestError());
+ assertTrue(response.getRequestError().getServiceExcept().getVariables()[2].contains("generic-vnf"));
}
}