Bump MRI upstreams
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / restconf / impl / json / to / nn / test / JsonToNnTest.java
index 0bd9a62ed369ae301a2c9fce1e055c126fd780bf..2be1f284175af66a888daaadbe97fc3c198f0a15 100644 (file)
@@ -87,8 +87,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
                 "multiple-items-yang:lst");
         assertNotNull(normalizedNodeContext);
 
-        assertEquals("lst", normalizedNodeContext.getData().getNodeType()
-                .getLocalName());
+        assertEquals("lst", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
 
         verityMultipleItemsInList(normalizedNodeContext);
     }
@@ -99,11 +98,9 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
                 "/json-to-nn/array-with-null.json", "array-with-null-yang:cont");
         assertNotNull(normalizedNodeContext);
 
-        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
-                .getLocalName());
+        assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
 
-        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
-                .getData());
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
         assertTrue(dataTree.contains("lf"));
         assertTrue(dataTree.contains("empty"));
     }
@@ -171,11 +168,9 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
                 "/json-to-nn/empty-data.json", "array-with-null-yang:cont");
         assertNotNull(normalizedNodeContext);
 
-        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
-                .getLocalName());
+        assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
 
-        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
-                .getData());
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
 
         assertTrue(dataTree.contains("lflst1"));
 
@@ -183,24 +178,20 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
 
         RestconfDocumentedException exception = null;
         mockBodyReader("array-with-null-yang:cont", this.jsonBodyReader, false);
-        final InputStream inputStream = this.getClass().getResourceAsStream(
-                "/json-to-nn/empty-data.json1");
+        final InputStream inputStream = this.getClass().getResourceAsStream("/json-to-nn/empty-data.json1");
 
         try {
-            this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,
-                    inputStream);
+            this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,inputStream);
         } catch (final RestconfDocumentedException e) {
             exception = e;
         }
         assertNotNull(exception);
-        assertEquals("Error parsing input: null", exception.getErrors().get(0)
-                .getErrorMessage());
+        assertEquals("Error parsing input: null", exception.getErrors().get(0).getErrorMessage());
     }
 
     @Test
     public void testJsonBlankInput() throws Exception {
-        final NormalizedNodeContext normalizedNodeContext = prepareNNC("",
-                "array-with-null-yang:cont");
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC("", "array-with-null-yang:cont");
         assertNull(normalizedNodeContext);
     }
 
@@ -208,19 +199,16 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
     public void notSupplyNamespaceIfAlreadySupplied()throws Exception {
         final String uri = "simple-list-yang1" + ":" + "lst";
 
-        final NormalizedNodeContext normalizedNodeContext = prepareNNC(
-                "/json-to-nn/simple-list.json", uri);
+        final NormalizedNodeContext normalizedNodeContext = prepareNNC("/json-to-nn/simple-list.json", uri);
         assertNotNull(normalizedNodeContext);
 
         verifyNormaluizedNodeContext(normalizedNodeContext, "lst");
 
         mockBodyReader("simple-list-yang2:lst", this.jsonBodyReader, false);
-        final InputStream inputStream = this.getClass().getResourceAsStream(
-                "/json-to-nn/simple-list.json");
+        final InputStream inputStream = this.getClass().getResourceAsStream("/json-to-nn/simple-list.json");
 
         try {
-            this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,
-                    inputStream);
+            this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
             fail("NormalizedNodeContext should not be create because of different namespace");
         } catch (final RestconfDocumentedException e) {
             LOG.warn("Read from InputStream failed. Message: {}. Status: {}", e.getMessage(), e.getStatus());
@@ -231,26 +219,21 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
 
     @Test
     public void dataAugmentedTest() throws Exception {
-        NormalizedNodeContext normalizedNodeContext = prepareNNC(
-                "/common/augment/json/dataa.json", "main:cont");
+        NormalizedNodeContext normalizedNodeContext = prepareNNC("/common/augment/json/dataa.json", "main:cont");
 
         assertNotNull(normalizedNodeContext);
-        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
-                .getLocalName());
+        assertEquals("cont", normalizedNodeContext.getData().getIdentifier().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");
+        normalizedNodeContext = prepareNNC("/common/augment/json/datab.json", "main:cont");
 
         assertNotNull(normalizedNodeContext);
-        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
-                .getLocalName());
-        dataTree = NormalizedNodes
-                .toStringTree(normalizedNodeContext.getData());
+        assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
+        dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
         assertTrue(dataTree.contains("cont1"));
         assertTrue(dataTree.contains("lf11 lf11 value from b"));
     }
