dan-s1 commented on code in PR #9785:
URL: https://github.com/apache/nifi/pull/9785#discussion_r1993421630


##########
nifi-extension-bundles/nifi-jolt-bundle/nifi-jolt-processors/src/test/java/org/apache/nifi/processors/jolt/TestJoltTransformJSON.java:
##########
@@ -464,6 +464,71 @@ void testJoltSpecInvalidEL() throws IOException {
         runner.assertNotValid();
     }
 
+    @Test
+    void testJsonAttributeNotInitialised() throws IOException {
+        runner.setProperty(JoltTransformJSON.JSON_SOURCE, 
SourceStrategy.ATTRIBUTE);
+        runner.setProperty(JoltTransformJSON.JOLT_SPEC, 
"./src/test/resources/specs/shiftrSpec.json");
+        runner.setProperty(JoltTransformJSON.JOLT_TRANSFORM, 
JoltTransformStrategy.SHIFTR);
+        runner.setProperty(JoltTransformJSON.JSON_SOURCE_ATTRIBUTE, 
"jsonAttr");
+        runner.enqueue(JSON_INPUT);
+        runner.run();
+        runner.assertAllFlowFilesTransferred(JoltTransformJSON.REL_FAILURE);
+    }
+
+    @Test
+    void testInvalidJsonAttribute() throws IOException {
+        runner.setProperty(JoltTransformJSON.JSON_SOURCE, 
SourceStrategy.ATTRIBUTE);
+        runner.setProperty(JoltTransformJSON.JOLT_SPEC, 
"./src/test/resources/specs/shiftrSpec.json");
+        runner.setProperty(JoltTransformJSON.JOLT_TRANSFORM, 
JoltTransformStrategy.SHIFTR);
+        runner.setProperty(JoltTransformJSON.JSON_SOURCE_ATTRIBUTE, 
"jsonAttr");
+        final Map<String, String> attributes = 
Collections.singletonMap("jsonAttr",
+                
"{\"rating\":{\"primary\":{\"value\":3},\"series\":{\"value\":[5,4]},\"quality\":{\"value\":}}}");

Review Comment:
   You could simply use `Map.of` like you do on line 497. Similar comment for 
line 511.
   
   ```suggestion
           final Map<String, String> attributes = Map.of("jsonAttr",
                   
"{\"rating\":{\"primary\":{\"value\":3},\"series\":{\"value\":[5,4]},\"quality\":{\"value\":}}}");
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to