Peel of RPC invocation InstanceIdentifierContext 68/100268/3
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Mar 2022 18:35:11 +0000 (19:35 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Mar 2022 20:09:11 +0000 (21:09 +0100)
Here is a confusing site, which could ned up holding an
InstanceIdentifier, which is not valid. Peel it off.

JIRA: NETCONF-818
Change-Id: I2184afd2d5e750b60b471f7d5d009e038b4b7017
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/context/InstanceIdentifierContext.java
restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/impl/ControllerContext.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/AbstractBodyReaderTest.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReader.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestJsonBodyReaderMountPoint.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReader.java
restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/rest/impl/test/providers/TestXmlBodyReaderMountPoint.java

index 3c7ed16a9c8c05e51d8c32506f3e96bd4127a4ac..cd6139b1a564b262f004c4a1e2a5a35b8cad860b 100644 (file)
@@ -100,6 +100,11 @@ public final class InstanceIdentifierContext {
         return new InstanceIdentifierContext(mountContext, requireNonNull(mountPoint));
     }
 
+    public static @NonNull InstanceIdentifierContext ofMountPointRpc(final DOMMountPoint mountPoint,
+            final EffectiveModelContext mountContext, final RpcDefinition rpc) {
+        return new InstanceIdentifierContext(mountContext, rpc, requireNonNull(mountPoint));
+    }
+
     public static @NonNull InstanceIdentifierContext ofMountPointRpcOutput(final DOMMountPoint mountPoint,
             final EffectiveModelContext mountContext, final RpcDefinition rpc) {
         return new InstanceIdentifierContext(mountContext, rpc, requireNonNull(mountPoint));
@@ -107,7 +112,7 @@ public final class InstanceIdentifierContext {
 
     // FIXME: what the heck are the callers of this doing?!
     public @NonNull InstanceIdentifierContext withConcatenatedArgs(final List<PathArgument> concatArgs) {
-        if (concatArgs.isEmpty()) {
+        if (instanceIdentifier == null || concatArgs.isEmpty()) {
             return this;
         }
         final var newInstanceIdentifier = YangInstanceIdentifier.create(
index 6c338cc1c03a33b0934b1fbac137b110279d981f..1a34ef7bd507521f95dd90503d3d3d1b632f4c1b 100644 (file)
@@ -631,8 +631,8 @@ public final class ControllerContext implements EffectiveModelContextListener, C
                     rpc = getRpcDefinition(module, rpcName);
                 }
                 if (rpc != null) {
-                    return new InstanceIdentifierContext(builder.build(), rpc, mountPoint,
-                            mountPoint != null ? getModelContext(mountPoint) : globalSchema);
+                    return mountPoint == null ? InstanceIdentifierContext.ofLocalRpc(globalSchema, rpc)
+                        : InstanceIdentifierContext.ofMountPointRpc(mountPoint, getModelContext(mountPoint), rpc);
                 }
             }
 
index 424ac4497f9de42a7b666a582ca55f27e1609513..5bbd161130db7938c58e3a90bff0d800ec67f7f6 100644 (file)
@@ -8,12 +8,13 @@
 package org.opendaylight.controller.sal.rest.impl.test.providers;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.lang.reflect.Field;
 import java.net.URI;
-import java.util.Collections;
+import java.util.List;
 import java.util.Optional;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedHashMap;
@@ -49,7 +50,7 @@ public abstract class AbstractBodyReaderTest {
     protected final MediaType mediaType;
 
     protected AbstractBodyReaderTest(final EffectiveModelContext schemaContext, final DOMMountPoint mountInstance) {
-        this.mediaType = getMediaType();
+        mediaType = getMediaType();
 
         controllerContext = TestRestconfUtils.newControllerContext(schemaContext, mountInstance);
     }
@@ -67,7 +68,7 @@ public abstract class AbstractBodyReaderTest {
         final MultivaluedMap<String, String> pathParm = new MultivaluedHashMap<>(1);
 
         if (!identifier.isEmpty()) {
-            pathParm.put(RestconfConstants.IDENTIFIER, Collections.singletonList(identifier));
+            pathParm.put(RestconfConstants.IDENTIFIER, List.of(identifier));
         }
 
         when(uriInfoMock.getPathParameters()).thenReturn(pathParm);
@@ -86,20 +87,25 @@ public abstract class AbstractBodyReaderTest {
         requestField.set(normalizedNodeProvider, request);
     }
 
-    protected static void checkMountPointNormalizedNodeContext(
-            final NormalizedNodeContext nnContext) {
+    protected static void checkMountPointNormalizedNodeContext(final NormalizedNodeContext nnContext) {
         checkNormalizedNodeContext(nnContext);
         assertNotNull(nnContext.getInstanceIdentifierContext().getMountPoint());
     }
 
-    protected static void checkNormalizedNodeContext(
-            final NormalizedNodeContext nnContext) {
+    protected static void checkNormalizedNodeContext(final NormalizedNodeContext nnContext) {
         assertNotNull(nnContext.getData());
         assertNotNull(nnContext.getInstanceIdentifierContext().getInstanceIdentifier());
         assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaContext());
         assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaNode());
     }
 
+    protected static void checkNormalizedNodeContextRpc(final NormalizedNodeContext nnContext) {
+        assertNotNull(nnContext.getData());
+        assertNull(nnContext.getInstanceIdentifierContext().getInstanceIdentifier());
+        assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaContext());
+        assertNotNull(nnContext.getInstanceIdentifierContext().getSchemaNode());
+    }
+
     protected static void checkPatchContext(final PatchContext patchContext) {
         assertNotNull(patchContext.getData());
         assertNotNull(patchContext.getInstanceIdentifierContext().getInstanceIdentifier());
index 9d3ab2499b2a54ebc21cabcaeeb3b86dd3be3b47..fe50c687e7fc3e8d3c1559cdb2d3f8e85b503ce7 100644 (file)
@@ -12,11 +12,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.collect.Sets;
 import java.io.File;
 import java.io.InputStream;
 import java.util.Collection;
 import java.util.Optional;
+import java.util.Set;
 import javax.ws.rs.core.MediaType;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -28,6 +28,7 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
@@ -47,7 +48,7 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
 
     public TestJsonBodyReader() {
         super(schemaContext, null);
-        this.jsonBodyReader = new JsonNormalizedNodeBodyReader(controllerContext);
+        jsonBodyReader = new JsonNormalizedNodeBodyReader(controllerContext);
     }
 
     @Override
@@ -69,11 +70,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName());
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.jsonBodyReader, false);
+        mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/jsondata.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -86,11 +87,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final DataSchemaNode dataSchemaNodeOnPath = ((DataNodeContainer) dataSchemaNode).getDataChildByName(cont1QName);
         final String uri = "instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, this.jsonBodyReader, false);
+        mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNodeOnPath, returnValue, dataII);
     }
@@ -102,11 +103,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1");
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.jsonBodyReader, true);
+        mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -117,16 +118,15 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final Module augmentModule = schemaContext.findModules(XMLNamespace.of("augment:module")).iterator().next();
         final QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment");
-        final YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier(
-                Sets.newHashSet(contAugmentQName));
+        final AugmentationIdentifier augII = new AugmentationIdentifier(Set.of(contAugmentQName));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName())
                 .node(augII).node(contAugmentQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.jsonBodyReader, true);