@@ -268,8 +251,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
     private NormalizedNodeContext prepareNNC(final String jsonPath, final String uri) throws Exception {
         try {
             mockBodyReader(uri, this.jsonBodyReader, false);
-        } catch (NoSuchFieldException | SecurityException
-                | IllegalArgumentException | IllegalAccessException e) {
+        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
             LOG.warn("Operation failed due to: {}", e.getMessage());
         }
         final InputStream inputStream = this.getClass().getResourceAsStream(jsonPath);
@@ -277,8 +259,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
         NormalizedNodeContext normalizedNodeContext = null;
 
         try {
-            normalizedNodeContext = this.jsonBodyReader.readFrom(null, null, null,
-                    this.mediaType, null, inputStream);
+            normalizedNodeContext = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
         } catch (WebApplicationException e) {
             // TODO Auto-generated catch block
         }
@@ -288,11 +269,9 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
 
     private static void verifyNormaluizedNodeContext(final NormalizedNodeContext normalizedNodeContext,
             final String topLevelElementName) {
-        assertEquals(topLevelElementName, normalizedNodeContext.getData()
-                .getNodeType().getLocalName());
+        assertEquals(topLevelElementName, normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
 
-        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
-                .getData());
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
         assertTrue(dataTree.contains("cont1"));
         assertTrue(dataTree.contains("lst1"));
         assertTrue(dataTree.contains("lflst1"));
@@ -302,9 +281,7 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
     }
 
     private static void verityMultipleItemsInList(final NormalizedNodeContext normalizedNodeContext) {
-
-        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
-                .getData());
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
         assertTrue(dataTree.contains("lf11"));
         assertTrue(dataTree.contains("lf11_1"));
         assertTrue(dataTree.contains("lflst11"));
@@ -317,21 +294,18 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
     public void unsupportedDataFormatTest() throws Exception {
         mockBodyReader("simple-list-yang1:lst", this.jsonBodyReader, false);
 
-        final InputStream inputStream = this.getClass().getResourceAsStream(
-                "/json-to-nn/unsupported-json-format.json");
+        final InputStream inputStream = this.getClass().getResourceAsStream("/json-to-nn/unsupported-json-format.json");
 
         RestconfDocumentedException exception = null;
 
         try {
-            this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,
-                    inputStream);
+            this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
         } catch (final RestconfDocumentedException e) {
             exception = e;
         }
         LOG.info(exception.getErrors().get(0).getErrorMessage());
 
-        assertTrue(exception.getErrors().get(0).getErrorMessage()
-                .contains("is not a simple type"));
+        assertTrue(exception.getErrors().get(0).getErrorMessage().contains("is not a simple type"));
     }
 
     @Test
@@ -345,11 +319,9 @@ public class JsonToNnTest extends AbstractBodyReaderTest {
                 null, null, null, this.mediaType, null, inputStream);
         assertNotNull(normalizedNodeContext);
 
-        assertEquals("cont", normalizedNodeContext.getData().getNodeType()
-                .getLocalName());
+        assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
 
-        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
-                .getData());
+        final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
         assertTrue(dataTree.contains("lf1 module<Name:value lf1"));
         assertTrue(dataTree.contains("lf2 module>Name:value lf2"));
     }