summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/aai/src
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 /controlloop/common/model-impl/aai/src
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>
Diffstat (limited to 'controlloop/common/model-impl/aai/src')
-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
2 files changed, 23 insertions, 23 deletions
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());
}
/**