More test for improving of code coverage + test refactoring
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / xml / to / cnsn / test / XmlToCnSnTest.java
1 package org.opendaylight.controller.sal.restconf.impl.xml.to.cnsn.test;
2
3 import static org.junit.Assert.*;
4
5 import org.junit.BeforeClass;
6 import org.junit.Test;
7 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
8 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
9 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
10 import org.opendaylight.yangtools.yang.data.api.*;
11
12 public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader {
13
14     @BeforeClass
15     public static void initialize() {
16         dataLoad("/xml-to-cnsn/leafref");
17     }
18
19     @Test
20     public void testXmlLeafrefToCnSn() {
21         CompositeNode compositeNode = TestUtils.readInputToCnSn("/xml-to-cnsn/leafref/xml/data.xml", false,
22                 XmlToCompositeNodeProvider.INSTANCE);
23         assertNotNull(compositeNode);
24         assertNotNull(dataSchemaNode);
25         TestUtils.normalizeCompositeNode(compositeNode, modules, schemaNodePath);
26
27         assertEquals("cont", compositeNode.getNodeType().getLocalName());
28
29         SimpleNode<?> lf2 = null;
30         for (Node<?> childNode : compositeNode.getChildren()) {
31             if (childNode instanceof SimpleNode) {
32                 if (childNode.getNodeType().getLocalName().equals("lf2")) {
33                     lf2 = (SimpleNode<?>) childNode;
34                     break;
35                 }
36             }
37         }
38
39         assertNotNull(lf2);
40         assertTrue(lf2.getValue() instanceof String);
41         assertEquals("121", (String) lf2.getValue());
42     }
43
44 }