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