X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Fxml%2Fto%2Fcnsn%2Ftest%2FXmlLeafrefToCnSnTest.java;h=1c62b7fbdb8e9013a38cd124d1df4e1c481bf3e5;hb=48daeb11697dbb83f554b64fe8702e21de3e0a12;hp=7a949b8f2df962ad9efcf6d93b532296263cb98a;hpb=2c7c9ef5e517de98e0d740f938762cc746dbcde1;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlLeafrefToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlLeafrefToCnSnTest.java index 7a949b8f2d..1c62b7fbdb 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlLeafrefToCnSnTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlLeafrefToCnSnTest.java @@ -13,7 +13,6 @@ import static org.junit.Assert.assertTrue; import java.util.List; import java.util.Set; - import org.junit.Ignore; import org.junit.Test; import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider; @@ -30,13 +29,15 @@ public class XmlLeafrefToCnSnTest { private static final Logger LOG = LoggerFactory.getLogger(XmlLeafrefToCnSnTest.class); /** - * top level element represents container. second level element is list with - * two elements. + * top level element represents container. second level element is list with two elements. */ @Test public void testXmlDataContainer() { - CompositeNode compNode = TestUtils.readInputToCnSn("/xml-to-cnsn/data-container.xml", false, + Node node = TestUtils.readInputToCnSn("/xml-to-cnsn/data-container.xml", false, XmlToCompositeNodeProvider.INSTANCE); + assertTrue(node instanceof CompositeNode); + CompositeNode compNode = (CompositeNode)node; + assertNotNull(compNode); Set modules = TestUtils.loadModulesFrom("/xml-to-cnsn/data-container-yang"); @@ -50,13 +51,13 @@ public class XmlLeafrefToCnSnTest { verifyCommonPartAOfXml(compNode, "", nameSpace); } - private void verifyNullAndEmptyStringSingleNode(CompositeNode compNode, String nameSpace) { + private void verifyNullAndEmptyStringSingleNode(final CompositeNode compNode, final String nameSpace) { assertEquals("cont", compNode.getNodeType().getLocalName()); SimpleNode lf2 = null; SimpleNode lf3 = null; int found = 0; - for (Node child : compNode.getChildren()) { + for (Node child : compNode.getValue()) { if (found == 0x3) break; if (child instanceof SimpleNode) { @@ -78,9 +79,11 @@ public class XmlLeafrefToCnSnTest { @Test public void testXmlDataList() { - CompositeNode compNode = TestUtils.readInputToCnSn("/xml-to-cnsn/data-list.xml", false, + Node node = TestUtils.readInputToCnSn("/xml-to-cnsn/data-list.xml", false, XmlToCompositeNodeProvider.INSTANCE); - assertNotNull(compNode); + assertTrue(node instanceof CompositeNode); + CompositeNode compNode = (CompositeNode)node; + Set modules = TestUtils.loadModulesFrom("/xml-to-cnsn/data-list-yang"); assertNotNull(modules); @@ -91,26 +94,26 @@ public class XmlLeafrefToCnSnTest { String nameSpaceCont = "data:container:yang"; assertEquals(nameSpaceCont, compNode.getNodeType().getNamespace().toString()); assertEquals("cont", compNode.getNodeType().getLocalName()); - assertEquals(3, compNode.getChildren().size()); + assertEquals(3, compNode.getValue().size()); CompositeNode lst1_1 = null; CompositeNode lst1_2 = null; int loopCount = 0; - for (Node node : compNode.getChildren()) { - if (node.getNodeType().getLocalName().equals("lf1")) { - assertEquals(nameSpaceList, node.getNodeType().getNamespace().toString()); - assertTrue(node instanceof SimpleNode); - assertEquals("lf1", node.getValue()); + for (Node nd : compNode.getValue()) { + if (nd.getNodeType().getLocalName().equals("lf1")) { + assertEquals(nameSpaceList, nd.getNodeType().getNamespace().toString()); + assertTrue(nd instanceof SimpleNode); + assertEquals("lf1", nd.getValue()); } else { - assertTrue(node instanceof CompositeNode); + assertTrue(nd instanceof CompositeNode); switch (loopCount++) { case 0: - lst1_1 = (CompositeNode) node; + lst1_1 = (CompositeNode) nd; break; case 1: - lst1_2 = (CompositeNode) node; + lst1_2 = (CompositeNode) nd; break; } - assertEquals(nameSpaceCont, node.getNodeType().getNamespace().toString()); + assertEquals(nameSpaceCont, nd.getNodeType().getNamespace().toString()); } } // lst1_1 @@ -120,23 +123,23 @@ public class XmlLeafrefToCnSnTest { // lst1_2 SimpleNode lflst11 = null; CompositeNode cont11 = null; - for (Node node : lst1_2.getChildren()) { - String nodeName = node.getNodeType().getLocalName(); + for (Node nd : lst1_2.getValue()) { + String nodeName = nd.getNodeType().getLocalName(); if (nodeName.equals("lflst11")) { - assertTrue(node instanceof SimpleNode); - lflst11 = (SimpleNode) node; + assertTrue(nd instanceof SimpleNode); + lflst11 = (SimpleNode) nd; } else if (nodeName.equals("cont11")) { - assertTrue(node instanceof CompositeNode); - cont11 = (CompositeNode) node; + assertTrue(nd instanceof CompositeNode); + cont11 = (CompositeNode) nd; } assertEquals(nameSpaceCont, compNode.getNodeType().getNamespace().toString()); } assertEquals("221", lflst11.getValue()); - assertEquals(1, cont11.getChildren().size()); - assertTrue(cont11.getChildren().get(0) instanceof SimpleNode); - SimpleNode cont11_lf111 = (SimpleNode) cont11.getChildren().get(0); + assertEquals(1, cont11.getValue().size()); + assertTrue(cont11.getValue().get(0) instanceof SimpleNode); + SimpleNode cont11_lf111 = (SimpleNode) cont11.getValue().get(0); assertEquals(nameSpaceCont, cont11_lf111.getNodeType().getNamespace().toString()); assertEquals("lf111", cont11_lf111.getNodeType().getLocalName()); assertEquals((short) 100, cont11_lf111.getValue()); @@ -146,32 +149,35 @@ public class XmlLeafrefToCnSnTest { @Test public void testXmlEmptyData() { - CompositeNode compNode = TestUtils.readInputToCnSn("/xml-to-cnsn/empty-data.xml", true, + Node node = TestUtils.readInputToCnSn("/xml-to-cnsn/empty-data.xml", true, XmlToCompositeNodeProvider.INSTANCE); + assertTrue(node instanceof CompositeNode); + CompositeNode compNode = (CompositeNode)node; + assertEquals("cont", compNode.getNodeType().getLocalName()); SimpleNode lf1 = null; SimpleNode lflst1_1 = null; SimpleNode lflst1_2 = null; CompositeNode lst1 = null; int lflst1Count = 0; - for (Node node : compNode.getChildren()) { - if (node.getNodeType().getLocalName().equals("lf1")) { - assertTrue(node instanceof SimpleNode); - lf1 = (SimpleNode) node; - } else if (node.getNodeType().getLocalName().equals("lflst1")) { - assertTrue(node instanceof SimpleNode); + for (Node nd : compNode.getValue()) { + if (nd.getNodeType().getLocalName().equals("lf1")) { + assertTrue(nd instanceof SimpleNode); + lf1 = (SimpleNode) nd; + } else if (nd.getNodeType().getLocalName().equals("lflst1")) { + assertTrue(nd instanceof SimpleNode); switch (lflst1Count++) { case 0: - lflst1_1 = (SimpleNode) node; + lflst1_1 = (SimpleNode) nd; break; case 1: - lflst1_2 = (SimpleNode) node; + lflst1_2 = (SimpleNode) nd; break; } - } else if (node.getNodeType().getLocalName().equals("lst1")) { - assertTrue(node instanceof CompositeNode); - lst1 = (CompositeNode) node; + } else if (nd.getNodeType().getLocalName().equals("lst1")) { + assertTrue(nd instanceof CompositeNode); + lst1 = (CompositeNode) nd; } } @@ -183,11 +189,11 @@ public class XmlLeafrefToCnSnTest { assertEquals("", lf1.getValue()); assertEquals("", lflst1_1.getValue()); assertEquals("", lflst1_2.getValue()); - assertEquals(1, lst1.getChildren().size()); - assertEquals("lf11", lst1.getChildren().get(0).getNodeType().getLocalName()); + assertEquals(1, lst1.getValue().size()); + assertEquals("lf11", lst1.getValue().get(0).getNodeType().getLocalName()); - assertTrue(lst1.getChildren().get(0) instanceof SimpleNode); - assertEquals("", lst1.getChildren().get(0).getValue()); + assertTrue(lst1.getValue().get(0) instanceof SimpleNode); + assertEquals("", lst1.getValue().get(0).getValue()); } @@ -201,9 +207,8 @@ public class XmlLeafrefToCnSnTest { } /** - * - * Test case like identity + * + * Test case like identity */ @Test @@ -213,9 +218,8 @@ public class XmlLeafrefToCnSnTest { } /** - * - * Test case like identity + * + * Test case like identity */ @Test public void testIdentityrefDefaultNmspcInParrentElement() { @@ -224,9 +228,8 @@ public class XmlLeafrefToCnSnTest { } /** - * - * Test case like - * x:identity + * + * Test case like x:identity */ @Ignore @Test @@ -236,9 +239,8 @@ public class XmlLeafrefToCnSnTest { } /** - * - * Test case like (without namespace in xml) x:identity - * + * + * Test case like (without namespace in xml) x:identity */ @Test public void testIdentityrefNoNmspcValueWithPrefix() { @@ -247,9 +249,8 @@ public class XmlLeafrefToCnSnTest { } /** - * - * Test case like (without namespace in xml) identity - * + * + * Test case like (without namespace in xml) identity */ @Test public void testIdentityrefNoNmspcValueWithoutPrefix() { @@ -257,7 +258,7 @@ public class XmlLeafrefToCnSnTest { "/xml-to-cnsn/identityref", "identityref-module", "cont", 2, "iden", "identityref:module"); } - private void verifyCommonPartAOfXml(CompositeNode compNode, String suf, String nameSpace) { + private void verifyCommonPartAOfXml(final CompositeNode compNode, final String suf, final String nameSpace) { SimpleNode lf1suf = null; SimpleNode lflst1suf_1 = null; SimpleNode lflst1suf_2 = null; @@ -267,7 +268,7 @@ public class XmlLeafrefToCnSnTest { int lflstCount = 0; - for (Node node : compNode.getChildren()) { + for (Node node : compNode.getValue()) { String localName = node.getNodeType().getLocalName(); if (localName.equals("lf1" + suf)) { assertTrue(node instanceof SimpleNode); @@ -307,25 +308,27 @@ public class XmlLeafrefToCnSnTest { assertEquals("131", lflst1suf_2.getValue()); assertEquals("str1", lflst1suf_3.getValue()); - assertEquals(1, lst1suf.getChildren().size()); + assertEquals(1, lst1suf.getValue().size()); - assertTrue(lst1suf.getChildren().get(0) instanceof SimpleNode); - SimpleNode lst11_lf11 = (SimpleNode) lst1suf.getChildren().get(0); + assertTrue(lst1suf.getValue().get(0) instanceof SimpleNode); + SimpleNode lst11_lf11 = (SimpleNode) lst1suf.getValue().get(0); assertEquals(nameSpace, lst11_lf11.getNodeType().getNamespace().toString()); assertEquals("lf11" + suf, lst11_lf11.getNodeType().getLocalName()); assertEquals("str2", lst11_lf11.getValue()); - assertTrue(cont1suf.getChildren().get(0) instanceof SimpleNode); - SimpleNode cont1_lf11 = (SimpleNode) cont1suf.getChildren().get(0); + assertTrue(cont1suf.getValue().get(0) instanceof SimpleNode); + SimpleNode cont1_lf11 = (SimpleNode) cont1suf.getValue().get(0); assertEquals(nameSpace, cont1_lf11.getNodeType().getNamespace().toString()); assertEquals("lf11" + suf, cont1_lf11.getNodeType().getLocalName()); assertEquals((short) 100, cont1_lf11.getValue()); } - private void testIdentityrefToCnSn(String xmlPath, String yangPath, String moduleName, String schemaName, - int moduleCount, String resultLocalName, String resultNamespace) { - CompositeNode compositeNode = TestUtils.readInputToCnSn(xmlPath, false, XmlToCompositeNodeProvider.INSTANCE); - assertNotNull(compositeNode); + private void testIdentityrefToCnSn(final String xmlPath, final String yangPath, final String moduleName, + final String schemaName, final int moduleCount, final String resultLocalName, final String resultNamespace) { + Node node = TestUtils.readInputToCnSn(xmlPath, false, XmlToCompositeNodeProvider.INSTANCE); + assertTrue(node instanceof CompositeNode); + CompositeNode compositeNode = (CompositeNode)node; + Set modules = TestUtils.loadModulesFrom(yangPath); assertEquals(moduleCount, modules.size()); @@ -339,16 +342,16 @@ public class XmlLeafrefToCnSnTest { assertEquals(resultNamespace, qName.getNamespace().toString()); } - private SimpleNode getLf11(CompositeNode compositeNode) { + private SimpleNode getLf11(final CompositeNode compositeNode) { assertEquals("cont", compositeNode.getNodeType().getLocalName()); - List> childs = compositeNode.getChildren(); + List> childs = compositeNode.getValue(); assertEquals(1, childs.size()); Node nd = childs.iterator().next(); assertTrue(nd instanceof CompositeNode); assertEquals("cont1", nd.getNodeType().getLocalName()); - childs = ((CompositeNode) nd).getChildren(); + childs = ((CompositeNode) nd).getValue(); SimpleNode lf11 = null; for (Node child : childs) { assertTrue(child instanceof SimpleNode);