2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.restconf.impl.json.to.cnsn.test;
10 import static org.junit.Assert.*;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
15 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
16 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
17 import org.opendaylight.yangtools.yang.data.api.*;
19 public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader {
22 public static void initialize() {
23 dataLoad("/json-to-cnsn/leafref");
27 * JSON values which represents leafref are always loaded to simple node as
31 public void jsonIdentityrefToCompositeNode() {
32 CompositeNode compositeNode = TestUtils.readInputToCnSn("/json-to-cnsn/leafref/json/data.json", false,
33 JsonToCompositeNodeProvider.INSTANCE);
34 assertNotNull(compositeNode);
35 TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName);
37 assertEquals("cont", compositeNode.getNodeType().getLocalName());
39 SimpleNode<?> lf2 = null;
40 for (Node<?> childNode : compositeNode.getChildren()) {
41 if (childNode instanceof SimpleNode) {
42 if (childNode.getNodeType().getLocalName().equals("lf2")) {
43 lf2 = (SimpleNode<?>) childNode;
50 assertTrue(lf2.getValue() instanceof String);
51 assertEquals("121", (String) lf2.getValue());