Inline json_sub_container.json 13/109113/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Nov 2023 21:36:13 +0000 (22:36 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Nov 2023 21:36:13 +0000 (22:36 +0100)
This is a simple resource, inline it to its two callers and eliminate
obsolete method which gets freed up.

Change-Id: I706dd3cf59e65e5feda0b787ef658bc41d77c922
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/AbstractResourceBodyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/JsonChildBodyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/JsonResourceBodyTest.java
restconf/restconf-nb/src/test/resources/instanceidentifier/json/json_sub_container.json [deleted file]

index 0cef2808ee260b0fcbea36b60658a66d998742a6..1882a378b48f146fbe016d3371b7f5ef455f9b63 100644 (file)
@@ -72,17 +72,7 @@ abstract class AbstractResourceBodyTest extends AbstractBodyTest {
         DATABIND = DatabindContext.ofModel(YangParserTestUtils.parseYangFiles(testFiles));
     }
 
-    // FIXME: migrate callers to use string literals
-    @Deprecated
-    final @NonNull NormalizedNode parseResource(final String uriPath, final String resourceName) throws IOException {
-        return parse(uriPath, AbstractResourceBodyTest.class.getResourceAsStream(resourceName));
-    }
-
     final @NonNull NormalizedNode parse(final String uriPath, final String patchBody) throws IOException {
-        return parse(uriPath, stringInputStream(patchBody));
-    }
-
-    private @NonNull NormalizedNode parse(final String uriPath, final InputStream patchBody) throws IOException {
         final ApiPath apiPath;
         try {
             apiPath = ApiPath.parse(uriPath);
@@ -90,7 +80,7 @@ abstract class AbstractResourceBodyTest extends AbstractBodyTest {
             throw new AssertionError(e);
         }
 
-        try (var body = bodyConstructor.apply(patchBody)) {
+        try (var body = bodyConstructor.apply(stringInputStream(patchBody))) {
             final var context = InstanceIdentifierContext.ofApiPath(apiPath, DATABIND, mountPointService);
             return body.toNormalizedNode(
                 new DataPutPath(context.databind(), context.inference(), context.getInstanceIdentifier()),
index 0db038732a8a75b9278fade98fc5daf173a2db4f..ae8451936350cc9d9c4c06d7f5a5463d3e18676b 100644 (file)
@@ -38,8 +38,13 @@ class JsonChildBodyTest extends AbstractBodyTest {
 
     @Test
     void moduleSubContainerDataPostTest() {
-        final var body = new JsonChildBody(
-            JsonChildBodyTest.class.getResourceAsStream("/instanceidentifier/json/json_sub_container.json"));
+        final var body = new JsonChildBody(stringInputStream("""
+            {
+              "instance-identifier-module:cont1": {
+                "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont\
+            /instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\\"lflst11_1\\"]"
+              }
+            }"""));
         final var payload = body.toPayload(CONT_PATH);
 
         final var lflst11 = QName.create("augment:module:leaf:list", "2014-01-27", "lflst11");
index aa1436a18b6dc541cf9f500ce424b932c67cc116..456eae5398d8111f4b77df98a6a7da575ed7850b 100644 (file)
@@ -69,8 +69,13 @@ class JsonResourceBodyTest extends AbstractResourceBodyTest {
             .withNodeIdentifier(CONT1_NID)
             .withChild(ImmutableNodes.leafNode(LF11, YangInstanceIdentifier.of(CONT_NID, CONT1_NID,
                 new NodeIdentifier(LFLST11), new NodeWithValue<>(LFLST11, "lflst11_1"))))
-            .build(), parseResource("instance-identifier-module:cont/cont1",
-                "/instanceidentifier/json/json_sub_container.json"));
+            .build(), parse("instance-identifier-module:cont/cont1", """
+                {
+                  "instance-identifier-module:cont1": {
+                    "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont\
+                /instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\\"lflst11_1\\"]"
+                  }
+                }"""));
     }
 
     @Test
diff --git a/restconf/restconf-nb/src/test/resources/instanceidentifier/json/json_sub_container.json b/restconf/restconf-nb/src/test/resources/instanceidentifier/json/json_sub_container.json
deleted file mode 100644 (file)
index 22a1d15..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "instance-identifier-module:cont1": {
-        "augment-module-leaf-list:lf11" : "/instance-identifier-module:cont/instance-identifier-module:cont1/augment-module-leaf-list:lflst11[.=\"lflst11_1\"]"
-    }
-}
\ No newline at end of file