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%2Fcnsn%2Fto%2Fjson%2Ftest%2FCnSnToJsonWithAugmentTest.java;h=72b9ed93d469642886064641fabfb18284244052;hb=a51537ff2f51571e54b607eace980a145b2a29da;hp=3c2325c0f305cbc0853a4d2486afd76c65eede2d;hpb=eb538dbc16c0bb487f8ed70547b0df2c8c96c432;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithAugmentTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithAugmentTest.java index 3c2325c0f3..72b9ed93d4 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithAugmentTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonWithAugmentTest.java @@ -1,19 +1,25 @@ +/* + * 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.cnsn.to.json.test; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.opendaylight.controller.sal.restconf.impl.test.TestUtils.containsStringData; import java.io.IOException; - import javax.ws.rs.WebApplicationException; - import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider; import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider; 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.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.Node; public class CnSnToJsonWithAugmentTest extends YangAndXmlAndDataSchemaLoader { @@ -23,29 +29,28 @@ public class CnSnToJsonWithAugmentTest extends YangAndXmlAndDataSchemaLoader { } /** - * Test of json output when as input are specified composite node with empty - * data + YANG file + * Test of json output when as input are specified composite node with empty data + YANG file */ @Test public void augmentedElementsToJson() { - CompositeNode compositeNode = TestUtils.readInputToCnSn("/cnsn-to-json/augmentation/xml/data.xml", + Node node = TestUtils.readInputToCnSn("/cnsn-to-json/augmentation/xml/data.xml", XmlToCompositeNodeProvider.INSTANCE); - TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName); + TestUtils.normalizeCompositeNode(node, modules, searchedModuleName + ":" + searchedDataSchemaName); String jsonOutput = null; try { - jsonOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(compositeNode, modules, dataSchemaNode, + jsonOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(node, modules, dataSchemaNode, StructuredDataToJsonProvider.INSTANCE); } catch (WebApplicationException | IOException e) { } assertNotNull(jsonOutput); - assertTrue(jsonOutput.contains("\"augment-leaf:lf2\": \"lf2\"")); - assertTrue(jsonOutput.contains("\"augment-container:cont1\": {")); - assertTrue(jsonOutput.contains("\"augment-container:lf11\": \"lf11\"")); - assertTrue(jsonOutput.contains("\"augment-list:lst1\": [")); - assertTrue(jsonOutput.contains("\"augment-list:lf11\": \"lf1_1\"")); - assertTrue(jsonOutput.contains("\"augment-list:lf11\": \"lf1_2\"")); - assertTrue(jsonOutput.contains("\"augment-leaflist:lflst1\": [")); + assertTrue(containsStringData(jsonOutput, "\"augment-leaf:lf2\"", ":", "\"lf2\"")); + assertTrue(containsStringData(jsonOutput, "\"augment-container:cont1\"", ":", "\\{")); + assertTrue(containsStringData(jsonOutput, "\"augment-container:lf11\"", ":", "\"lf11\"")); + assertTrue(containsStringData(jsonOutput, "\"augment-list:lst1\"", ":", "\\[")); + assertTrue(containsStringData(jsonOutput, "\"augment-list:lf11\"", ":", "\"lf1_1\"")); + assertTrue(containsStringData(jsonOutput, "\"augment-list:lf11\"", ":", "\"lf1_2\"")); + assertTrue(containsStringData(jsonOutput, "\"augment-leaflist:lflst1\"", ":", "\\[")); } }