* 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;
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;
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"));
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";
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));
}
/**