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.cnsn.to.json.test;
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12 import static org.opendaylight.controller.sal.restconf.impl.test.TestUtils.containsStringData;
14 import java.io.IOException;
15 import javax.ws.rs.WebApplicationException;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
19 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
20 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
21 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
22 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
24 public class CnSnToJsonWithAugmentTest extends YangAndXmlAndDataSchemaLoader {
27 public static void initialize() {
28 dataLoad("/cnsn-to-json/augmentation", 5, "yang", "cont");
32 * Test of json output when as input are specified composite node with empty data + YANG file
35 public void augmentedElementsToJson() {
36 CompositeNode compositeNode = TestUtils.readInputToCnSn("/cnsn-to-json/augmentation/xml/data.xml",
37 XmlToCompositeNodeProvider.INSTANCE);
38 TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName);
40 String jsonOutput = null;
42 jsonOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(compositeNode, modules, dataSchemaNode,
43 StructuredDataToJsonProvider.INSTANCE);
44 } catch (WebApplicationException | IOException e) {
46 assertNotNull(jsonOutput);
48 assertTrue(containsStringData(jsonOutput, "\"augment-leaf:lf2\"", ":", "\"lf2\""));
49 assertTrue(containsStringData(jsonOutput, "\"augment-container:cont1\"", ":", "\\{"));
50 assertTrue(containsStringData(jsonOutput, "\"augment-container:lf11\"", ":", "\"lf11\""));
51 assertTrue(containsStringData(jsonOutput, "\"augment-list:lst1\"", ":", "\\["));
52 assertTrue(containsStringData(jsonOutput, "\"augment-list:lf11\"", ":", "\"lf1_1\""));
53 assertTrue(containsStringData(jsonOutput, "\"augment-list:lf11\"", ":", "\"lf1_2\""));
54 assertTrue(containsStringData(jsonOutput, "\"augment-leaflist:lflst1\"", ":", "\\["));