+        mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_augment_container.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -140,19 +140,17 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
         final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
         final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
         final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
-        final YangInstanceIdentifier.AugmentationIdentifier augChoice1II =
-                new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName));
-        final YangInstanceIdentifier.AugmentationIdentifier augChoice2II =
-                new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName));
+        final AugmentationIdentifier augChoice1II = new AugmentationIdentifier(Set.of(augmentChoice1QName));
+        final AugmentationIdentifier augChoice2II = new AugmentationIdentifier(Set.of(augmentChoice2QName));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName())
                 .node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName)
                 .node(containerQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.jsonBodyReader, true);
+        mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/json/json_augment_choice_container.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -160,12 +158,11 @@ public class TestJsonBodyReader extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, this.jsonBodyReader, true);
-        final InputStream inputStream = TestJsonBodyReader.class
-                .getResourceAsStream("/invoke-rpc/json/rpc-input.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
-        checkNormalizedNodeContext(returnValue);
+        mockBodyReader(uri, jsonBodyReader, true);
+        final InputStream inputStream = TestJsonBodyReader.class.getResourceAsStream("/invoke-rpc/json/rpc-input.json");
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, null, null, mediaType, null,
+            inputStream);
+        checkNormalizedNodeContextRpc(returnValue);
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(
             QName.create(inputNode.getIdentifier().getNodeType(), "cont"));
index 544e6c044065e39de891811043311d439cafb4e0..e8776c87da5518bdf0692211ec7f47f0418a2e2a 100644 (file)
@@ -45,7 +45,7 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
 
     public TestJsonBodyReaderMountPoint() throws NoSuchFieldException, SecurityException {
         super(schemaContext, mock(DOMMountPoint.class));
-        this.jsonBodyReader = new JsonNormalizedNodeBodyReader(controllerContext);
+        jsonBodyReader = new JsonNormalizedNodeBodyReader(controllerContext);
     }
 
     @Override
