1 package org.opendaylight.controller.sal.restconf.impl.json.to.cnsn.test;
3 import static org.junit.Assert.*;
5 import org.junit.BeforeClass;
7 import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
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.*;
12 public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader {
15 public static void initialize() {
16 dataLoad("/json-to-cnsn/leafref");
20 * JSON values which represents leafref are always loaded to simple node as
24 public void jsonIdentityrefToCompositeNode() {
25 CompositeNode compositeNode = TestUtils.readInputToCnSn("/json-to-cnsn/leafref/json/data.json", false,
26 JsonToCompositeNodeProvider.INSTANCE);
27 assertNotNull(compositeNode);
28 TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName);
30 assertEquals("cont", compositeNode.getNodeType().getLocalName());
32 SimpleNode<?> lf2 = null;
33 for (Node<?> childNode : compositeNode.getChildren()) {
34 if (childNode instanceof SimpleNode) {
35 if (childNode.getNodeType().getLocalName().equals("lf2")) {
36 lf2 = (SimpleNode<?>) childNode;
43 assertTrue(lf2.getValue() instanceof String);
44 assertEquals("121", (String) lf2.getValue());