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%2Fjson%2Fto%2Fcnsn%2Ftest%2FJsonLeafrefToCnSnTest.java;h=bdd74e8f9617a634235814304f21a3362eefeb6f;hb=a9406b1074eecabc79d13cd47f1c0f221b99e428;hp=2bb42d903af4f77aebbdc6a8dfb375643c5c0a55;hpb=1f3ee2a2588512476704f3bf1c3528753ad453d5;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java index 2bb42d903a..bdd74e8f96 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java @@ -1,13 +1,24 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.restconf.impl.json.to.cnsn.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider; import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; -import org.opendaylight.yangtools.yang.data.api.*; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.api.SimpleNode; public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader { @@ -17,20 +28,20 @@ public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader { } /** - * JSON values which represents leafref are always loaded to simple node as - * string + * JSON values which represents leafref are always loaded to simple node as string */ @Test public void jsonIdentityrefToCompositeNode() { - CompositeNode compositeNode = TestUtils.readInputToCnSn("/json-to-cnsn/leafref/json/data.json", false, + Node node = TestUtils.readInputToCnSn("/json-to-cnsn/leafref/json/data.json", false, JsonToCompositeNodeProvider.INSTANCE); - assertNotNull(compositeNode); - TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName); + assertNotNull(node); + TestUtils.normalizeCompositeNode(node, modules, searchedModuleName + ":" + searchedDataSchemaName); - assertEquals("cont", compositeNode.getNodeType().getLocalName()); + assertEquals("cont", node.getNodeType().getLocalName()); SimpleNode lf2 = null; - for (Node childNode : compositeNode.getChildren()) { + assertTrue(node instanceof CompositeNode); + for (Node childNode : ((CompositeNode) node).getValue()) { if (childNode instanceof SimpleNode) { if (childNode.getNodeType().getLocalName().equals("lf2")) { lf2 = (SimpleNode) childNode; @@ -40,9 +51,7 @@ public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader { } assertNotNull(lf2); - assertTrue(lf2.getValue() instanceof String); - assertEquals("121", (String) lf2.getValue()); - + assertEquals(121, lf2.getValue()); } }