Bump upstreams for Silicon
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / jersey / providers / XmlBodyReaderMountPointTest.java
index 578bcd7e8c23bdf10e7fa6841e5580430deb907b..d8121fbe97f14a94a0735b167f9126d5ad8a9eda 100644 (file)
@@ -5,7 +5,6 @@
  * 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.restconf.nb.rfc8040.jersey.providers;
 
 import static org.junit.Assert.assertEquals;
@@ -16,11 +15,12 @@ import java.io.File;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.Collection;
+import java.util.Optional;
 import javax.ws.rs.core.MediaType;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.restconf.common.context.NormalizedNodeContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
@@ -37,12 +37,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
     private final XmlNormalizedNodeBodyReader xmlBodyReader;
-    private static SchemaContext schemaContext;
+    private static EffectiveModelContext schemaContext;
 
     private static final QNameModule INSTANCE_IDENTIFIER_MODULE_QNAME =  QNameModule.create(
         URI.create("instance:identifier:module"), Revision.of("2014-01-17"));
@@ -107,6 +107,20 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
         checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
     }
 
+    @Test
+    public void moduleSubContainerDataPostActionTest() throws Exception {
+        final Optional<DataSchemaNode> dataSchemaNode = schemaContext
+            .findDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
+        final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont/cont1/reset";
+        mockBodyReader(uri, this.xmlBodyReader, true);
+        final InputStream inputStream = XmlBodyReaderMountPointTest.class
+            .getResourceAsStream("/instanceidentifier/xml/xml_cont_action.xml");
+        final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null,
+            null, null, this.mediaType, null, inputStream);
+        checkMountPointNormalizedNodeContext(returnValue);
+        checkExpectValueNormalizeNodeContext(dataSchemaNode.get(), returnValue);
+    }
+
     @Test
     public void rpcModuleInputTest() throws Exception {
         final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test";
@@ -118,46 +132,38 @@ public class XmlBodyReaderMountPointTest extends AbstractBodyReaderTest {
         checkNormalizedNodeContext(returnValue);
         final ContainerNode contNode = (ContainerNode) returnValue.getData();
         final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getNodeType(), "cont"));
-        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode
+        final Optional<DataContainerChild<? extends PathArgument, ?>> contDataNodePotential = contNode
                 .getChild(yangCont.getLastPathArgument());
         assertTrue(contDataNodePotential.isPresent());
         final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get();
         final YangInstanceIdentifier yangLeaf =
                 YangInstanceIdentifier.of(QName.create(contDataNode.getNodeType(), "lf"));
-        final java.util.Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(
+        final Optional<DataContainerChild<? extends PathArgument, ?>> leafDataNode = contDataNode.getChild(
                 yangLeaf.getLastPathArgument());
         assertTrue(leafDataNode.isPresent());
         assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().getValue().toString()));
     }
 
-    private void checkExpectValueNormalizeNodeContext(
-            final DataSchemaNode dataSchemaNode,
+    private static void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext) {
         checkExpectValueNormalizeNodeContext(dataSchemaNode, nnContext, null);
     }
 
-    private void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
+    private static void checkExpectValueNormalizeNodeContext(final DataSchemaNode dataSchemaNode,
             final NormalizedNodeContext nnContext, final QName qualifiedName) {
-        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier
-                .of(dataSchemaNode.getQName());
-        final DOMMountPoint mountPoint = nnContext
-                .getInstanceIdentifierContext().getMountPoint();
-        final DataSchemaNode mountDataSchemaNode = mountPoint
-                .getSchemaContext().getDataChildByName(
-                        dataSchemaNode.getQName());
+        YangInstanceIdentifier dataNodeIdent = YangInstanceIdentifier.of(dataSchemaNode.getQName());
+        final DOMMountPoint mountPoint = nnContext.getInstanceIdentifierContext().getMountPoint();
+        final DataSchemaNode mountDataSchemaNode = modelContext(mountPoint)
+                .getDataChildByName(dataSchemaNode.getQName());
         assertNotNull(mountDataSchemaNode);
         if (qualifiedName != null && dataSchemaNode instanceof DataNodeContainer) {
-            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode)
-                    .getDataChildByName(qualifiedName);
-            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent)
-                    .node(child.getQName()).build();
-            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode()
-                    .equals(child));
+            final DataSchemaNode child = ((DataNodeContainer) dataSchemaNode).getDataChildByName(qualifiedName);
+            dataNodeIdent = YangInstanceIdentifier.builder(dataNodeIdent).node(child.getQName()).build();
+            assertTrue(nnContext.getInstanceIdentifierContext().getSchemaNode().equals(child));
         } else {
             assertTrue(mountDataSchemaNode.equals(dataSchemaNode));
         }
-        assertNotNull(NormalizedNodes.findNode(nnContext.getData(),
-                dataNodeIdent));
+        assertNotNull(NormalizedNodes.findNode(nnContext.getData(), dataNodeIdent));
     }
 
     /**