summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dt5972@att.com>2018-06-12 17:03:44 +0000
committerGerrit Code Review <gerrit@onap.org>2018-06-12 17:03:44 +0000
commitd2a764b04824233f2068460c3806016abf692b31 (patch)
treedec8037f9d4860c55dc83ea0fa97ad5bcbeab69f
parent127401e9fbca889c1a64836ae06ac03309e26e7c (diff)
parenta90bcd956de2f040480c8349548397596094e50d (diff)
Merge "Reset root array length when using setnode"
-rw-r--r--sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java5
-rw-r--r--sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java5
-rw-r--r--sli/provider/src/test/resources/clearArrayValues.xml5
3 files changed, 15 insertions, 0 deletions
diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java
index 758f2039c..5019b5681 100644
--- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java
+++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutor.java
@@ -131,6 +131,11 @@ public class SetNodeExecutor extends SvcLogicNodeExecutor {
// If RHS is empty, unset attributes in LHS
LinkedList<String> parmsToRemove = new LinkedList<String>();
String prefix = lhsVarName + ".";
+ //Clear length value in case an array exists with this prefix
+ String lengthParamName = lhsVarName + "_length";
+ parmsToRemove.add(lengthParamName);
+ LOG.debug("Unsetting " + lengthParamName + " because prefix " + prefix + " is being cleared.");
+
for (String curCtxVarname : ctx.getAttributeKeySet()) {
String curCtxVarnameMatchingValue = curCtxVarname;
//Special handling for reseting array values, strips out brackets and any numbers between the brackets
diff --git a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java
index c400bf5d1..9ba2c05e6 100644
--- a/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java
+++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/SetNodeExecutorTest.java
@@ -48,6 +48,11 @@ public class SetNodeExecutorTest {
assertNull(ctx.getAttribute("si[0].field1"));
assertNull(ctx.getAttribute("si[1].field2"));
assertNull(ctx.getAttribute("si[2].field3"));
+ assertNull(ctx.getAttribute("si_length"));
+ assertNull(ctx.getAttribute("si[0].subarray[0]"));
+ assertNull(ctx.getAttribute("si[0].subarray[1]"));
+ assertNull(ctx.getAttribute("si[0].subarray[2]"));
+ assertNull(ctx.getAttribute("si[0].subarray_length"));
assertEquals("6", ctx.getAttribute("search1"));
assertEquals("KeepMe!", ctx.getAttribute("simonSays"));
}
diff --git a/sli/provider/src/test/resources/clearArrayValues.xml b/sli/provider/src/test/resources/clearArrayValues.xml
index 629322d65..8f40058f1 100644
--- a/sli/provider/src/test/resources/clearArrayValues.xml
+++ b/sli/provider/src/test/resources/clearArrayValues.xml
@@ -7,6 +7,11 @@
<parameter name='si[0].field1' value='1' />
<parameter name='si[1].field2' value='2' />
<parameter name='si[2].field3' value='3' />
+ <parameter name='si_length' value='3' />
+ <parameter name='si[0].subarray[0]' value='a' />
+ <parameter name='si[0].subarray[1]' value='b' />
+ <parameter name='si[0].subarray[2]' value='c' />
+ <parameter name='si[0].subarray_length' value='3' />
<parameter name='search1' value='6' />
<parameter name='simonSays' value='KeepMe!' />
</set>