Unify *PatchBodyReader(MountPoint)Tests 03/107503/4
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Aug 2023 15:44:34 +0000 (17:44 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Aug 2023 16:44:52 +0000 (18:44 +0200)
We have thorough duplication of tests here, refactor the class hierarchy
to keep us from duplicating things.

JIRA: NETCONF-1128
Change-Id: I541d708d0e00940cbd703d6dec3dacf2cf30e935
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/AbstractPatchBodyReaderTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderMountPointTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/JsonPatchBodyReaderTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderMountPointTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/patch/XmlPatchBodyReaderTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/test/AbstractBodyReaderTest.java

index 218506300d2e15530e20d6e976567d8fccc01a27..d4f9230fce7fe0df9b881be0703a92ec3638bdfb 100644 (file)
@@ -8,13 +8,28 @@
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.jersey.providers.test.AbstractBodyReaderTest;
 
 abstract class AbstractPatchBodyReaderTest extends AbstractBodyReaderTest {
 
-    static final void checkPatchContext(final PatchContext patchContext) {
+    @NonNull String mountPrefix() {
+        return "";
+    }
+
+    @Nullable DOMMountPoint mountPoint() {
+        return null;
+    }
+
+    final void checkPatchContext(final PatchContext patchContext) {
         assertNotNull(patchContext.getData());
 
         final var iid = patchContext.getInstanceIdentifierContext();
@@ -23,10 +38,10 @@ abstract class AbstractPatchBodyReaderTest extends AbstractBodyReaderTest {
         assertNotNull(iid.getInstanceIdentifier());
         assertNotNull(iid.getSchemaContext());
         assertNotNull(iid.getSchemaNode());
+        assertSame(mountPoint(), iid.getMountPoint());
     }
 
-    static final void checkPatchContextMountPoint(final PatchContext patchContext) {
-        checkPatchContext(patchContext);
-        assertNotNull(patchContext.getInstanceIdentifierContext().getMountPoint());
+    static final @NonNull InputStream stringInputStream(final String str) {
+        return new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8));
     }
 }
index c3ac4f63c653e4c28e09120fdb67d23e73c2093d..b391fa663b088094cafb32526be88cea88d10a37 100644 (file)
  */
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
-
-import java.io.InputStream;
-import javax.ws.rs.core.MediaType;
-import org.junit.Test;
-import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.yangtools.yang.common.ErrorTag;
-
-public class JsonPatchBodyReaderMountPointTest extends AbstractPatchBodyReaderTest {
-    private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
-
-    private final JsonPatchBodyReader jsonToPatchBodyReader;
-
-    public JsonPatchBodyReaderMountPointTest() {
-        jsonToPatchBodyReader = new JsonPatchBodyReader(databindProvider, mountPointService);
-    }
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 
+public class JsonPatchBodyReaderMountPointTest extends JsonPatchBodyReaderTest {
     @Override
-    protected MediaType getMediaType() {
-        return new MediaType(APPLICATION_JSON, null);
-    }
-
-    @Test
-    public void modulePatchDataTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHdata.json")));
-    }
-
-    /**
-     * Test of successful Patch consisting of create and delete Patch operations.
-     */
-    @Test
-    public void modulePatchCreateAndDeleteTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json")));
-    }
-
-    /**
-     * Test trying to use Patch create operation which requires value without value. Test should fail with
-     * {@link RestconfDocumentedException} with error code 400.
-     */
-    @Test
-    public void modulePatchValueMissingNegativeTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        final InputStream inputStream = JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHdataValueMissing.json");
-
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
-            () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
-        assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
+    String mountPrefix() {
+        return "instance-identifier-module:cont/yang-ext:mount/";
     }
 
-    /**
-     * Test trying to use value with Patch delete operation which does not support value. Test should fail with
-     * {@link RestconfDocumentedException} with error code 400.
-     */
-    @Test
-    public void modulePatchValueNotSupportedNegativeTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        final InputStream inputStream = JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
-
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
-            () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
-        assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
-    }
-
-    /**
-     * Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
-     */
-    @Test
-    public void modulePatchCompleteTargetInURITest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json")));
-    }
-
-    /**
-     * Test of Yang Patch merge operation on list. Test consists of two edit operations - replace and merge.
-     */
-    @Test
-    public void modulePatchMergeOperationOnListTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHMergeOperationOnList.json")));
-    }
-
-    /**
-     * Test of Yang Patch merge operation on container. Test consists of two edit operations - create and merge.
-     */
-    @Test
-    public void modulePatchMergeOperationOnContainerTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json")));
-    }
-
-    /**
-     * Test reading simple leaf value.
-     */
-    @Test
-    public void modulePatchSimpleLeafValueTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            JsonPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHSimpleLeafValue.json")));
+    @Override
+    DOMMountPoint mountPoint() {
+        return mountPoint;
     }
 }
