stack.exit();
}
- final EffectiveStatement<?, ?> parentStmt = stack.currentStatement();
- verify(parentStmt instanceof SchemaNode, "Unexpected parent %s", parentStmt);
+ if (!stack.isEmpty()) {
+ final EffectiveStatement<?, ?> parentStmt = stack.currentStatement();
+ verify(parentStmt instanceof SchemaNode, "Unexpected parent %s", parentStmt);
+ }
edit.setTargetSchemaNode(stack.toInference());
}
stack.exit();
}
- final EffectiveStatement<?, ?> parentStmt = stack.currentStatement();
- verify(parentStmt instanceof SchemaNode, "Unexpected parent %s", parentStmt);
- targetNode = (SchemaNode) parentStmt;
+ if (stack.isEmpty()) {
+ targetNode = pathContext.getSchemaContext();
+ } else {
+ final EffectiveStatement<?, ?> parentStmt = stack.currentStatement();
+ verify(parentStmt instanceof SchemaNode, "Unexpected parent %s", parentStmt);
+ targetNode = (SchemaNode) parentStmt;
+ }
}
if (targetNode == null) {
final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
checkPatchContext(returnValue);
}
+
+ /**
+ * Test of Yang Patch on the top-level container with empty URI for data root.
+ */
+ @Test
+ public void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
+ final String uri = "";
+ mockBodyReader(uri, jsonToPatchBodyReader, false);
+
+ final InputStream inputStream = JsonBodyReaderTest.class.getResourceAsStream(
+ "/instanceidentifier/json/jsonPATCHTargetTopLevelContainerWithEmptyURI.json");
+
+ final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+ checkPatchContext(returnValue);
+ }
}
.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml");
checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
}
+
+ /**
+ * Test of Yang Patch on the top-level container with empty URI for data root.
+ */
+ @Test
+ public void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
+ mockBodyReader("", xmlToPatchBodyReader, false);
+ final InputStream inputStream = XmlBodyReaderTest.class
+ .getResourceAsStream("/instanceidentifier/xml/xmlPATCHTargetTopLevelContainerWithEmptyURI.xml");
+ checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
+ }
}
--- /dev/null
+{
+ "ietf-yang-patch:yang-patch" : {
+ "patch-id" : "test-patch",
+ "comment" : "Test patch applied to the top-level container with empty URI",
+ "edit" : [
+ {
+ "edit-id": "edit1",
+ "operation": "replace",
+ "target": "/instance-identifier-patch-module:patch-cont",
+ "value": {
+ "patch-cont": {
+ "my-list1": [
+ {
+ "name": "my-leaf10"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+}
--- /dev/null
+<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+ <patch-id>test-patch</patch-id>
+ <comment>Test patch applied to the top-level container with empty URI</comment>
+ <edit>
+ <edit-id>edit1</edit-id>
+ <operation>replace</operation>
+ <target>/instance-identifier-patch-module:patch-cont</target>
+ <value>
+ <patch-cont xmlns="instance:identifier:patch:module">
+ <my-list1>
+ <name>my-leaf10</name>
+ </my-list1>
+ </patch-cont>
+ </value>
+ </edit>
+</yang-patch>