You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/12/23 13:57:34 UTC

[GitHub] [nifi] Lehel44 commented on a diff in pull request #6803: NIFI-10998: Fix SplitJson to always compile new JsonPath when property changes

Lehel44 commented on code in PR #6803:
URL: https://github.com/apache/nifi/pull/6803#discussion_r1056360444


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestSplitJson.java:
##########
@@ -112,6 +112,43 @@ public void testSplit_arrayResult_multipleValues() throws Exception {
         originalOut.assertContentEquals(JSON_SNIPPET);
     }
 
+    @Test
+    public void testSplit_change_jsonpath() throws Exception {
+        final TestRunner testRunner = TestRunners.newTestRunner(new SplitJson());
+        testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[0].range");
+
+        testRunner.enqueue(JSON_SNIPPET);
+        testRunner.run();
+
+        int numSplitsExpected = 10;
+
+        testRunner.assertTransferCount(SplitJson.REL_ORIGINAL, 1);
+        testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0).assertAttributeEquals(FRAGMENT_COUNT.key(), String.valueOf(numSplitsExpected));
+        testRunner.assertTransferCount(SplitJson.REL_SPLIT, numSplitsExpected);
+        final MockFlowFile originalOut = testRunner.getFlowFilesForRelationship(SplitJson.REL_ORIGINAL).get(0);
+        originalOut.assertContentEquals(JSON_SNIPPET);
+
+        // Change JsonPath Expression, verify it is being applied correctly
+        testRunner.clearTransferState();
+        testRunner.setProperty(SplitJson.ARRAY_JSON_PATH_EXPRESSION, "$[*].name");
+
+        testRunner.enqueue(JSON_SNIPPET, new HashMap<>() {
+            {
+                put(CoreAttributes.FILENAME.key(), "test.json");
+            }
+        });

Review Comment:
   Using diamond with anonymous inner classes is not supported for some reason, this change fixes the build, too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org