tpalfy commented on a change in pull request #3646: NIFI-6546 - Add JsonPath 
set value support
URL: https://github.com/apache/nifi/pull/3646#discussion_r317960818
 
 

 ##########
 File path: 
nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java
 ##########
 @@ -336,17 +345,20 @@ public void testJsonPath() throws IOException {
         }
     }
 
-    private void verifyCommonAddressBookAttributes(Map<String,String> 
attributes, String skipCheck) {
-        if (! ADDRESS_BOOK_JSON_PATH_FIRST_NAME.equals(skipCheck) )
-            verifyEquals(ADDRESS_BOOK_JSON_PATH_FIRST_NAME, attributes, 
"John");
-        if (! ADDRESS_BOOK_JSON_PATH_LAST_NAME.equals(skipCheck) )
-            verifyEquals(ADDRESS_BOOK_JSON_PATH_LAST_NAME, attributes, 
"Smith");
-        if (! ADDRESS_BOOK_JSON_PATH_AGE.equals(skipCheck) )
-            verifyEquals(ADDRESS_BOOK_JSON_PATH_AGE, attributes, "25");
-        if (! ADDRESS_BOOK_JSON_PATH_VOTER.equals(skipCheck) )
-            verifyEquals(ADDRESS_BOOK_JSON_PATH_VOTER, attributes, "true");
-        if (! ADDRESS_BOOK_JSON_PATH_ADDRESS_POSTAL_CODE.equals(skipCheck) )
-            verifyEquals(ADDRESS_BOOK_JSON_PATH_ADDRESS_POSTAL_CODE, 
attributes, "10021-3100");
+    private void verifyAddressBookAttributes(String originalAddressBook, 
Map<String,String> attributes, String updatedAttribute, Object updatedValue, 
boolean verifyBothPhones) {
+
+        Map<String, String> originalAttributes = new HashMap<>();
+        originalAttributes.put("json", originalAddressBook);
+
+        phoneBookAttributes.stream()
+                .filter(currentAttribute -> 
!currentAttribute.equals(updatedAttribute))
+                .forEach(currentAttribute -> {
+                            String expected = 
Query.evaluateExpressions(currentAttribute, originalAttributes, null, null, 
ParameterLookup.EMPTY);
+                            verifyEquals(currentAttribute, attributes, 
expected);
+                        }
+                );
+        if ( verifyBothPhones )
 
 Review comment:
   `phoneBookAttribute` already covers both phone books. I feel like that they 
are treated as special for some reason but I don't see why we still need this 
separate and redundant check?
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to