Add test coverage for last missed branch in cps-service 00/142000/1
authorToineSiebelink <toine.siebelink@est.tech>
Mon, 8 Sep 2025 10:17:54 +0000 (11:17 +0100)
committerToineSiebelink <toine.siebelink@est.tech>
Mon, 8 Sep 2025 10:17:54 +0000 (11:17 +0100)
- Add test for user-order leaf-list using test-tree model
 (see https://en.wikipedia.org/wiki/The_Rattlin%27_Bog)

Issue-ID: CPS-475
Change-Id: I1adf107289e7fa0a9f832bfdc4267c04615eaa28
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
cps-service/src/main/java/org/onap/cps/impl/DataNodeBuilder.java
cps-service/src/test/groovy/org/onap/cps/impl/DataNodeBuilderSpec.groovy
cps-service/src/test/resources/test-tree.json
cps-service/src/test/resources/test-tree.yang

index e9c11a7..e738eeb 100644 (file)
@@ -247,6 +247,8 @@ public class DataNodeBuilder {
                 .collect(Collectors.toList());
         if (leafSetNode.ordering() == Ordering.SYSTEM) {
             leafListValues.sort(null);
+        } else {
+            log.trace("Maintaining user order");
         }
         leafListValues = Collections.unmodifiableList(leafListValues);
         addYangLeaf(currentDataNode, leafListName, (Serializable) leafListValues);
index 5b9a961..71da0ba 100644 (file)
@@ -44,7 +44,7 @@ class DataNodeBuilderSpec extends Specification {
             '/test-tree/branch[@name=\'Left\']/nest'                : [name: 'Small', birds: ['Sparrow', 'Robin', 'Finch']],
             '/test-tree/branch[@name=\'Right\']'                    : [name: 'Right'],
             '/test-tree/branch[@name=\'Right\']/nest'               : [name: 'Big', birds: ['Owl', 'Raven', 'Crow']],
-            '/test-tree/fruit[@color=\'Green\' and @name=\'Apple\']': [color: 'Green', name: 'Apple']
+            '/test-tree/fruit[@color=\'Green\' and @name=\'Apple\']': [color: 'Green', name: 'Apple', rattlinBog: ['tick', 'louse', 'hair', 'worm']]
     ]
 
     String[] networkTopologyModelRfc8345 = [
index e1789ab..2db3f95 100644 (file)
     "fruit": [
       {
         "name": "Apple",
-        "color": "Green"
+        "color": "Green",
+        "rattlinBog": [
+          "tick",
+          "louse",
+          "hair",
+          "worm"
+        ]
       }
     ]
   }
index a9f7e22..057b698 100644 (file)
@@ -31,6 +31,11 @@ module test-tree {
                 type string;
             }
 
+            leaf-list rattlinBog {
+                type string;
+                ordered-by user;
+            }
+
         }
     }
     leaf topLevelLeafAddedForBranchCoverageInPrefixResolverSpec {