diff options
author | Smokowski, Kevin (ks6305) <ks6305@att.com> | 2018-06-12 15:51:30 +0000 |
---|---|---|
committer | Smokowski, Kevin (ks6305) <ks6305@att.com> | 2018-06-12 15:52:10 +0000 |
commit | a90bcd956de2f040480c8349548397596094e50d (patch) | |
tree | 9b2bf2dbb69d7bf36ab1f46016fb35b3261d0ba5 | |
parent | 88115d6cf23b4d836cb5637905d46412fb82c7e4 (diff) |
Reset root array length when using setnode
Reset root array length when using setnode shortcut to support backwards compatibility
Change-Id: I0a51e396a9c75a632759cefd82ef4c6c6ca3a384
Issue-ID: CCSDK-302
Signed-off-by: Smokowski, Kevin (ks6305) <ks6305@att.com>
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>
|