@@ -65,11 +65,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, this.jsonBodyReader, false);
+        mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/jsondata.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -79,11 +79,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, this.jsonBodyReader, false);
+        mockBodyReader(uri, jsonBodyReader, false);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
                 QName.create(dataSchemaNode.getQName(), "cont1"));
@@ -94,11 +94,11 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, this.jsonBodyReader, true);
+        mockBodyReader(uri, jsonBodyReader, true);
         final InputStream inputStream = TestJsonBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/json/json_sub_container.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -106,12 +106,12 @@ public class TestJsonBodyReaderMountPoint extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, this.jsonBodyReader, true);
-        final InputStream inputStream = TestJsonBodyReaderMountPoint.class
-                .getResourceAsStream("/invoke-rpc/json/rpc-input.json");
-        final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
-        checkNormalizedNodeContext(returnValue);
+        mockBodyReader(uri, jsonBodyReader, true);
+        final InputStream inputStream = TestJsonBodyReaderMountPoint.class.getResourceAsStream(
+            "/invoke-rpc/json/rpc-input.json");
+        final NormalizedNodeContext returnValue = jsonBodyReader.readFrom(null, null, null, mediaType, null,
+            inputStream);
+        checkNormalizedNodeContextRpc(returnValue);
         final ContainerNode inputNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(
                 QName.create(inputNode.getIdentifier().getNodeType(), "cont"));
index 4cbe8e5b3df8b36a4d15e5e09a9500ee7f30fd30..4bd80de74e2a2b202d96fb6faf581064e07b1377 100644 (file)
@@ -12,11 +12,11 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.google.common.collect.Sets;
 import java.io.File;
 import java.io.InputStream;
 import java.util.Collection;
 import java.util.Optional;
+import java.util.Set;
 import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -33,6 +33,7 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
@@ -53,7 +54,7 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
 
     public TestXmlBodyReader() {
         super(schemaContext, null);
-        this.xmlBodyReader = new XmlNormalizedNodeBodyReader(controllerContext);
+        xmlBodyReader = new XmlNormalizedNodeBodyReader(controllerContext);
     }
 
     @Override
@@ -109,11 +110,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName());
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.xmlBodyReader, false);
+        mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -126,11 +127,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final DataSchemaNode dataSchemaNodeOnPath = ((DataNodeContainer) dataSchemaNode).getDataChildByName(cont1QName);
         final String uri = "instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, this.xmlBodyReader, false);
+        mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNodeOnPath, returnValue, dataII);
     }
@@ -142,11 +143,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final QName cont1QName = QName.create(dataSchemaNode.getQName(), "cont1");
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName()).node(cont1QName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.xmlBodyReader, true);
+        mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -157,16 +158,15 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
                 schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final Module augmentModule = schemaContext.findModules(XMLNamespace.of("augment:module")).iterator().next();
         final QName contAugmentQName = QName.create(augmentModule.getQNameModule(), "cont-augment");
-        final YangInstanceIdentifier.AugmentationIdentifier augII = new YangInstanceIdentifier.AugmentationIdentifier(
-                Sets.newHashSet(contAugmentQName));
+        final AugmentationIdentifier augII = new AugmentationIdentifier(Set.of(contAugmentQName));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName())
                 .node(augII).node(contAugmentQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.xmlBodyReader, true);
+        mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_augment_container.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -179,19 +179,17 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
         final QName augmentChoice1QName = QName.create(augmentModule.getQNameModule(), "augment-choice1");
         final QName augmentChoice2QName = QName.create(augmentChoice1QName, "augment-choice2");
         final QName containerQName = QName.create(augmentChoice1QName, "case-choice-case-container1");
-        final YangInstanceIdentifier.AugmentationIdentifier augChoice1II =
-                new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice1QName));
-        final YangInstanceIdentifier.AugmentationIdentifier augChoice2II =
-                new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(augmentChoice2QName));
+        final AugmentationIdentifier augChoice1II = new AugmentationIdentifier(Set.of(augmentChoice1QName));
+        final AugmentationIdentifier augChoice2II = new AugmentationIdentifier(Set.of(augmentChoice2QName));
         final YangInstanceIdentifier dataII = YangInstanceIdentifier.of(dataSchemaNode.getQName())
                 .node(augChoice1II).node(augmentChoice1QName).node(augChoice2II).node(augmentChoice2QName)
                 .node(containerQName);
         final String uri = "instance-identifier-module:cont";
-        mockBodyReader(uri, this.xmlBodyReader, true);
+        mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_augment_choice_container.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
         checkNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue, dataII);
     }
@@ -199,11 +197,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, this.xmlBodyReader, true);
+        mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null,
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null, null, null, mediaType, null,
             inputStream);
