Eliminate use of SchemaNode.getPath() in TestRestconfUtils
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / TestRestconfUtils.java
index c1682dc7cce4c30ce27c662bf3214f97dfc61701..1ecdef936d2b7f9b54c315f34bb2614876bf97e6 100644 (file)
@@ -24,6 +24,8 @@ import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
 import org.opendaylight.yangtools.yang.common.YangConstants;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 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.codec.xml.XmlParserStream;
@@ -117,8 +119,14 @@ public final class TestRestconfUtils {
 
         final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
         final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
-        final XmlParserStream xmlParser = XmlParserStream.create(writer,
-            SchemaInferenceStack.ofInstantiatedPath(iiContext.getSchemaContext(), schemaNode.getPath()).toInference());
+
+        final SchemaInferenceStack stack = SchemaInferenceStack.of(iiContext.getSchemaContext());
+        iiContext.getInstanceIdentifier().getPathArguments().stream()
+                .filter(p -> !(p instanceof NodeIdentifierWithPredicates))
+                .filter(p -> !(p instanceof AugmentationIdentifier))
+                .forEach(p -> stack.enterSchemaTree(p.getNodeType()));
+
+        final XmlParserStream xmlParser = XmlParserStream.create(writer, stack.toInference());
 
         if (schemaNode instanceof ContainerSchemaNode || schemaNode instanceof ListSchemaNode) {
             xmlParser.traverse(new DOMSource(doc.getDocumentElement()));