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.restconf.impl.test.TestUtils;
14 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
15 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
17 public class CnSnToJsonWithAugmentTest extends YangAndXmlAndDataSchemaLoader {
20 public static void initialize() {
21 dataLoad("/cnsn-to-json/augmentation", 5, "yang", "cont");
25 * Test of json output when as input are specified composite node with empty
29 public void augmentedElementsToJson() {
30 CompositeNode compositeNode = TestUtils.loadCompositeNode("/cnsn-to-json/augmentation/xml/data.xml");
31 TestUtils.normalizeCompositeNode(compositeNode, modules, searchedModuleName + ":" + searchedDataSchemaName);
33 String jsonOutput = null;
35 jsonOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(compositeNode, modules, dataSchemaNode,
36 StructuredDataToJsonProvider.INSTANCE);
37 } catch (WebApplicationException | IOException e) {
39 assertNotNull(jsonOutput);
41 assertTrue(jsonOutput.contains("\"augment-leaf:lf2\": \"lf2\""));
42 assertTrue(jsonOutput.contains("\"augment-container:cont1\": {"));
43 assertTrue(jsonOutput.contains("\"augment-container:lf11\": \"lf11\""));
44 assertTrue(jsonOutput.contains("\"augment-list:lst1\": ["));
45 assertTrue(jsonOutput.contains("\"augment-list:lf11\": \"lf1_1\""));
46 assertTrue(jsonOutput.contains("\"augment-list:lf11\": \"lf1_2\""));
47 assertTrue(jsonOutput.contains("\"augment-leaflist:lflst1\": ["));