index 4dfef164160a57dcdc5ab946b91bd96a0ca7e079..8d318fbee9f10e34cbe2f20df4be4de8821a642e 100644 (file)
@@ -11,13 +11,9 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThrows;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
 import javax.ws.rs.core.MediaType;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -26,42 +22,34 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
-    private final JsonPatchBodyReader jsonToPatchBodyReader;
-
-    public JsonPatchBodyReaderTest() {
-        jsonToPatchBodyReader = new JsonPatchBodyReader(databindProvider, mountPointService);
-    }
+    private final JsonPatchBodyReader jsonToPatchBodyReader =
+        new JsonPatchBodyReader(databindProvider, mountPointService);
 
     @Override
-    protected MediaType getMediaType() {
+    protected final MediaType getMediaType() {
         return new MediaType(APPLICATION_JSON, null);
     }
 
     @Test
-    public void modulePatchDataTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHdata.json");
+    public final void modulePatchDataTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            jsonToPatchBodyReader, false);
 
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
-        checkPatchContext(returnValue);
+        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream("/instanceidentifier/json/jsonPATCHdata.json")));
     }
 
     /**
      * Test of successful Patch consisting of create and delete Patch operations.
      */
     @Test
-    public void modulePatchCreateAndDeleteTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json");
+    public final void modulePatchCreateAndDeleteTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            jsonToPatchBodyReader, false);
 
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
-        checkPatchContext(returnValue);
+        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/json/jsonPATCHdataCreateAndDelete.json")));
     }
 
     /**
@@ -69,14 +57,14 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * {@link RestconfDocumentedException} with error code 400.
      */
     @Test
-    public void modulePatchValueMissingNegativeTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
+    public final void modulePatchValueMissingNegativeTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            jsonToPatchBodyReader, false);
 
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
+        final var inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
             "/instanceidentifier/json/jsonPATCHdataValueMissing.json");
 
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
+        final var ex = assertThrows(RestconfDocumentedException.class,
             () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
         assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
     }
@@ -86,14 +74,14 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * {@link RestconfDocumentedException} with error code 400.
      */
     @Test
-    public void modulePatchValueNotSupportedNegativeTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
+    public final void modulePatchValueNotSupportedNegativeTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            jsonToPatchBodyReader, false);
 
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
+        final var inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
             "/instanceidentifier/json/jsonPATCHdataValueNotSupported.json");
 
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
+        final var ex = assertThrows(RestconfDocumentedException.class,
             () -> jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
         assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
     }
@@ -102,87 +90,74 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
      */
     @Test
-    public void modulePatchCompleteTargetInURITest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json");
+    public final void modulePatchCompleteTargetInURITest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont", jsonToPatchBodyReader, false);
 
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
-        checkPatchContext(returnValue);
+        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/json/jsonPATCHdataCompleteTargetInURI.json")));
     }
 
     /**
-     * Test of Yang Patch merge operation on list. Test consists of two edit operations - replace and merge.
+     * Test of YANG Patch merge operation on list. Test consists of two edit operations - replace and merge.
      */
     @Test
-    public void modulePatchMergeOperationOnListTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
+    public final void modulePatchMergeOperationOnListTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            jsonToPatchBodyReader, false);
 
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHMergeOperationOnList.json");
-
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
-        checkPatchContext(returnValue);
+        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/json/jsonPATCHMergeOperationOnList.json")));
     }
 
     /**
-     * Test of Yang Patch merge operation on container. Test consists of two edit operations - create and merge.
+     * Test of YANG Patch merge operation on container. Test consists of two edit operations - create and merge.
      */
     @Test
-    public void modulePatchMergeOperationOnContainerTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
+    public final void modulePatchMergeOperationOnContainerTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont", jsonToPatchBodyReader, false);
 
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json");
-
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
-        checkPatchContext(returnValue);
+        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/json/jsonPATCHMergeOperationOnContainer.json")));
     }
 
     /**
      * Test reading simple leaf value.
      */
     @Test
