alopresto commented on a change in pull request #3604: NIFI-6255 NIFI-6287: 
Hash function for expression language and record…
URL: https://github.com/apache/nifi/pull/3604#discussion_r307413633
 
 

 ##########
 File path: 
nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java
 ##########
 @@ -1816,6 +1816,18 @@ public void testIfElse() {
         verifyEquals("${literal(true):ifElse(false, 'b')}", attributes, 
"false");
     }
 
+    @Test
+    public void testHash() {
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("str_attr", "string value");
+        attributes.put("nbr_attr", "10");
+        verifyEquals("${literal('john'):hash('MD5')}", attributes, 
"527bd5b5d689e2c32ae974c6229ff785");
+        verifyEquals("${str_attr:hash('MD5')}", attributes, 
"64e58419496c7248b4ef25731f88b8c3");
+        verifyEquals("${str_attr:hash('SHA-1')}", attributes, 
"34990db823e7bb2b47278a7fbf08c62d9e8e4307");
+        verifyEquals("${str_attr:hash('SHA-256')}", attributes, 
"9b6a1a9167a5caf3f5948413faa89e0ec0de89e12bef55327442e60dcc0e8c9b");
+        verifyEquals("${nbr_attr:toNumber():hash('MD5')}", attributes, 
"d3d9446802a44259755d38e6d163e820");
 
 Review comment:
   I would add a line verifying that `${nbr_attr:hash('MD5')}` also equals the 
same hash as when it is converted using `toNumber()` to demonstrate the 
equivalence. 

----------------------------------------------------------------
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