pvillard31 commented on code in PR #10923:
URL: https://github.com/apache/nifi/pull/10923#discussion_r2852251319
##########
nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java:
##########
@@ -2689,4 +2692,74 @@ public long getVersion() {
return 0;
}
}
+
+ @Test
+ public void testUnique() {
+ final Map<String, String> attributes = new HashMap<>();
+
+ // Test basic comma-separated list
+ attributes.put("list", "apple,banana,apple,orange,banana,grape");
+ verifyEquals("${list:unique(',')}", attributes,
"apple,banana,orange,grape");
+
+ // Test pipe-separated list
+ attributes.put("pipe_list", "red|blue|red|green|blue|yellow");
+ verifyEquals("${pipe_list:unique('|')}", attributes,
"red|blue|green|yellow");
+
+ // Test with spaces
+ attributes.put("space_list", "one two one three two four");
+ verifyEquals("${space_list:unique(' ')}", attributes, "one two three
four");
+
+ attributes.put("space_list", "one two one three two four");
+ verifyEquals("${space_list:unique(' ')}", attributes, "one two three
four");
Review Comment:
```suggestion
// Test with spaces
attributes.put("space_list", "one two one three two four");
verifyEquals("${space_list:unique(' ')}", attributes, "one two three
four");
```
##########
nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java:
##########
@@ -2689,4 +2692,74 @@ public long getVersion() {
return 0;
}
}
+
+ @Test
+ public void testUnique() {
+ final Map<String, String> attributes = new HashMap<>();
+
+ // Test basic comma-separated list
+ attributes.put("list", "apple,banana,apple,orange,banana,grape");
+ verifyEquals("${list:unique(',')}", attributes,
"apple,banana,orange,grape");
+
+ // Test pipe-separated list
+ attributes.put("pipe_list", "red|blue|red|green|blue|yellow");
+ verifyEquals("${pipe_list:unique('|')}", attributes,
"red|blue|green|yellow");
+
+ // Test with spaces
+ attributes.put("space_list", "one two one three two four");
+ verifyEquals("${space_list:unique(' ')}", attributes, "one two three
four");
+
+ attributes.put("space_list", "one two one three two four");
+ verifyEquals("${space_list:unique(' ')}", attributes, "one two three
four");
+
+ // Test with empty values in list
+ attributes.put("empty_values_in_list", "a,,b,,");
+ verifyEquals("${empty_values_in_list:unique(',')}", attributes,
"a,,b");
Review Comment:
Very minor but the previous test was a bit more thorough
```suggestion
// Test with empty values in list
attributes.put("empty_values_in_list", "a,b,,c,,d,b");
verifyEquals("${empty_values_in_list:unique(',')}", attributes,
"a,b,,c,d");
```
--
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]