-    public void modulePatchSimpleLeafValueTest() throws Exception {
-        final String uri = "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, jsonToPatchBodyReader, false);
-
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/json/jsonPATCHSimpleLeafValue.json");
+    public final void modulePatchSimpleLeafValueTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            jsonToPatchBodyReader, false);
 
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/json/jsonPATCHSimpleLeafValue.json"));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(LEAF_NAME_QNAME, data.name().getNodeType());
-        assertEquals(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf20"), data);
+        assertEquals(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf20"), returnValue.getData().get(0).getNode());
     }
 
     /**
-     * Test of Yang Patch on the top-level container with empty URI for data root.
+     * 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);
+    public final void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
+        mockBodyReader(mountPrefix(), jsonToPatchBodyReader, false);
 
-        final InputStream inputStream = JsonPatchBodyReaderTest.class.getResourceAsStream(
-                "/instanceidentifier/json/jsonPATCHTargetTopLevelContainerWithEmptyURI.json");
-
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
-        checkPatchContext(returnValue);
+        checkPatchContext(jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            JsonPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/json/jsonPATCHTargetTopLevelContainerWithEmptyURI.json")));
     }
 
     /**
-     * Test of Yang Patch on the top-level container with the full path in the URI and "/" in 'target'.
+     * Test of YANG Patch on the top-level container with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont", jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont", jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "test-patch",
@@ -206,8 +181,7 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }""".getBytes(StandardCharsets.UTF_8));
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
         assertEquals(Builders.containerBuilder()
             .withNodeIdentifier(new NodeIdentifier(PATCH_CONT_QNAME))
@@ -224,13 +198,14 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
     }
 
     /**
-     * Test of Yang Patch on the second-level list with the full path in the URI and "/" in 'target'.
+     * Test of YANG Patch on the second-level list with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=my-leaf-set",
-                jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=my-leaf-set",
+            jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "test-patch",
@@ -252,8 +227,7 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }""".getBytes(StandardCharsets.UTF_8));
-        final PatchContext returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
         assertEquals(Builders.mapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MY_LIST1_QNAME))
@@ -271,9 +245,10 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * Test of Yang Patch on the top augmented element.
      */
     @Test
-    public void modulePatchTargetTopLevelAugmentedContainerTest() throws Exception {
-        mockBodyReader("", jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetTopLevelAugmentedContainerTest() throws Exception {
+        mockBodyReader(mountPrefix(), jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "test-patch",
@@ -291,26 +266,22 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(CONT_AUG_QNAME))
-                .withChild(ImmutableNodes.leafNode(LEAF_AUG_QNAME, "data"))
-                .build();
-        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(CONT_AUG_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(CONT_AUG_QNAME))
+            .withChild(ImmutableNodes.leafNode(LEAF_AUG_QNAME, "data"))
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
-     * Test of Yang Patch on the system map node element.
+     * Test of YANG Patch on the system map node element.
      */
     @Test
-    public void modulePatchTargetMapNodeTest() throws Exception {
-        mockBodyReader("", jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetMapNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "map-patch",
@@ -329,30 +300,26 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.mapBuilder()
-                .withNodeIdentifier(new NodeIdentifier(MAP_CONT_QNAME))
-                .withChild(Builders.mapEntryBuilder()
-                        .withNodeIdentifier(NodeIdentifierWithPredicates.of(MAP_CONT_QNAME, KEY_LEAF_QNAME, "key"))
-                        .withChild(ImmutableNodes.leafNode(KEY_LEAF_QNAME, "key"))
-                        .withChild(ImmutableNodes.leafNode(DATA_LEAF_QNAME, "data"))
-                        .build())
-                .build();
-        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(MAP_CONT_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.mapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MAP_CONT_QNAME))
+            .withChild(Builders.mapEntryBuilder()
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MAP_CONT_QNAME, KEY_LEAF_QNAME, "key"))
+                .withChild(ImmutableNodes.leafNode(KEY_LEAF_QNAME, "key"))
+                .withChild(ImmutableNodes.leafNode(DATA_LEAF_QNAME, "data"))
+                .build())
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
      * Test of Yang Patch on the leaf set node element.
      */
     @Test
-    public void modulePatchTargetLeafSetNodeTest() throws Exception {
-        mockBodyReader("", jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetLeafSetNodeTest() throws Exception {
+        mockBodyReader(mountPrefix() + "", jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "set-patch",
@@ -368,29 +335,25 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.leafSetBuilder()
-                .withNodeIdentifier(new NodeIdentifier(LEAF_SET_QNAME))
-                .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, "data1"))
-                        .withValue("data1")
-                        .build())
-                .build();
-        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(LEAF_SET_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.leafSetBuilder()
+            .withNodeIdentifier(new NodeIdentifier(LEAF_SET_QNAME))
+            .withChild(Builders.leafSetEntryBuilder()
+                .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, "data1"))
+                .withValue("data1")
+                .build())
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
      * Test of Yang Patch on the unkeyed list node element.
      */
     @Test
-    public void modulePatchTargetUnkeyedListNodeTest() throws Exception {
-        mockBodyReader("", jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetUnkeyedListNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "list-patch",
@@ -409,30 +372,26 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.unkeyedListBuilder()
-                .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
-                .withChild(Builders.unkeyedListEntryBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
-                        .withChild(ImmutableNodes.leafNode(LIST_LEAF1_QNAME, "data1"))
-                        .withChild(ImmutableNodes.leafNode(LIST_LEAF2_QNAME, "data2"))
-                        .build())
-                .build();
-        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(LIST_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.unkeyedListBuilder()
+            .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
+            .withChild(Builders.unkeyedListEntryBuilder()
+                .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
+                .withChild(ImmutableNodes.leafNode(LIST_LEAF1_QNAME, "data1"))
+                .withChild(ImmutableNodes.leafNode(LIST_LEAF2_QNAME, "data2"))
+                .build())
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
      * Test of Yang Patch on the case node element.
      */
     @Test
-    public void modulePatchTargetCaseNodeTest() throws Exception {
-        mockBodyReader("", jsonToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchTargetCaseNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), jsonToPatchBodyReader, false);
+
+        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, stringInputStream("""
             {
                 "ietf-yang-patch:yang-patch": {
                     "patch-id": "choice-patch",
@@ -450,16 +409,11 @@ public class JsonPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                         }
                     ]
                 }
-            }
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(CHOICE_CONT_QNAME))
-                .withChild(ImmutableNodes.leafNode(CASE_LEAF1_QNAME, "data"))
-                .build();
-        final var returnValue = jsonToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+            }"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(CHOICE_CONT_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(CHOICE_CONT_QNAME))
+            .withChild(ImmutableNodes.leafNode(CASE_LEAF1_QNAME, "data"))
+            .build(), returnValue.getData().get(0).getNode());
     }
 }
index 6b995bbee6dbf98281f2eec129611255db43c1e1..a2774ff40562b6ca869adf683db92f8bc643dbc5 100644 (file)
  */
 package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
-
-import java.io.InputStream;
-import javax.ws.rs.core.MediaType;
-import org.junit.Test;
-import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.yangtools.yang.common.ErrorTag;
-
-public class XmlPatchBodyReaderMountPointTest extends AbstractPatchBodyReaderTest {
-    private static final String MOUNT_POINT = "instance-identifier-module:cont/yang-ext:mount/";
-
-    private final XmlPatchBodyReader xmlToPatchBodyReader;
-
-    public XmlPatchBodyReaderMountPointTest() {
-        xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
-    }
+import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 
+public class XmlPatchBodyReaderMountPointTest extends XmlPatchBodyReaderTest {
     @Override
-    protected MediaType getMediaType() {
-        return new MediaType(MediaType.APPLICATION_XML, null);
-    }
-
-    @Test
-    public void moduleDataTest() throws Exception {
-        mockBodyReader(MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader,
-            false);
-        checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            XmlPatchBodyReaderMountPointTest.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdata.xml")));
-    }
-
-    /**
-     * Test trying to use Patch create operation which requires value without value. Error code 400 should be returned.
-     */
-    @Test
-    public void moduleDataValueMissingNegativeTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, xmlToPatchBodyReader, false);
-        final InputStream inputStream = XmlPatchBodyReaderMountPointTest.class.getResourceAsStream(
-            "/instanceidentifier/xml/xmlPATCHdataValueMissing.xml");
-
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
-            () -> xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
-        assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
-    }
-
-    /**
-     * Test trying to use value with Patch delete operation which does not support value. Error code 400 should be
-     * returned.
-     */
-    @Test
-    public void moduleDataNotValueNotSupportedNegativeTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, xmlToPatchBodyReader, false);
-        final InputStream inputStream = XmlPatchBodyReaderMountPointTest.class.getResourceAsStream(
-            "/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml");
-
-        RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
-            () -> xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
-        assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
-    }
-
-    /**
-     * Test of Yang Patch with absolute target path.
-     */
-    @Test
-    public void moduleDataAbsoluteTargetPathTest() throws Exception {
-        final String uri = MOUNT_POINT;
-        mockBodyReader(uri, xmlToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            XmlPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml")));
-    }
-
-    /**
-     * Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
-     */
-    @Test
-    public void modulePatchCompleteTargetInURITest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
-        mockBodyReader(uri, xmlToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            XmlPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml")));
-    }
-
-    /**
-     * Test of Yang Patch merge operation on list. Test consists of two edit operations - replace and merge.
-     */
-    @Test
-    public void moduleDataMergeOperationOnListTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont/my-list1=leaf1";
-        mockBodyReader(uri, xmlToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            XmlPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml")));
+    String mountPrefix() {
+        return "instance-identifier-module:cont/yang-ext:mount/";
     }
 
-    /**
-     * Test of Yang Patch merge operation on container. Test consists of two edit operations - create and merge.
-     */
-    @Test
-    public void moduleDataMergeOperationOnContainerTest() throws Exception {
-        final String uri = MOUNT_POINT + "instance-identifier-patch-module:patch-cont";
-        mockBodyReader(uri, xmlToPatchBodyReader, false);
-
-        checkPatchContextMountPoint(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
-            XmlPatchBodyReaderMountPointTest.class.getResourceAsStream(
-                "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml")));
+    @Override
+    DOMMountPoint mountPoint() {
+        return mountPoint;
     }
 }
index f33c80aec3ab9dc24a8abe4d1d887f67f1036785..c48b2748505792f64972d657a1e1033e5ac6fb99 100644 (file)
@@ -10,13 +10,9 @@ package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThrows;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
 import javax.ws.rs.core.MediaType;
 import org.junit.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -25,20 +21,18 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
-    private final XmlPatchBodyReader xmlToPatchBodyReader;
-
-    public XmlPatchBodyReaderTest() {
-        xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
-    }
+    private final XmlPatchBodyReader xmlToPatchBodyReader = new XmlPatchBodyReader(databindProvider, mountPointService);
 
     @Override
-    protected MediaType getMediaType() {
+    protected final MediaType getMediaType() {
         return new MediaType(MediaType.APPLICATION_XML, null);
     }
 
     @Test
-    public void moduleDataTest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
+    public final void moduleDataTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            xmlToPatchBodyReader, false);
+
         checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
             XmlPatchBodyReaderTest.class.getResourceAsStream("/instanceidentifier/xml/xmlPATCHdata.xml")));
     }
@@ -47,11 +41,13 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * Test trying to use Patch create operation which requires value without value. Error code 400 should be returned.
      */
     @Test
-    public void moduleDataValueMissingNegativeTest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
-        final InputStream inputStream = XmlPatchBodyReaderTest.class.getResourceAsStream(
+    public final void moduleDataValueMissingNegativeTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            xmlToPatchBodyReader, false);
+
+        final var inputStream = XmlPatchBodyReaderTest.class.getResourceAsStream(
             "/instanceidentifier/xml/xmlPATCHdataValueMissing.xml");
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
+        final var ex = assertThrows(RestconfDocumentedException.class,
             () -> xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
         assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
     }
@@ -61,21 +57,24 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * returned.
      */
     @Test
-    public void moduleDataNotValueNotSupportedNegativeTest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
-        final InputStream inputStream = XmlPatchBodyReaderTest.class.getResourceAsStream(
+    public final void moduleDataNotValueNotSupportedNegativeTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            xmlToPatchBodyReader, false);
+
+        final var inputStream = XmlPatchBodyReaderTest.class.getResourceAsStream(
             "/instanceidentifier/xml/xmlPATCHdataValueNotSupported.xml");
-        final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
+        final var ex = assertThrows(RestconfDocumentedException.class,
             () -> xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
         assertEquals(ErrorTag.MALFORMED_MESSAGE, ex.getErrors().get(0).getErrorTag());
     }
 
     /**
-     * Test of Yang Patch with absolute target path.
+     * Test of YANG Patch with absolute target path.
      */
     @Test
-    public void moduleDataAbsoluteTargetPathTest() throws Exception {
-        mockBodyReader("", xmlToPatchBodyReader, false);
+    public final void moduleDataAbsoluteTargetPathTest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
         checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
             XmlPatchBodyReaderTest.class.getResourceAsStream(
                 "/instanceidentifier/xml/xmlPATCHdataAbsoluteTargetPath.xml")));
@@ -85,8 +84,9 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
      */
     @Test
-    public void modulePatchCompleteTargetInURITest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont", xmlToPatchBodyReader, false);
+    public final void modulePatchCompleteTargetInURITest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont", xmlToPatchBodyReader, false);
+
         checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
             XmlPatchBodyReaderTest.class.getResourceAsStream(
                 "/instanceidentifier/xml/xmlPATCHdataCompleteTargetInURI.xml")));
@@ -96,62 +96,66 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * Test of Yang Patch merge operation on list. Test consists of two edit operations - replace and merge.
      */
     @Test
-    public void moduleDataMergeOperationOnListTest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
-        final InputStream inputStream = XmlPatchBodyReaderTest.class.getResourceAsStream(
-            "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml");
-        checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
+    public final void moduleDataMergeOperationOnListTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            xmlToPatchBodyReader, false);
+
+        checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            XmlPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnList.xml")));
     }
 
     /**
      * Test of Yang Patch merge operation on container. Test consists of two edit operations - create and merge.
      */
     @Test
-    public void moduleDataMergeOperationOnContainerTest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont", xmlToPatchBodyReader, false);
-        final InputStream inputStream = XmlPatchBodyReaderTest.class
-                .getResourceAsStream("/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml");
-        checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
+    public final void moduleDataMergeOperationOnContainerTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont", xmlToPatchBodyReader, false);
+
+        checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            XmlPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/xml/xmlPATCHdataMergeOperationOnContainer.xml")));
     }
 
     /**
      * 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 = XmlPatchBodyReaderTest.class
-                .getResourceAsStream("/instanceidentifier/xml/xmlPATCHTargetTopLevelContainerWithEmptyURI.xml");
-        checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream));
+    public final void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
+        checkPatchContext(xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            XmlPatchBodyReaderTest.class.getResourceAsStream(
+                "/instanceidentifier/xml/xmlPATCHTargetTopLevelContainerWithEmptyURI.xml")));
     }
 
     /**
-     * Test of Yang Patch on the top-level container with the full path in the URI and "/" in 'target'.
+     * Test of YANG Patch on the top-level container with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <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 '/' in target</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/</target>
-                    <value>
-                        <patch-cont xmlns="instance:identifier:patch:module">
-                            <my-list1>
-                                <name>my-leaf-set</name>
-                                <my-leaf11>leaf-a</my-leaf11>
-                                <my-leaf12>leaf-b</my-leaf12>
-                            </my-list1>
-                        </patch-cont>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont", xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <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 '/' in target</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/</target>
+                        <value>
+                            <patch-cont xmlns="instance:identifier:patch:module">
+                                <my-list1>
+                                    <name>my-leaf-set</name>
+                                    <my-leaf11>leaf-a</my-leaf11>
+                                    <my-leaf12>leaf-b</my-leaf12>
+                                </my-list1>
+                            </patch-cont>
+                        </value>
+                    </edit>
+                </yang-patch>"""));
         checkPatchContext(returnValue);
         assertEquals(Builders.containerBuilder()
             .withNodeIdentifier(new NodeIdentifier(PATCH_CONT_QNAME))
@@ -168,31 +172,32 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
     }
 
     /**
-     * Test of Yang Patch on the second-level list with the full path in the URI and "/" in 'target'.
+     * Test of YANG Patch on the second-level list with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=my-leaf-set",
-                xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
-                <patch-id>test-patch</patch-id>
-                <comment>Test patch applied to the second-level list with '/' in target</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/</target>
-                    <value>
-                        <my-list1 xmlns="instance:identifier:patch:module">
-                            <name>my-leaf-set</name>
-                            <my-leaf11>leaf-a</my-leaf11>
-                            <my-leaf12>leaf-b</my-leaf12>
-                        </my-list1>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final PatchContext returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=my-leaf-set",
+            xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+                    <patch-id>test-patch</patch-id>
+                    <comment>Test patch applied to the second-level list with '/' in target</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/</target>
+                        <value>
+                            <my-list1 xmlns="instance:identifier:patch:module">
+                                <name>my-leaf-set</name>
+                                <my-leaf11>leaf-a</my-leaf11>
+                                <my-leaf12>leaf-b</my-leaf12>
+                            </my-list1>
+                        </value>
+                    </edit>
+                </yang-patch>
+                """));
         checkPatchContext(returnValue);
         assertEquals(Builders.mapBuilder()
             .withNodeIdentifier(new NodeIdentifier(MY_LIST1_QNAME))
@@ -209,185 +214,173 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
      * Test of Yang Patch on the top augmented element.
      */
     @Test
-    public void moduleTargetTopLevelAugmentedContainerTest() throws Exception {
-        mockBodyReader("", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
-                <patch-id>test-patch</patch-id>
-                <comment>This test patch for augmented element</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/test-m:container-root/test-m:container-lvl1/test-m-aug:container-aug</target>
-                    <value>
-                        <container-aug xmlns="test-ns-aug">
-                            <leaf-aug>data</leaf-aug>
-                        </container-aug>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(CONT_AUG_QNAME))
-                .withChild(ImmutableNodes.leafNode(LEAF_AUG_QNAME, "data"))
-                .build();
-        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void moduleTargetTopLevelAugmentedContainerTest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+                    <patch-id>test-patch</patch-id>
+                    <comment>This test patch for augmented element</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/test-m:container-root/test-m:container-lvl1/test-m-aug:container-aug</target>
+                        <value>
+                            <container-aug xmlns="test-ns-aug">
+                                <leaf-aug>data</leaf-aug>
+                            </container-aug>
+                        </value>
+                    </edit>
+                </yang-patch>"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(CONT_AUG_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(CONT_AUG_QNAME))
+            .withChild(ImmutableNodes.leafNode(LEAF_AUG_QNAME, "data"))
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
-     * Test of Yang Patch on the top system map node element.
+     * Test of YANG Patch on the top system map node element.
      */
     @Test
-    public void moduleTargetMapNodeTest() throws Exception {
-        mockBodyReader("", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
-                <patch-id>map-patch</patch-id>
-                <comment>YANG patch comment</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/map-model:cont-root/map-model:cont1/map-model:my-map=key</target>
-                    <value>
-                        <my-map xmlns="map:ns">
-                            <key-leaf>key</key-leaf>
-                            <data-leaf>data</data-leaf>
-                        </my-map>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.mapBuilder()
-                .withNodeIdentifier(new NodeIdentifier(MAP_CONT_QNAME))
-                .withChild(Builders.mapEntryBuilder()
-                        .withNodeIdentifier(NodeIdentifierWithPredicates.of(MAP_CONT_QNAME, KEY_LEAF_QNAME, "key"))
-                        .withChild(ImmutableNodes.leafNode(KEY_LEAF_QNAME, "key"))
-                        .withChild(ImmutableNodes.leafNode(DATA_LEAF_QNAME, "data"))
-                        .build())
-                .build();
-        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void moduleTargetMapNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+                    <patch-id>map-patch</patch-id>
+                    <comment>YANG patch comment</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/map-model:cont-root/map-model:cont1/map-model:my-map=key</target>
+                        <value>
+                            <my-map xmlns="map:ns">
+                                <key-leaf>key</key-leaf>
+                                <data-leaf>data</data-leaf>
+                            </my-map>
+                        </value>
+                    </edit>
+                </yang-patch>"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(MAP_CONT_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.mapBuilder()
+            .withNodeIdentifier(new NodeIdentifier(MAP_CONT_QNAME))
+            .withChild(Builders.mapEntryBuilder()
+                .withNodeIdentifier(NodeIdentifierWithPredicates.of(MAP_CONT_QNAME, KEY_LEAF_QNAME, "key"))
+                .withChild(ImmutableNodes.leafNode(KEY_LEAF_QNAME, "key"))
+                .withChild(ImmutableNodes.leafNode(DATA_LEAF_QNAME, "data"))
+                .build())
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
-     * Test of Yang Patch on the leaf set node element.
+     * Test of YANG Patch on the leaf set node element.
      */
     @Test
-    public void modulePatchTargetLeafSetNodeTest() throws Exception {
-        mockBodyReader("", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
-                <patch-id>set-patch</patch-id>
-                <comment>YANG patch comment</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/set-model:cont-root/set-model:cont1/set-model:my-set="data1"</target>
-                    <value>
-                        <my-set xmlns="set:ns">data1</my-set>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.leafSetBuilder()
-                .withNodeIdentifier(new NodeIdentifier(LEAF_SET_QNAME))
-                .withChild(Builders.leafSetEntryBuilder()
-                        .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, "data1"))
-                        .withValue("data1")
-                        .build())
-                .build();
-        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void modulePatchTargetLeafSetNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+                    <patch-id>set-patch</patch-id>
+                    <comment>YANG patch comment</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/set-model:cont-root/set-model:cont1/set-model:my-set="data1"</target>
+                        <value>
+                            <my-set xmlns="set:ns">data1</my-set>
+                        </value>
+                    </edit>
+                </yang-patch>"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(LEAF_SET_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.leafSetBuilder()
+            .withNodeIdentifier(new NodeIdentifier(LEAF_SET_QNAME))
+            .withChild(Builders.leafSetEntryBuilder()
+                .withNodeIdentifier(new NodeWithValue<>(LEAF_SET_QNAME, "data1"))
+                .withValue("data1")
+                .build())
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
      * Test of Yang Patch on the top unkeyed list element.
      */
     @Test
-    public void moduleTargetUnkeyedListNodeTest() throws Exception {
-        mockBodyReader("", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
-                <patch-id>list-patch</patch-id>
-                <comment>YANG patch comment</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/list-model:cont-root/list-model:cont1/list-model:unkeyed-list</target>
-                    <value>
-                        <unkeyed-list xmlns="list:ns">
-                            <leaf1>data1</leaf1>
-                            <leaf2>data2</leaf2>
-                        </unkeyed-list>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.unkeyedListBuilder()
-                .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
-                .withChild(Builders.unkeyedListEntryBuilder()
-                        .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
-                        .withChild(ImmutableNodes.leafNode(LIST_LEAF1_QNAME, "data1"))
-                        .withChild(ImmutableNodes.leafNode(LIST_LEAF2_QNAME, "data2"))
-                        .build())
-                .build();
-        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void moduleTargetUnkeyedListNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+                    <patch-id>list-patch</patch-id>
+                    <comment>YANG patch comment</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/list-model:cont-root/list-model:cont1/list-model:unkeyed-list</target>
+                        <value>
+                            <unkeyed-list xmlns="list:ns">
+                                <leaf1>data1</leaf1>
+                                <leaf2>data2</leaf2>
+                            </unkeyed-list>
+                        </value>
+                    </edit>
+                </yang-patch>"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(LIST_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.unkeyedListBuilder()
+            .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
+            .withChild(Builders.unkeyedListEntryBuilder()
+                .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
+                .withChild(ImmutableNodes.leafNode(LIST_LEAF1_QNAME, "data1"))
+                .withChild(ImmutableNodes.leafNode(LIST_LEAF2_QNAME, "data2"))
+                .build())
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
      * Test of Yang Patch on the top case node element.
      */
     @Test
-    public void moduleTargetCaseNodeTest() throws Exception {
-        mockBodyReader("", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
-            <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
-                <patch-id>choice-patch</patch-id>
-                <comment>YANG patch comment</comment>
-                <edit>
-                    <edit-id>edit1</edit-id>
-                    <operation>replace</operation>
-                    <target>/choice-model:cont-root/choice-model:cont1/choice-model:case-cont1</target>
-                    <value>
-                        <case-cont1 xmlns="choice:ns">
-                            <case-leaf1>data</case-leaf1>
-                        </case-cont1>
-                    </value>
-                </edit>
-            </yang-patch>
-            """.getBytes(StandardCharsets.UTF_8));
-        final var expectedData = Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(CHOICE_CONT_QNAME))
-                .withChild(ImmutableNodes.leafNode(CASE_LEAF1_QNAME, "data"))
-                .build();
-        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+    public final void moduleTargetCaseNodeTest() throws Exception {
+        mockBodyReader(mountPrefix(), xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
+                <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+                    <patch-id>choice-patch</patch-id>
+                    <comment>YANG patch comment</comment>
+                    <edit>
+                        <edit-id>edit1</edit-id>
+                        <operation>replace</operation>
+                        <target>/choice-model:cont-root/choice-model:cont1/choice-model:case-cont1</target>
+                        <value>
+                            <case-cont1 xmlns="choice:ns">
+                                <case-leaf1>data</case-leaf1>
+                            </case-cont1>
+                        </value>
+                    </edit>
+                </yang-patch>"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(CHOICE_CONT_QNAME, data.name().getNodeType());
-        assertEquals(expectedData, data);
+        assertEquals(Builders.containerBuilder()
+            .withNodeIdentifier(new NodeIdentifier(CHOICE_CONT_QNAME))
+            .withChild(ImmutableNodes.leafNode(CASE_LEAF1_QNAME, "data"))
+            .build(), returnValue.getData().get(0).getNode());
     }
 
     /**
      * Test reading simple leaf value.
      */
     @Test
-    public void modulePatchSimpleLeafValueTest() throws Exception {
-        mockBodyReader("instance-identifier-patch-module:patch-cont/my-list1=leaf1", xmlToPatchBodyReader, false);
-        final var inputStream = new ByteArrayInputStream("""
+    public final void modulePatchSimpleLeafValueTest() throws Exception {
+        mockBodyReader(mountPrefix() + "instance-identifier-patch-module:patch-cont/my-list1=leaf1",
+            xmlToPatchBodyReader, false);
+
+        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null,
+            stringInputStream("""
                 <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                     <patch-id>test-patch</patch-id>
                     <comment>this is test patch</comment>
@@ -399,12 +392,8 @@ public class XmlPatchBodyReaderTest extends AbstractPatchBodyReaderTest {
                             <name xmlns="instance:identifier:patch:module">my-leaf20</name>
                         </value>
                     </edit>
-                </yang-patch>
-                """.getBytes(StandardCharsets.UTF_8));
-        final var returnValue = xmlToPatchBodyReader.readFrom(null, null, null, mediaType, null, inputStream);
+                </yang-patch>"""));
         checkPatchContext(returnValue);
-        final var data = returnValue.getData().get(0).getNode();
-        assertEquals(LEAF_NAME_QNAME, data.name().getNodeType());
-        assertEquals(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf20"), data);
+        assertEquals(ImmutableNodes.leafNode(LEAF_NAME_QNAME, "my-leaf20"), returnValue.getData().get(0).getNode());
     }
 }
index 73733ec78f433cc008b162fc1ec60ce087ceb730..bcf645914300b88cdf6ddf09173db0a95ab62d9d 100644 (file)
@@ -74,6 +74,7 @@ public abstract class AbstractBodyReaderTest {
     protected final MediaType mediaType;
     protected final DatabindProvider databindProvider;
     protected final DOMMountPointService mountPointService;
+    protected final DOMMountPoint mountPoint;
 
     protected AbstractBodyReaderTest() {
         this(BASELINE_CONTEXT);
@@ -86,7 +87,7 @@ public abstract class AbstractBodyReaderTest {
         databindProvider = () -> databindContext;
 
         mountPointService = mock(DOMMountPointService.class);
-        final var mountPoint = mock(DOMMountPoint.class);
+        mountPoint = mock(DOMMountPoint.class);
         doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
         doReturn(Optional.of(FixedDOMSchemaService.of(schemaContext))).when(mountPoint)
             .getService(DOMSchemaService.class);