1 package org.opendaylight.controller.sal.restconf.impl.cnsn.to.json.test;
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
6 import java.io.IOException;
8 import javax.ws.rs.WebApplicationException;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
13 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
14 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
15 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
16 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
18 public class CnSnToJsonWithAugmentTest extends YangAndXmlAndDataSchemaLoader {
21 public static void initialize() {
22 dataLoad("/cnsn-to-json/augmentation", 5, "yang", "cont");
26 * Test of json output when as input are specified composite node with empty
30 public void augmentedElementsToJson() {
31 CompositeNode compositeNode = TestUtils.readInputToCnSn("/cnsn-to-json/augmentation/xml/data.xml",
32 XmlToCompositeNodeProvider.INSTANCE);
33 TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName);
35 String jsonOutput = null;
37 jsonOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(compositeNode, modules, dataSchemaNode,
38 StructuredDataToJsonProvider.INSTANCE);
39 } catch (WebApplicationException | IOException e) {
41 assertNotNull(jsonOutput);
43 assertTrue(jsonOutput.contains("\"augment-leaf:lf2\": \"lf2\""));
44 assertTrue(jsonOutput.contains("\"augment-container:cont1\": {"));
45 assertTrue(jsonOutput.contains("\"augment-container:lf11\": \"lf11\""));
46 assertTrue(jsonOutput.contains("\"augment-list:lst1\": ["));
47 assertTrue(jsonOutput.contains("\"augment-list:lf11\": \"lf1_1\""));
48 assertTrue(jsonOutput.contains("\"augment-list:lf11\": \"lf1_2\""));
49 assertTrue(jsonOutput.contains("\"augment-leaflist:lflst1\": ["));