BUG-2801: Added filtering for get and getConfig in netconf mdsal northbound. 83/16483/7
authorTomas Cere <tcere@cisco.com>
Mon, 9 Mar 2015 15:26:39 +0000 (16:26 +0100)
committerTomas Cere <tcere@cisco.com>
Fri, 20 Mar 2015 15:00:06 +0000 (16:00 +0100)
Change-Id: I37db2b21712c7b3d16c6b9dafa193a3fb9df4430
Signed-off-by: Tomas Cere <tcere@cisco.com>
47 files changed:
features/mdsal/src/main/resources/features.xml
opendaylight/netconf/mdsal-netconf-connector/pom.xml
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/Get.java
opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/GetConfig.java
opendaylight/netconf/mdsal-netconf-connector/src/test/java/org/opendaylight/controller/netconf/mdsal/connector/ops/NetconfMDSalMappingTest.java
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig-filtering-setup.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig-filtering-setup2.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_create.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_create.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_delete-root.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_delete-root.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_delete-top.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_missing_default-operation_1.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_missing_default-operation_1.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_missing_default-operation_2.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_missing_default-operation_2.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_missing_default-operation_control.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_missing_default-operation_control.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_1.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_1.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_2.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_2.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_3.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_3.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_4_replace.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_4_replace.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_after_more_complex_merge.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_after_more_complex_merge.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_after_more_complex_merge_2.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_after_more_complex_merge_2.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_after_replace.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_after_replace.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_control_1.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_control_1.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_multiple_control_2.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_multiple_control_2.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_n1.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_n1.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_n1_control.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_n1_control.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_merge_single_1.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_merge_single_1.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_remove-root.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_remove-root.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_replace_default.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_replace_default.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_replace_default_control.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_replace_default_control.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_running.xml [moved from opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfig_running.xml with 100% similarity]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-empty-filter.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-alluser.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case-inner-case.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case-inner-choice.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-string.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-company-info.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-modules-and-admin.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-only-names-types.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-specific-module-type-and-user.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-superuser.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-users.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-case-inner-choice.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-case.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-string.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/get-empty-response.xml [new file with mode: 0644]
opendaylight/netconf/mdsal-netconf-connector/src/test/resources/yang/mdsal-netconf-mapping-test.yang

index fb368abf2c6f5197ff3d7f6adb3db886a0973636..021ed1d5689a20d9fe1180b9b6e3fe9fb4e447c9 100644 (file)
     </feature>
 
     <!-- TODO move to netconf features, however there are some weird dependencies on features-config-persister all over that cause cyclic dependencies-->
-    <!-- TODO when installing this in pure karaf distro, many optimistic lock exceptions are thrown from config manager -->
     <feature name='odl-netconf-mdsal' version='${project.version}' description="OpenDaylight :: Netconf :: Mdsal">
         <feature version='${config.version}'>odl-config-all</feature>
         <feature version='${netconf.version}'>odl-netconf-all</feature>
