Bug 2358 - Remove tests json to cnsn and add tests json to nn 90/19290/7
authorary <jatoth@cisco.com>
Wed, 29 Apr 2015 10:09:41 +0000 (12:09 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 23 Jul 2015 09:03:57 +0000 (09:03 +0000)
Tests of codecs are included in codecs yangtools yang-data-codec-gson and yang-data-impl but
we test codec on input data and also with presentation of Rest path.

* remove all tests json to composite node and simple node
* rewrite json leafref input tests from comp and simple node to normalized node
  * we're testing REST provider URI path translator with payload
* add test for test data in json with identityref to normalized node
  * positive test
  * test data in builded normalized node with data in json
    * used identityref type to reference an existing identity
* add test for test data in json with leafref to normalized node
  * positive test
  * test data in builded normalized node with data in json
    * used leafref type to reference particular leaf instance in the data tree
* add test for test data in json with more type of nodes and values
  * positive tests
    * test normalized node from json with:
      * simple data in list
      * simple data in container
      * multiple items in leaf-list
      * multiple items in list
      * empty leaf
      * augmented data
  * negative tests
    * test fail on bad top level elements
      * contains 3 situations
    * test fail for null data
      * empty leaf-list
      * leaf without any value
    * test on build normalized node with blank json
    * test fail with different namespaces
    * test fail because of unsupported format of json
    * test on invalid URI character

Change-Id: Icb5ff5d11843123c79859a0c75d7df7bad8a0b44
Signed-off-by: Jakub Toth <jatoth@cisco.com>
(cherry picked from commit a3fd2b66c8121a8603d684b97c1fb7076d933d99)

opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonIdentityrefToCnSnTest.java [deleted file]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java [deleted file]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java [deleted file]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonIdentityrefToNnTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonLeafrefToNnTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java [new file with mode: 0644]

diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonIdentityrefToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonIdentityrefToCnSnTest.java
deleted file mode 100644 (file)
index 86c1595..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.json.to.cnsn.test;
-
-import org.junit.BeforeClass;
-import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
-
-public class JsonIdentityrefToCnSnTest extends YangAndXmlAndDataSchemaLoader {
-
-    @BeforeClass
-    public static void initialize() {
-        dataLoad("/json-to-cnsn/identityref", 2, "identityref-module", "cont");
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonLeafrefToCnSnTest.java
deleted file mode 100644 (file)
index 4705de3..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.json.to.cnsn.test;
-
-import org.junit.BeforeClass;
-import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
-
-public class JsonLeafrefToCnSnTest extends YangAndXmlAndDataSchemaLoader {
-
-    @BeforeClass
-    public static void initialize() {
-        dataLoad("/json-to-cnsn/leafref",2,"leafref-module","cont");
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/cnsn/test/JsonToCnSnTest.java
deleted file mode 100644 (file)
index a14bba1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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.json.to.cnsn.test;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JsonToCnSnTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(JsonToCnSnTest.class);
-}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonIdentityrefToNnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonIdentityrefToNnTest.java
new file mode 100644 (file)
index 0000000..6577355
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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.json.to.nn.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader;
+import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class JsonIdentityrefToNnTest extends AbstractBodyReaderTest {
+
+    private final JsonNormalizedNodeBodyReader jsonBodyReader;
+    private static SchemaContext schemaContext;
+
+    public JsonIdentityrefToNnTest() throws NoSuchFieldException,
+            SecurityException {
+        super();
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+    }
+
+    @BeforeClass
+    public static void initialize() {
+        schemaContext = schemaContextLoader("/json-to-nn/identityref",
+                schemaContext);
+        controllerContext.setSchemas(schemaContext);
+    }
+
+    @Test
+    public void jsonIdentityrefToNn() throws NoSuchFieldException,
+            SecurityException, IllegalArgumentException,
+            IllegalAccessException, WebApplicationException, IOException {
+
+        String uri = "identityref-module:cont";
+        mockBodyReader(uri, jsonBodyReader, false);
+        InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/identityref/json/data.json");
+
+        NormalizedNodeContext normalizedNodeContext = jsonBodyReader.readFrom(
+                null, null, null, mediaType, null, inputStream);
+
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+
+        String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+
+        assertTrue(dataTree.contains("cont1"));
+        assertTrue(dataTree
+                .contains("lf11 (identity:module?revision=2013-12-02)iden"));
+        assertTrue(dataTree
+                .contains("lf12 (identityref:module?revision=2013-12-02)iden_local"));
+        assertTrue(dataTree
+                .contains("lf13 (identityref:module?revision=2013-12-02)iden_local"));
+        assertTrue(dataTree
+                .contains("lf14 (identity:module?revision=2013-12-02)iden"));
+    }
+
+    @Override
+    protected MediaType getMediaType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonLeafrefToNnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonLeafrefToNnTest.java
new file mode 100644 (file)
index 0000000..afeddc2
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.json.to.nn.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader;
+import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class JsonLeafrefToNnTest extends AbstractBodyReaderTest {
+
+    private final JsonNormalizedNodeBodyReader jsonBodyReader;
+    private static SchemaContext schemaContext;
+
+    public JsonLeafrefToNnTest() throws NoSuchFieldException, SecurityException {
+        super();
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+    }
+
+    @BeforeClass
+    public static void initialize() {
+        schemaContext = schemaContextLoader("/json-to-nn/leafref",
+                schemaContext);
+        controllerContext.setSchemas(schemaContext);
+    }
+
+    @Test
+    public void jsonIdentityrefToNormalizeNode() throws NoSuchFieldException,
+            SecurityException, IllegalArgumentException,
+            IllegalAccessException, WebApplicationException, IOException {
+
+        String uri = "leafref-module:cont";
+        mockBodyReader(uri, jsonBodyReader, false);
+        InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/leafref/json/data.json");
+
+        NormalizedNodeContext normalizedNodeContext = jsonBodyReader.readFrom(
+                null, null, null, mediaType, null, inputStream);
+
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+        String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("lf2 121"));
+    }
+
+    @Override
+    protected MediaType getMediaType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/json/to/nn/test/JsonToNnTest.java
new file mode 100644 (file)
index 0000000..5f4945c
--- /dev/null
@@ -0,0 +1,393 @@
+/*
+ * 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.json.to.nn.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader;
+import org.opendaylight.controller.sal.rest.impl.test.providers.AbstractBodyReaderTest;
+import org.opendaylight.controller.sal.restconf.impl.NormalizedNodeContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class JsonToNnTest extends AbstractBodyReaderTest {
+
+    private JsonNormalizedNodeBodyReader jsonBodyReader;
+    private SchemaContext schemaContext;
+
+    public JsonToNnTest() throws NoSuchFieldException, SecurityException {
+        super();
+    }
+
+    public static void initialize(final String path, SchemaContext schemaContext) {
+        schemaContext = schemaContextLoader(path, schemaContext);
+        controllerContext.setSchemas(schemaContext);
+    }
+
+    @Test
+    public void simpleListTest() {
+        simpleTest("/json-to-nn/simple-list.json",
+                "/json-to-nn/simple-list-yang/1", "lst", "simple-list-yang1");
+    }
+
+    @Test
+    public void simpleContainerTest() {
+        simpleTest("/json-to-nn/simple-container.json",
+                "/json-to-nn/simple-container-yang", "cont",
+                "simple-container-yang");
+    }
+
+    @Test
+    public void multipleItemsInLeafListTest() {
+
+        initialize("/json-to-nn/simple-list-yang/1", schemaContext);
+
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC(
+                "/json-to-nn/multiple-leaflist-items.json",
+                "simple-list-yang1:lst");
+        assertNotNull(normalizedNodeContext);
+
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("45"));
+        assertTrue(dataTree.contains("55"));
+        assertTrue(dataTree.contains("66"));
+    }
+
+    @Test
+    public void multipleItemsInListTest() {
+        initialize("/json-to-nn/simple-list-yang/3", schemaContext);
+
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC(
+                "/json-to-nn/multiple-items-in-list.json",
+                "multiple-items-yang:lst");
+        assertNotNull(normalizedNodeContext);
+
+        assertEquals("lst", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+
+        verityMultipleItemsInList(normalizedNodeContext);
+    }
+
+    @Test
+    public void nullArrayToSimpleNodeWithNullValueTest() {
+        initialize("/json-to-nn/simple-list-yang/4", schemaContext);
+
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC(
+                "/json-to-nn/array-with-null.json", "array-with-null-yang:cont");
+        assertNotNull(normalizedNodeContext);
+
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("lf"));
+        assertTrue(dataTree.contains("null"));
+    }
+
+    @Test
+    public void incorrectTopLevelElementsTest() throws WebApplicationException,
+            IOException, NoSuchFieldException, SecurityException,
+            IllegalArgumentException, IllegalAccessException {
+
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        initialize("/json-to-nn/simple-list-yang/1", schemaContext);
+        mockBodyReader("simple-list-yang1:lst", jsonBodyReader, false);
+
+        InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/wrong-top-level1.json");
+
+        int countExceptions = 0;
+        RestconfDocumentedException exception = null;
+
+        try {
+            jsonBodyReader.readFrom(null, null, null, mediaType, null,
+                    inputStream);
+        } catch (final RestconfDocumentedException e) {
+            exception = e;
+            countExceptions++;
+        }
+        assertNotNull(exception);
+        assertEquals(
+                "Error parsing input: Schema node with name cont wasn't found under (urn:ietf:params:xml:ns:netconf:base:1.0)data.",
+                exception.getErrors().get(0).getErrorMessage());
+
+        inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/wrong-top-level2.json");
+        exception = null;
+        try {
+            jsonBodyReader.readFrom(null, null, null, mediaType, null,
+                    inputStream);
+        } catch (final RestconfDocumentedException e) {
+            exception = e;
+            countExceptions++;
+        }
+        assertNotNull(exception);
+        assertEquals(
+                "Error parsing input: Schema node with name lst1 wasn't found under (urn:ietf:params:xml:ns:netconf:base:1.0)data.",
+                exception.getErrors().get(0).getErrorMessage());
+
+        inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/wrong-top-level3.json");
+        exception = null;
+        try {
+            jsonBodyReader.readFrom(null, null, null, mediaType, null,
+                    inputStream);
+        } catch (final RestconfDocumentedException e) {
+            exception = e;
+            countExceptions++;
+        }
+        assertNotNull(exception);
+        assertEquals(
+                "Error parsing input: Schema node with name lf wasn't found under (urn:ietf:params:xml:ns:netconf:base:1.0)data.",
+                exception.getErrors().get(0).getErrorMessage());
+        assertEquals(3, countExceptions);
+    }
+
+    @Test
+    public void emptyDataReadTest() throws WebApplicationException,
+            IOException, NoSuchFieldException, SecurityException,
+            IllegalArgumentException, IllegalAccessException {
+
+        initialize("/json-to-nn/simple-list-yang/4", schemaContext);
+
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC(
+                "/json-to-nn/empty-data.json", "array-with-null-yang:cont");
+        assertNotNull(normalizedNodeContext);
+
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+
+        assertTrue(dataTree.contains("lflst1"));
+
+        assertTrue(dataTree.contains("lflst2 45"));
+
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        RestconfDocumentedException exception = null;
+        mockBodyReader("array-with-null-yang:cont", jsonBodyReader, false);
+        final InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/empty-data.json1");
+
+        try {
+            jsonBodyReader.readFrom(null, null, null, mediaType, null,
+                    inputStream);
+        } catch (final RestconfDocumentedException e) {
+            exception = e;
+        }
+        assertNotNull(exception);
+        assertEquals("Error parsing input: null", exception.getErrors().get(0)
+                .getErrorMessage());
+    }
+
+    @Test
+    public void testJsonBlankInput() throws NoSuchFieldException,
+            SecurityException, IllegalArgumentException,
+            IllegalAccessException, WebApplicationException, IOException {
+        initialize("/json-to-nn/simple-list-yang/4", schemaContext);
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC("",
+                "array-with-null-yang:cont");
+        assertNull(normalizedNodeContext);
+    }
+
+    @Test
+    public void notSupplyNamespaceIfAlreadySupplied()
+            throws WebApplicationException, IOException, NoSuchFieldException,
+            SecurityException, IllegalArgumentException, IllegalAccessException {
+
+        initialize("/json-to-nn/simple-list-yang/1", schemaContext);
+
+        final String uri = "simple-list-yang1" + ":" + "lst";
+
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC(
+                "/json-to-nn/simple-list.json", uri);
+        assertNotNull(normalizedNodeContext);
+
+        verifyNormaluizedNodeContext(normalizedNodeContext, "lst");
+
+        mockBodyReader("simple-list-yang2:lst", jsonBodyReader, false);
+        final InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/simple-list.json");
+
+        try {
+            jsonBodyReader.readFrom(null, null, null, mediaType, null,
+                    inputStream);
+            fail("NormalizedNodeContext should not be create because of different namespace");
+        } catch (final RestconfDocumentedException e) {
+        }
+
+        verifyNormaluizedNodeContext(normalizedNodeContext, "lst");
+    }
+
+    @Test
+    public void dataAugmentedTest() {
+
+        initialize("/common/augment/yang", schemaContext);
+
+        NormalizedNodeContext normalizedNodeContext = prepareNNC(
+                "/common/augment/json/dataa.json", "main:cont");
+
+        assertNotNull(normalizedNodeContext);
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+
+        String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("cont1"));
+        assertTrue(dataTree.contains("lf11 lf11 value from a"));
+
+        normalizedNodeContext = prepareNNC("/common/augment/json/datab.json",
+                "main:cont");
+
+        assertNotNull(normalizedNodeContext);
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+        dataTree = NormalizedNodes
+                .toStringTree(normalizedNodeContext.getData());
+        assertTrue(dataTree.contains("cont1"));
+        assertTrue(dataTree.contains("lf11 lf11 value from b"));
+    }
+
+    private void simpleTest(final String jsonPath, final String yangPath,
+            final String topLevelElementName, final String moduleName) {
+
+        initialize(yangPath, schemaContext);
+
+        final String uri = moduleName + ":" + topLevelElementName;
+
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC(jsonPath, uri);
+        assertNotNull(normalizedNodeContext);
+
+        verifyNormaluizedNodeContext(normalizedNodeContext, topLevelElementName);
+    }
+
+    private NormalizedNodeContext prepareNNC(final String jsonPath, final String uri) {
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        try {
+            mockBodyReader(uri, jsonBodyReader, false);
+        } catch (NoSuchFieldException | SecurityException
+                | IllegalArgumentException | IllegalAccessException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        final InputStream inputStream = this.getClass().getResourceAsStream(jsonPath);
+
+        NormalizedNodeContext normalizedNodeContext = null;
+
+        try {
+            normalizedNodeContext = jsonBodyReader.readFrom(null, null, null,
+                    mediaType, null, inputStream);
+        } catch (WebApplicationException | IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+
+        return normalizedNodeContext;
+    }
+
+    private void verifyNormaluizedNodeContext(
+            final NormalizedNodeContext normalizedNodeContext,
+            final String topLevelElementName) {
+        assertEquals(topLevelElementName, normalizedNodeContext.getData()
+                .getNodeType().getLocalName());
+
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("cont1"));
+        assertTrue(dataTree.contains("lst1"));
+        assertTrue(dataTree.contains("lflst1"));
+        assertTrue(dataTree.contains("lflst1_1"));
+        assertTrue(dataTree.contains("lflst1_2"));
+        assertTrue(dataTree.contains("lf1"));
+    }
+
+    private void verityMultipleItemsInList(
+            final NormalizedNodeContext normalizedNodeContext) {
+
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("lf11"));
+        assertTrue(dataTree.contains("lf11_1"));
+        assertTrue(dataTree.contains("lflst11"));
+        assertTrue(dataTree.contains("45"));
+        assertTrue(dataTree.contains("cont11"));
+        assertTrue(dataTree.contains("lst11"));
+    }
+
+    @Test
+    public void unsupportedDataFormatTest() throws NoSuchFieldException,
+            SecurityException, IllegalArgumentException,
+            IllegalAccessException, WebApplicationException, IOException {
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        initialize("/json-to-nn/simple-list-yang/1", schemaContext);
+        mockBodyReader("simple-list-yang1:lst", jsonBodyReader, false);
+
+        final InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/unsupported-json-format.json");
+
+        RestconfDocumentedException exception = null;
+
+        try {
+            jsonBodyReader.readFrom(null, null, null, mediaType, null,
+                    inputStream);
+        } catch (final RestconfDocumentedException e) {
+            exception = e;
+        }
+        System.out.println(exception.getErrors().get(0).getErrorMessage());
+
+        assertTrue(exception.getErrors().get(0).getErrorMessage()
+                .contains("is not a simple type"));
+    }
+
+    @Test
+    public void invalidUriCharacterInValue() throws NoSuchFieldException,
+            SecurityException, IllegalArgumentException,
+            IllegalAccessException, WebApplicationException, IOException {
+
+        jsonBodyReader = new JsonNormalizedNodeBodyReader();
+        initialize("/json-to-nn/simple-list-yang/4", schemaContext);
+        mockBodyReader("array-with-null-yang:cont", jsonBodyReader, false);
+
+        final InputStream inputStream = this.getClass().getResourceAsStream(
+                "/json-to-nn/invalid-uri-character-in-value.json");
+
+        final NormalizedNodeContext normalizedNodeContext = jsonBodyReader.readFrom(
+                null, null, null, mediaType, null, inputStream);
+        assertNotNull(normalizedNodeContext);
+
+        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
+                .getLocalName());
+
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
+                .getData());
+        assertTrue(dataTree.contains("lf1 module<Name:value lf1"));
+        assertTrue(dataTree.contains("lf2 module>Name:value lf2"));
+    }
+
+    @Override
+    protected MediaType getMediaType() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}