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


##########
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:
   This can be simplified using `Collections.singletonMap`
   ```suggestion
           testRunner.enqueue(JSON_SNIPPET, 
Collections.singletonMap(CoreAttributes.FILENAME.key(), "test.json"));
   ```



-- 
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-unsubscr...@nifi.apache.org

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

Reply via email to