+        <!-- TODO remove dependency on sal netconf connector (odl-yangtools-models, sal-netconf-connector, model-inventory-->
+        <feature version='${yangtools.version}'>odl-yangtools-models</feature>
+        <bundle>mvn:org.opendaylight.controller/sal-netconf-connector/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.controller.model/model-inventory/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.controller/netconf-ssh/${netconf.version}</bundle>
         <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
         <bundle>mvn:org.opendaylight.controller/mdsal-netconf-connector/${netconf.version}</bundle>
index 809e729752fc38aab7014c224c1d3d372ab82878..878c37846bcb4e9d828b40aaa37ed8cc35a532cd 100644 (file)
           <artifactId>xmlunit</artifactId>
           <scope>test</scope>
       </dependency>
+      <dependency>
+          <!--TODO remove this dependency on sal-netconf-connector - move InstanceIdToNodes to netconf-util,
+          remove odl-yangtools-models, sal-netconf-connector, model-inventory dependency from the odl-netconf-mdsal feature in mdsal features with this-->
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>sal-netconf-connector</artifactId>
+      </dependency>
 
   </dependencies>
 
index 4253591fee011c57c0fc49d8b7f7a0796836b081..711cb8145b7d0ba110e552ca5a106658aa835747 100644 (file)
@@ -8,41 +8,62 @@
 
 package org.opendaylight.controller.netconf.mdsal.connector.ops.get;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Throwables;
 import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
 import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Collections;
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.dom.DOMResult;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.controller.netconf.mdsal.connector.ops.Datastore;
 import org.opendaylight.controller.netconf.util.mapping.AbstractLastNetconfOperation;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.sal.connect.netconf.util.InstanceIdToNodes;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 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.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.data.impl.codec.xml.XMLStreamNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.DomUtils;
+import org.opendaylight.yangtools.yang.data.impl.schema.transform.dom.parser.DomToNormalizedNodeParserFactory;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 public abstract class AbstractGet extends AbstractLastNetconfOperation {
 
-    protected static final YangInstanceIdentifier ROOT = YangInstanceIdentifier.builder().build();
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractGet.class);
 
+    protected static final String FILTER = "filter";
+    static final YangInstanceIdentifier ROOT = YangInstanceIdentifier.builder().build();
     protected final CurrentSchemaContext schemaContext;
 
-
     public AbstractGet(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext) {
         super(netconfSessionIdForReporting);
         this.schemaContext = schemaContext;
@@ -70,6 +91,7 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation {
         return result.getNode();
     }
 
+
     private XMLStreamWriter getXmlStreamWriter(final DOMResult result) {
         try {
             return XML_OUTPUT_FACTORY.createXMLStreamWriter(result);
@@ -92,8 +114,12 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation {
     // TODO this code is located in Restconf already
     private void writeRootElement(final XMLStreamWriter xmlWriter, final NormalizedNodeWriter nnWriter, final ContainerNode data) {
         try {
-            for (final DataContainerChild<? extends PathArgument, ?> child : data.getValue()) {
-                nnWriter.write(child);
+            if (data.getNodeType().equals(SchemaContext.NAME)) {
+                for (final DataContainerChild<? extends PathArgument, ?> child : data.getValue()) {
+                    nnWriter.write(child);
+                }
+            } else {
+                nnWriter.write(data);
             }
             nnWriter.flush();
             xmlWriter.flush();
@@ -102,9 +128,100 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation {
         }
     }
 
+    private DataSchemaNode getSchemaNodeFromNamespace(final XmlElement element) throws NetconfDocumentedException {
+
+        try {
+            final Module module = schemaContext.getCurrentContext().findModuleByNamespaceAndRevision(new URI(element.getNamespace()), null);
+            DataSchemaNode dataSchemaNode = module.getDataChildByName(element.getName());
+            if (dataSchemaNode != null) {
+                return dataSchemaNode;
+            }
+        } catch (URISyntaxException e) {
+            LOG.debug("Error during parsing of element namespace, this should not happen since namespace of an xml " +
+                    "element is valid and if the xml was parsed then the URI should be as well");
+            throw new IllegalArgumentException("Unable to parse element namespace, this should not happen since " +
+                    "namespace of an xml element is valid and if the xml was parsed then the URI should be as well");
+        }
+        throw new NetconfDocumentedException("Unable to find node with namespace: " + element.getNamespace() + "in schema context: " + schemaContext.getCurrentContext().toString(),
+                ErrorType.application,
+                ErrorTag.unknown_namespace,
+                ErrorSeverity.error);
+    }
+
+    protected Element serializeNodeWithParentStructure(Document document, YangInstanceIdentifier dataRoot, NormalizedNode node) {
+        if (!dataRoot.equals(ROOT)) {
+            return (Element) transformNormalizedNode(document,
+                    InstanceIdToNodes.serialize(schemaContext.getCurrentContext(), dataRoot, node),
+                    ROOT);
+        }
+        return  (Element) transformNormalizedNode(document, node, ROOT);
+    }
+
+    /**
+     *
+     * @param operationElement operation element
+     * @return if Filter is present and not empty returns Optional of the InstanceIdentifier to the read location in datastore.
+     *          empty filter returns Optional.absent() which should equal an empty <data/> container in the response.
+     *         if filter is not present we want to read the entire datastore - return ROOT.
+     * @throws NetconfDocumentedException
+     */
+    protected Optional<YangInstanceIdentifier> getDataRootFromFilter(XmlElement operationElement) throws NetconfDocumentedException {
+        Optional<XmlElement> filterElement = operationElement.getOnlyChildElementOptionally(FILTER);
+        if (filterElement.isPresent()) {
+            if (filterElement.get().getChildElements().size() == 0) {
+                return Optional.absent();
+            }
+            return Optional.of(getInstanceIdentifierFromFilter(filterElement.get()));
+        } else {
+            return Optional.of(ROOT);
+        }
+    }
+
+    @VisibleForTesting
+    protected YangInstanceIdentifier getInstanceIdentifierFromFilter(XmlElement filterElement) throws NetconfDocumentedException {
+
+        if (filterElement.getChildElements().size() != 1) {
+            throw new NetconfDocumentedException("Multiple filter roots not supported yet",
+                    ErrorType.application, ErrorTag.operation_not_supported, ErrorSeverity.error);
+        }
+
+        XmlElement element = filterElement.getOnlyChildElement();
+        DataSchemaNode schemaNode = getSchemaNodeFromNamespace(element);
+
+        return getReadPointFromNode(YangInstanceIdentifier.builder().build(), filterToNormalizedNode(element, schemaNode));
+    }
+
+    private YangInstanceIdentifier getReadPointFromNode(final YangInstanceIdentifier pathArg, final NormalizedNode nNode) {
+        final YangInstanceIdentifier path = pathArg.node(nNode.getIdentifier());
+        if (nNode instanceof DataContainerNode) {
+            DataContainerNode node = (DataContainerNode) nNode;
+            if (node.getValue().size() == 1) {
+                return getReadPointFromNode(path, (NormalizedNode) Lists.newArrayList(node.getValue()).get(0));
+            }
+        }
+        return path;
+    }
+
+    private NormalizedNode filterToNormalizedNode(XmlElement element, DataSchemaNode schemaNode) throws NetconfDocumentedException {
+        DomToNormalizedNodeParserFactory parserFactory = DomToNormalizedNodeParserFactory
+                .getInstance(DomUtils.defaultValueCodecProvider(), schemaContext.getCurrentContext());
+
+        final NormalizedNode parsedNode;
+
+        if (schemaNode instanceof ContainerSchemaNode) {
+            parsedNode = parserFactory.getContainerNodeParser().parse(Collections.singletonList(element.getDomElement()), (ContainerSchemaNode) schemaNode);
+        } else if (schemaNode instanceof ListSchemaNode) {
+            parsedNode = parserFactory.getMapNodeParser().parse(Collections.singletonList(element.getDomElement()), (ListSchemaNode) schemaNode);
+        } else {
+            throw new NetconfDocumentedException("Schema node of the top level element is not an instance of container or list",
+                    ErrorType.application, ErrorTag.unknown_element, ErrorSeverity.error);
+        }
+        return parsedNode;
+    }
+
     protected static final class GetConfigExecution {
-        private final Optional<Datastore> datastore;
 
+        private final Optional<Datastore> datastore;
         public GetConfigExecution(final Optional<Datastore> datastore) {
             this.datastore = datastore;
         }
@@ -127,8 +244,6 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation {
                 throw new NetconfDocumentedException("Get-config source attribute error: " + e.getMessage(), e.getErrorType(), e.getErrorTag(), e.getErrorSeverity(), e.getErrorInfo());
             }
 
-            // Add filter
-
             return new GetConfigExecution(sourceDatastore);
         }
 
@@ -144,6 +259,7 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation {
             xml.checkName(operationName);
             xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
         }
+
     }
 
 }
index b62734baf09267702c1548f74716bc6c5d3a1cc2..1daccd265cc2c094d1617df94a2b1e1951e3508f 100644 (file)
@@ -16,10 +16,12 @@ import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.controller.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.controller.netconf.mdsal.connector.ops.Datastore;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.slf4j.Logger;
@@ -32,7 +34,6 @@ public class Get extends AbstractGet {
     private static final Logger LOG = LoggerFactory.getLogger(Get.class);
 
     private static final String OPERATION_NAME = "get";
-
     private final TransactionProvider transactionProvider;
 
     public Get(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext, final TransactionProvider transactionProvider) {
@@ -43,12 +44,23 @@ public class Get extends AbstractGet {
     @Override
     protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
 
-        final YangInstanceIdentifier dataRoot = ROOT;
+        final Optional<YangInstanceIdentifier> dataRootOptional = getDataRootFromFilter(operationElement);
+        if (!dataRootOptional.isPresent()) {
+            return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+        }
+
+        final YangInstanceIdentifier dataRoot = dataRootOptional.get();
+
         DOMDataReadWriteTransaction rwTx = getTransaction(Datastore.running);
         try {
             final Optional<NormalizedNode<?, ?>> normalizedNodeOptional = rwTx.read(LogicalDatastoreType.OPERATIONAL, dataRoot).checkedGet();
             transactionProvider.abortRunningTransaction(rwTx);
-            return (Element) transformNormalizedNode(document, normalizedNodeOptional.get(), dataRoot);
+
+            if (!normalizedNodeOptional.isPresent()) {
+                return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+            }
+
+            return serializeNodeWithParentStructure(document, dataRoot, normalizedNodeOptional.get());
         } catch (ReadFailedException e) {
             LOG.warn("Unable to read data: {}", dataRoot, e);
             throw new IllegalStateException("Unable to read data " + dataRoot, e);
index 6eb94f2f1eb58d17837eceb8255252d2f0caec9d..955666f2fe427dc9c9644878dcfdbafe8412762b 100644 (file)
@@ -17,10 +17,12 @@ import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.mdsal.connector.CurrentSchemaContext;
 import org.opendaylight.controller.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.controller.netconf.mdsal.connector.ops.Datastore;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.slf4j.Logger;
@@ -33,7 +35,6 @@ public class GetConfig extends AbstractGet {
     private static final Logger LOG = LoggerFactory.getLogger(GetConfig.class);
 
     private static final String OPERATION_NAME = "get-config";
-
     private final TransactionProvider transactionProvider;
 
     public GetConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext, final TransactionProvider transactionProvider) {
@@ -52,7 +53,13 @@ public class GetConfig extends AbstractGet {
             throw e;
         }
 
-        final YangInstanceIdentifier dataRoot = ROOT;
+        final Optional<YangInstanceIdentifier> dataRootOptional = getDataRootFromFilter(operationElement);
+        if (!dataRootOptional.isPresent()) {
+            return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+        }
+
+        final YangInstanceIdentifier dataRoot = dataRootOptional.get();
+
         // Proper exception should be thrown
         Preconditions.checkState(getConfigExecution.getDatastore().isPresent(), "Source element missing from request");
 
@@ -62,7 +69,12 @@ public class GetConfig extends AbstractGet {
             if (getConfigExecution.getDatastore().get() == Datastore.running) {
                 transactionProvider.abortRunningTransaction(rwTx);
             }
-            return (Element) transformNormalizedNode(document, normalizedNodeOptional.get(), dataRoot);
+
+            if (!normalizedNodeOptional.isPresent()) {
+                return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+            }
+
+            return serializeNodeWithParentStructure(document, dataRoot, normalizedNodeOptional.get());
         } catch (ReadFailedException e) {
             LOG.warn("Unable to read data: {}", dataRoot, e);
             throw new IllegalStateException("Unable to read data " + dataRoot, e);
index 6b942515315ef54a9a62a74253008fd9f6d9f8cd..0d29c0f8b4fac25e5b0c8d57c0ca9429ac8230bc 100644 (file)
@@ -20,6 +20,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.EnumMap;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
@@ -45,11 +46,15 @@ import org.opendaylight.controller.netconf.mdsal.connector.TransactionProvider;
 import org.opendaylight.controller.netconf.mdsal.connector.ops.get.Get;
 import org.opendaylight.controller.netconf.mdsal.connector.ops.get.GetConfig;
 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
@@ -69,6 +74,22 @@ public class NetconfMDSalMappingTest {
 
     private static final String RPC_REPLY_ELEMENT = "rpc-reply";
     private static final String DATA_ELEMENT = "data";
+    private static final String FILTER_NODE = "filter";
+    private static final String GET_CONFIG = "get-config";
+    private static final QName TOP = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "top");
+    private static final QName USERS = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "users");
+    private static final QName USER = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "user");
+    private static final QName MODULES = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "modules");
+    private static final QName AUGMENTED_CONTAINER = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "augmented-container");
+    private static final QName AUGMENTED_STRING_IN_CONT = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "identifier");
+    private static final QName CHOICE_NODE = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "choice-node");
+    private static final QName AUGMENTED_CASE = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "augmented-case");
+    private static final QName CHOICE_WRAPPER = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "choice-wrapper");
+    private static final QName INNER_CHOICE = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "inner-choice");
+    private static final QName INNER_CHOICE_TEXT = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "text");
+
+    private static final YangInstanceIdentifier AUGMENTED_CONTAINER_IN_MODULES =
+            YangInstanceIdentifier.builder().node(TOP).node(MODULES).build().node(new AugmentationIdentifier(Collections.singleton(AUGMENTED_CONTAINER)));
 
     private static Document RPC_REPLY_OK = null;
 
@@ -87,7 +108,6 @@ public class NetconfMDSalMappingTest {
 
     private TransactionProvider transactionProvider = null;
 
-
     @Before
     public void setUp() throws Exception {
 
@@ -96,7 +116,7 @@ public class NetconfMDSalMappingTest {
 
         this.schemaContext = parseSchemas(getYangSchemas());
         schemaContext.getModules();
-        SchemaService schemaService = createSchemaService();
+        final SchemaService schemaService = createSchemaService();
 
         final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
         final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
@@ -108,7 +128,7 @@ public class NetconfMDSalMappingTest {
         ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
                 16, 16, "CommitFutures");
 
-        ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
+        final ConcurrentDOMDataBroker cdb = new ConcurrentDOMDataBroker(datastores, listenableFutureExecutor);
         this.transactionProvider = new TransactionProvider(cdb, sessionIdForReporting);
         this.currentSchemaContext = new CurrentSchemaContext(schemaService);
 
@@ -116,23 +136,16 @@ public class NetconfMDSalMappingTest {
 
     @Test
     public void testEmptyDatastore() throws Exception {
-
-        Document response = getConfigRunning();
-        assertEmptyDatastore(response);
-
-        response = getConfigCandidate();
-        assertEmptyDatastore(response);
-
-        response = get();
-        assertEmptyDatastore(response);
-
+        assertEmptyDatastore(get());
+        assertEmptyDatastore(getConfigCandidate());
+        assertEmptyDatastore(getConfigRunning());
     }
 
     @Test
     public void testEditRunning() throws Exception {
 
         try {
-            edit("messages/mapping/editConfig_running.xml");
+            edit("messages/mapping/editConfigs/editConfig_running.xml");
             fail("Should have failed - edit config on running datastore is not supported");
         } catch (NetconfDocumentedException e) {
             assertTrue(e.getErrorSeverity() == ErrorSeverity.error);
@@ -145,8 +158,8 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testCandidateTransaction() throws Exception {
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_n1.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_n1_control.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_n1.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_n1_control.xml"));
         assertEmptyDatastore(getConfigRunning());
 
         verifyResponse(discardChanges(), RPC_REPLY_OK);
@@ -157,11 +170,11 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testEditWithCommit() throws Exception {
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_n1.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_n1_control.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_n1.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_n1_control.xml"));
 
         verifyResponse(commit(), RPC_REPLY_OK);
-        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_n1_control.xml"));
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_n1_control.xml"));
 
         deleteDatastore();
 
@@ -170,14 +183,14 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testMultipleEditsWithMerge() throws Exception {
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_multiple_1.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_control_1.xml"));
-        verifyResponse(edit("messages/mapping/editConfig_merge_single_1.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_control_2.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_1.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_control_1.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_single_1.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_control_2.xml"));
         assertEmptyDatastore(getConfigRunning());
 
         verifyResponse(commit(), RPC_REPLY_OK);
-        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_control_2.xml"));
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_control_2.xml"));
 
         deleteDatastore();
 
@@ -186,26 +199,26 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testMoreComplexEditConfigs() throws Exception {
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_multiple_1.xml"), RPC_REPLY_OK);
-        verifyResponse(edit("messages/mapping/editConfig_merge_single_1.xml"), RPC_REPLY_OK);
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_1.xml"), RPC_REPLY_OK);
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_single_1.xml"), RPC_REPLY_OK);
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_multiple_2.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_after_more_complex_merge.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_2.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_after_more_complex_merge.xml"));
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_multiple_3.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_after_more_complex_merge_2.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_3.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_after_more_complex_merge_2.xml"));
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_multiple_4_replace.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_after_replace.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_multiple_4_replace.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_after_replace.xml"));
         verifyResponse(commit(), RPC_REPLY_OK);
 
-        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_multiple_after_replace.xml"));
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_multiple_after_replace.xml"));
 
-        verifyResponse(edit("messages/mapping/editConfig_replace_default.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_replace_default_control.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_replace_default.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_replace_default_control.xml"));
         verifyResponse(commit(), RPC_REPLY_OK);
 
-        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_replace_default_control.xml"));
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_replace_default_control.xml"));
 
         deleteDatastore();
 
@@ -244,12 +257,12 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testEditWithCreate() throws Exception {
 
-        verifyResponse(edit("messages/mapping/editConfig_create.xml"), RPC_REPLY_OK);
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_create.xml"), RPC_REPLY_OK);
         verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_create_n1_control.xml"));
 
 
         try {
-            edit("messages/mapping/editConfig_create.xml");
+            edit("messages/mapping/editConfigs/editConfig_create.xml");
             fail("Create should have failed - data already exists");
         } catch (NetconfDocumentedException e) {
             assertTrue(e.getErrorSeverity() == ErrorSeverity.error);
@@ -268,7 +281,7 @@ public class NetconfMDSalMappingTest {
         assertEmptyDatastore(getConfigRunning());
 
         try {
-            edit("messages/mapping/editConfig_delete-root.xml");
+            edit("messages/mapping/editConfigs/editConfig_delete-root.xml");
             fail("Delete should have failed - data is missing");
         } catch (NetconfDocumentedException e) {
             assertTrue(e.getErrorSeverity() == ErrorSeverity.error);
@@ -281,18 +294,96 @@ public class NetconfMDSalMappingTest {
     @Test
     public void testEditMissingDefaultOperation() throws Exception {
 
-        verifyResponse(edit("messages/mapping/editConfig_merge_missing_default-operation_1.xml"), RPC_REPLY_OK);
-        verifyResponse(edit("messages/mapping/editConfig_merge_missing_default-operation_2.xml"), RPC_REPLY_OK);
-        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_missing_default-operation_control.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_missing_default-operation_1.xml"), RPC_REPLY_OK);
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_merge_missing_default-operation_2.xml"), RPC_REPLY_OK);
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_missing_default-operation_control.xml"));
 
         verifyResponse(commit(), RPC_REPLY_OK);
-        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfig_merge_missing_default-operation_control.xml"));
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/editConfigs/editConfig_merge_missing_default-operation_control.xml"));
 
         deleteDatastore();
     }
 
+    @Test
+    public void testFiltering() throws Exception {
+
+        assertEmptyDatastore(getConfigCandidate());
+        assertEmptyDatastore(getConfigRunning());
+
+        verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument("messages/mapping/get-empty-response.xml"));
+        verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument("messages/mapping/get-empty-response.xml"));
+        verifyResponse(getConfigWithFilter("messages/mapping/filters/get-filter-users.xml"),
+                XmlFileLoader.xmlFileToDocument("messages/mapping/get-empty-response.xml"));
+
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig-filtering-setup.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-alluser.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(USERS).node(USER).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-company-info.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(USERS).node(USER).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-modules-and-admin.xml",
+                YangInstanceIdentifier.builder().node(TOP).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-only-names-types.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(USERS).node(USER).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-specific-module-type-and-user.xml",
+                YangInstanceIdentifier.builder().node(TOP).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-superuser.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(USERS).node(USER).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-users.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(USERS).build());
+
+        YangInstanceIdentifier ident = YangInstanceIdentifier.
+                builder(AUGMENTED_CONTAINER_IN_MODULES).
+                node(AUGMENTED_CONTAINER).
+                node(AUGMENTED_STRING_IN_CONT).build();
+
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-augmented-string.xml", ident);
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-augmented-case.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(CHOICE_NODE).node(AUGMENTED_CASE).build());
+
+        verifyResponse(getConfigWithFilter("messages/mapping/filters/get-filter-augmented-case.xml"),
+                XmlFileLoader.xmlFileToDocument("messages/mapping/filters/response-augmented-case.xml"));
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig-filtering-setup2.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-augmented-case-inner-choice.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(CHOICE_NODE).node(CHOICE_WRAPPER).build());
+        verifyFilterIdentifier("messages/mapping/filters/get-filter-augmented-case-inner-case.xml",
+                YangInstanceIdentifier.builder().node(TOP).node(CHOICE_NODE).node(CHOICE_WRAPPER).node(INNER_CHOICE).node(INNER_CHOICE_TEXT).build());
+
+        verifyResponse(getConfigWithFilter("messages/mapping/filters/get-filter-augmented-string.xml"),
+                XmlFileLoader.xmlFileToDocument("messages/mapping/filters/response-augmented-string.xml"));
+        verifyResponse(getConfigWithFilter("messages/mapping/filters/get-filter-augmented-case-inner-choice.xml"),
+                XmlFileLoader.xmlFileToDocument("messages/mapping/filters/response-augmented-case-inner-choice.xml"));
+        verifyResponse(getConfigWithFilter("messages/mapping/filters/get-filter-augmented-case-inner-case.xml"),
+                XmlFileLoader.xmlFileToDocument("messages/mapping/filters/response-augmented-case-inner-choice.xml"));
+
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_delete-top.xml"), RPC_REPLY_OK);
+        verifyResponse(commit(), RPC_REPLY_OK);
+
+    }
+
+    private void verifyFilterIdentifier(String resource, YangInstanceIdentifier identifier) throws Exception{
+        TestingGetConfig getConfig = new TestingGetConfig(sessionIdForReporting, currentSchemaContext, transactionProvider);
+        Document request = XmlFileLoader.xmlFileToDocument(resource);
+        YangInstanceIdentifier iid = getConfig.getInstanceIdentifierFromDocument(request);
+        assertTrue(iid.equals(identifier));
+    }
+
+    private class TestingGetConfig extends GetConfig{
+        public TestingGetConfig(String sessionId, CurrentSchemaContext schemaContext, TransactionProvider transactionProvider) {
+            super(sessionId, schemaContext, transactionProvider);
+        }
+
+        public YangInstanceIdentifier getInstanceIdentifierFromDocument(Document request) throws NetconfDocumentedException {
+            XmlElement filterElement = XmlElement.fromDomDocument(request).getOnlyChildElement(GET_CONFIG).getOnlyChildElement(FILTER_NODE);
+            return getInstanceIdentifierFromFilter(filterElement);
+        }
+    }
+
     private void deleteDatastore() throws Exception{
-        verifyResponse(edit("messages/mapping/editConfig_delete-root.xml"), RPC_REPLY_OK);
+        verifyResponse(edit("messages/mapping/editConfigs/editConfig_delete-root.xml"), RPC_REPLY_OK);
         assertEmptyDatastore(getConfigCandidate());
 
         verifyResponse(commit(), RPC_REPLY_OK);
@@ -351,6 +442,11 @@ public class NetconfMDSalMappingTest {
         return executeOperation(getConfig, "messages/mapping/getConfig_candidate.xml");
     }
 
+    private Document getConfigWithFilter(String resource) throws NetconfDocumentedException, ParserConfigurationException, SAXException, IOException {
+        GetConfig getConfig = new GetConfig(sessionIdForReporting, currentSchemaContext, transactionProvider);
+        return executeOperation(getConfig, resource);
+    }
+
     private Document lock() throws NetconfDocumentedException, ParserConfigurationException, SAXException, IOException {
         Lock lock = new Lock(sessionIdForReporting);
         return executeOperation(lock, "messages/mapping/lock.xml");
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig-filtering-setup.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig-filtering-setup.xml
new file mode 100644 (file)
index 0000000..c059b27
--- /dev/null
@@ -0,0 +1,73 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <edit-config>
+        <target>
+            <candidate/>
+        </target>
+        <test-option>
+            set
+        </test-option>
+        <default-operation>merge</default-operation>
+        <config>
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user>
+                        <name>root</name>
+                        <type>superuser</type>
+                        <full-name>rooty root</full-name>
+                        <company-info>
+                            <dept>1</dept>
+                            <id>1</id>
+                        </company-info>
+                    </user>
+                    <user>
+                        <name>admin</name>
+                        <type>superuser</type>
+                        <full-name>johny admin</full-name>
+                        <company-info>
+                            <dept>2</dept>
+                            <id>2</id>
+                        </company-info>
+                    </user>
+                    <user>
+                        <name>regular</name>
+                        <type>user</type>
+                        <full-name>burt regular</full-name>
+                        <company-info>
+                            <dept>3</dept>
+                            <id>3</id>
+                        </company-info>
+                    </user>
+                </users>
+                <modules>
+                    <augmented-container>
+                        <identifier>augmented container</identifier>
+                    </augmented-container>
+                    <module>
+                        <id>module1</id>
+                        <type>type1</type>
+                        <desc>module1-desc</desc>
+                    </module>
+                    <module>
+                        <id>module2</id>
+                        <type>type1</type>
+                        <desc>module2-desc</desc>
+                    </module>
+                    <module>
+                        <id>module3</id>
+                        <type>unknown</type>
+                        <desc>module3-desc</desc>
+                    </module>
+                </modules>
+                <augmented-case>augmented case</augmented-case>
+            </top>
+        </config>
+    </edit-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig-filtering-setup2.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig-filtering-setup2.xml
new file mode 100644 (file)
index 0000000..ae607e8
--- /dev/null
@@ -0,0 +1,26 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+    <edit-config>
+        <target>
+            <candidate/>
+        </target>
+        <test-option>
+            set
+        </test-option>
+        <default-operation>merge</default-operation>
+        <config>
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <choice-wrapper>
+                    <text>augmented nested choice text1</text>
+                </choice-wrapper>
+            </top>
+        </config>
+    </edit-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_delete-top.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/editConfigs/editConfig_delete-top.xml
new file mode 100644 (file)
index 0000000..75a94fa
--- /dev/null
@@ -0,0 +1,23 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+<edit-config>
+    <target>
+        <candidate/>
+    </target>
+    <test-option>
+        set
+    </test-option>
+    <default-operation>none</default-operation>
+    <config>
+        <top xmlns="urn:opendaylight:mdsal:mapping:test" xmlns:a="urn:ietf:params:xml:ns:netconf:base:1.0" a:operation="delete">
+        </top>
+    </config>
+</edit-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-empty-filter.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-empty-filter.xml
new file mode 100644 (file)
index 0000000..0cc9c12
--- /dev/null
@@ -0,0 +1,17 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-alluser.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-alluser.xml
new file mode 100644 (file)
index 0000000..7f3e0b1
--- /dev/null
@@ -0,0 +1,22 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user/>
+                </users>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case-inner-case.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case-inner-case.xml
new file mode 100644 (file)
index 0000000..8130001
--- /dev/null
@@ -0,0 +1,23 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <choice-wrapper>
+                    <text/>
+                </choice-wrapper>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
+
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case-inner-choice.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case-inner-choice.xml
new file mode 100644 (file)
index 0000000..f673221
--- /dev/null
@@ -0,0 +1,20 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <choice-wrapper/>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-case.xml
new file mode 100644 (file)
index 0000000..a395b3f
--- /dev/null
@@ -0,0 +1,20 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <augmented-case/>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-string.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-augmented-string.xml
new file mode 100644 (file)
index 0000000..cafbf06
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <modules>
+                    <augmented-container>
+                        <identifier/>
+                    </augmented-container>
+                </modules>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-company-info.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-company-info.xml
new file mode 100644 (file)
index 0000000..74ad578
--- /dev/null
@@ -0,0 +1,37 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user>
+                        <name>root</name>
+                        <company-info/>
+                    </user>
+                    <user>
+                        <name>admin</name>
+                        <company-info>
+                            <id/>
+                        </company-info>
+                    </user>
+                    <user>
+                        <name>regular</name>
+                        <company-info>
+                            <dept/>
+                        </company-info>
+                    </user>
+                </users>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-modules-and-admin.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-modules-and-admin.xml
new file mode 100644 (file)
index 0000000..e9f4dee
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user>
+                        <name>admin</name>
+                    </user>
+                </users>
+                <modules/>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-only-names-types.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-only-names-types.xml
new file mode 100644 (file)
index 0000000..863df39
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user>
+                        <name/>
+                        <type/>
+                    </user>
+                </users>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-specific-module-type-and-user.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-specific-module-type-and-user.xml
new file mode 100644 (file)
index 0000000..768904f
--- /dev/null
@@ -0,0 +1,29 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user>
+                        <type>superuser</type>
+                    </user>
+                </users>
+                <modules>
+                    <module>
+                        <type>type1</type>
+                    </module>
+                </modules>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-superuser.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-superuser.xml
new file mode 100644 (file)
index 0000000..f396dfe
--- /dev/null
@@ -0,0 +1,24 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users>
+                    <user>
+                        <type>superuser</type>
+                    </user>
+                </users>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-users.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/get-filter-users.xml
new file mode 100644 (file)
index 0000000..e58cc3d
--- /dev/null
@@ -0,0 +1,20 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc id="a" a="64" xmlnx="a:b:c:d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
+    <get-config>
+        <filter type="subtree">
+            <top xmlns="urn:opendaylight:mdsal:mapping:test">
+                <users/>
+            </top>
+        </filter>
+        <source>
+            <running/>
+        </source>
+    </get-config>
+</rpc>
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-case-inner-choice.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-case-inner-choice.xml
new file mode 100644 (file)
index 0000000..d39007c
--- /dev/null
@@ -0,0 +1,18 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" id="a" message-id="101" xmlnx="a:b:c:d">
+    <data>
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <choice-wrapper>
+                <text>augmented nested choice text1</text>
+            </choice-wrapper>
+        </top>
+    </data>
+</rpc-reply>
+
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-case.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-case.xml
new file mode 100644 (file)
index 0000000..a9e4643
--- /dev/null
@@ -0,0 +1,16 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" id="a" message-id="101" xmlnx="a:b:c:d">
+    <data>
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <augmented-case>augmented case</augmented-case>
+        </top>
+    </data>
+</rpc-reply>
+
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-string.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/filters/response-augmented-string.xml
new file mode 100644 (file)
index 0000000..f866e55
--- /dev/null
@@ -0,0 +1,20 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" id="a" message-id="101" xmlnx="a:b:c:d">
+    <data>
+        <top xmlns="urn:opendaylight:mdsal:mapping:test">
+            <modules>
+                <augmented-container>
+                    <identifier>augmented container</identifier>
+                </augmented-container>
+            </modules>
+        </top>
+    </data>
+</rpc-reply>
+
diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/get-empty-response.xml b/opendaylight/netconf/mdsal-netconf-connector/src/test/resources/messages/mapping/get-empty-response.xml
new file mode 100644 (file)
index 0000000..f9a848d
--- /dev/null
@@ -0,0 +1,11 @@
+<!--
+  ~ Copyright (c) 2015 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
+  -->
+
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" id="a" message-id="101" xmlnx="a:b:c:d">
+    <data/>
+</rpc-reply>
\ No newline at end of file
index 69a82eea84b927b9fbd63f11c3a09b6dfd574099..dadeb694de9c064b8f2211072b122c07358a3311 100644 (file)
@@ -18,4 +18,105 @@ module config {
             }
         }
     }
+
+    container top {
+
+        container users {
+
+            list user {
+
+                leaf name {
+                    type string;
+                }
+
+                leaf type {
+                    type string;
+                }
+
+                leaf full-name {
+                    type string;
+                }
+
+                container company-info {
+
+                    leaf dept {
+                        type string;
+                    }
+
+                    leaf id {
+                        type string;
+                    }
+                }
+            }
+        }
+
+        container modules {
+
+            list module {
+
+                leaf id {
+                    type string;
+                }
+
+                leaf type {
+                    type string;
+                }
+
+                leaf desc {
+                    type string;
+                }
+            }
+        }
+
+        choice choice-node {
+            case a {
+                leaf text {
+                    type string;
+                }
+            }
+
+            case b {
+                container text-cont {
+                    leaf text {
+                        type string;
+                    }
+                }
+            }
+        }
+
+    } //top
+
+    augment "/map:top/map:choice-node" {
+        case c {
+            leaf augmented-case {
+                type string;
+            }
+        }
+
+        case d {
+            container choice-wrapper {
+                choice inner-choice {
+                    case ia {
+                        leaf text {
+                            type string;
+                        }
+                    }
+
+                    case ib {
+                        leaf text2 {
+                            type string;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    augment "/map:top/map:modules/" {
+        container augmented-container{
+            leaf identifier {
+                type string;
+            }
+        }
+    }
 }
\ No newline at end of file