-        checkNormalizedNodeContext(returnValue);
+        checkNormalizedNodeContextRpc(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final Optional<DataContainerChild> contDataNodePotential = contNode.findChildByArg(new NodeIdentifier(
             QName.create(contNode.getIdentifier().getNodeType(), "cont")));
@@ -229,11 +227,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
      */
     @Test
     public void findFooContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("", this.xmlBodyReader, true);
+        mockBodyReader("", xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindFooContainer.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
 
         // check return value
         checkNormalizedNodeContext(returnValue);
@@ -251,11 +249,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
      */
     @Test
     public void findBarContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("", this.xmlBodyReader, true);
+        mockBodyReader("", xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindBarContainer.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
 
         // check return value
         checkNormalizedNodeContext(returnValue);
@@ -273,11 +271,11 @@ public class TestXmlBodyReader extends AbstractBodyReaderTest {
      */
     @Test
     public void wrongRootElementTest() throws Exception {
-        mockBodyReader("instance-identifier-module:cont", this.xmlBodyReader, false);
+        mockBodyReader("instance-identifier-module:cont", xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream(
                 "/instanceidentifier/xml/bug7933.xml");
         try {
-            this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
+            xmlBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
             Assert.fail("Test should fail due to malformed PUT operation message");
         } catch (final RestconfDocumentedException exception) {
             final RestconfError restconfError = exception.getErrors().get(0);
index 7433e6d96a321fb8bed131599a07a68c1af2dcc8..fe257dbd04e938d239c672f7272ae81b8ae5b8cc 100644 (file)
@@ -50,7 +50,7 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
 
     public TestXmlBodyReaderMountPoint() {
         super(schemaContext, mock(DOMMountPoint.class));
-        this.xmlBodyReader = new XmlNormalizedNodeBodyReader(controllerContext);
+        xmlBodyReader = new XmlNormalizedNodeBodyReader(controllerContext);
     }
 
     @Override
@@ -70,11 +70,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, this.xmlBodyReader, false);
+        mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -84,11 +84,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1";
-        mockBodyReader(uri, this.xmlBodyReader, false);
+        mockBodyReader(uri, xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue,
                 QName.create(dataSchemaNode.getQName(), "cont1"));
@@ -99,11 +99,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
         final DataSchemaNode dataSchemaNode = schemaContext
                 .getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
         final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
-        mockBodyReader(uri, this.xmlBodyReader, true);
+        mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/instanceidentifier/xml/xml_sub_container.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
         checkMountPointNormalizedNodeContext(returnValue);
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
@@ -111,12 +111,12 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test";
-        mockBodyReader(uri, this.xmlBodyReader, true);
+        mockBodyReader(uri, xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReaderMountPoint.class
                 .getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
-                null, null, this.mediaType, null, inputStream);
-        checkNormalizedNodeContext(returnValue);
+        final NormalizedNodeContext returnValue = xmlBodyReader.readFrom(null,
+                null, null, mediaType, null, inputStream);
+        checkNormalizedNodeContextRpc(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(
                 QName.create(contNode.getIdentifier().getNodeType(), "cont"));
@@ -161,11 +161,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
      */
     @Test
     public void findFooContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, true);
+        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindFooContainer.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
 
         // check return value
         checkMountPointNormalizedNodeContext(returnValue);
@@ -183,11 +183,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
      */
     @Test
     public void findBarContainerUsingNamespaceTest() throws Exception {
-        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, true);
+        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", xmlBodyReader, true);
         final InputStream inputStream = TestXmlBodyReader.class
                 .getResourceAsStream("/instanceidentifier/xml/xmlDataFindBarContainer.xml");
-        final NormalizedNodeContext returnValue = this.xmlBodyReader
-                .readFrom(null, null, null, this.mediaType, null, inputStream);
+        final NormalizedNodeContext returnValue = xmlBodyReader
+                .readFrom(null, null, null, mediaType, null, inputStream);
 
         // check return value
         checkMountPointNormalizedNodeContext(returnValue);
@@ -205,11 +205,11 @@ public class TestXmlBodyReaderMountPoint extends AbstractBodyReaderTest {
      */
     @Test
     public void wrongRootElementTest() throws Exception {
-        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", this.xmlBodyReader, false);
+        mockBodyReader("instance-identifier-module:cont/yang-ext:mount", xmlBodyReader, false);
         final InputStream inputStream = TestXmlBodyReader.class.getResourceAsStream(
                 "/instanceidentifier/xml/bug7933.xml");
         try {
-            this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
+            xmlBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
             Assert.fail("Test should fail due to malformed PUT operation message");
         } catch (final RestconfDocumentedException exception) {
             final RestconfError restconfError = exception.getErrors().get(0);