Fix for deviation list mapping in Restconf
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / utils / mapping / RestconfMappingNodeUtilTest.java
index 116139dc3d1ee694cbe6d460861f6cce28bde681..c08e40814c7a7ed5b49e332f3f5760e08da16fba 100644 (file)
@@ -116,6 +116,8 @@ public class RestconfMappingNodeUtilTest {
 
         // verify loaded modules
         verifyLoadedModules((ContainerNode) mods);
+        // verify deviations
+        verifyDeviations((ContainerNode) mods);
     }
 
     @Test
@@ -204,6 +206,30 @@ public class RestconfMappingNodeUtilTest {
         }
     }
 
+    /**
+     * Verify whether the loaded modules contain any deviations.
+     *
+     * @param containerNode
+     *             modules
+     */
+    private static void verifyDeviations(final ContainerNode containerNode) {
+        int deviationsFound = 0;
+        for (final DataContainerChild child : containerNode.getValue()) {
+            if (child instanceof MapNode) {
+                for (final MapEntryNode mapEntryNode : ((MapNode) child).getValue()) {
+                    for (final DataContainerChild dataContainerChild : mapEntryNode
+                            .getValue()) {
+                        if (dataContainerChild.getNodeType()
+                                .equals(IetfYangLibrary.SPECIFIC_MODULE_DEVIATION_LIST_QNAME)) {
+                            deviationsFound++;
+                        }
+                    }
+                }
+            }
+        }
+        Assert.assertTrue(deviationsFound > 0);
+    }
+
     /**
      * Verify loaded modules.
      *