You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/08/25 16:23:40 UTC

[camel-kamelets] branch field-test-1 created (now c92320d2)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch field-test-1
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git


      at c92320d2 More MaskField test and regen

This branch includes the following new commits:

     new c92320d2 More MaskField test and regen

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel-kamelets] 01/01: More MaskField test and regen

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch field-test-1
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit c92320d2ef34bcd512f7d5871000b09d8a26b7e1
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Aug 25 18:22:42 2022 +0200

    More MaskField test and regen
---
 .../kamelets/utils/transform/MaskFieldTest.java    | 32 +++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/transform/MaskFieldTest.java b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/transform/MaskFieldTest.java
index aac86f10..bc8f0c51 100644
--- a/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/transform/MaskFieldTest.java
+++ b/library/camel-kamelets-utils/src/test/java/org/apache/camel/kamelets/utils/transform/MaskFieldTest.java
@@ -25,6 +25,11 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 class MaskFieldTest {
 
     private DefaultCamelContext camelContext;
@@ -44,7 +49,7 @@ class MaskFieldTest {
     }
 
     @Test
-    void shouldMaskFieldFromJsonNode() throws Exception {
+    void shouldMaskField() throws Exception {
         Exchange exchange = new DefaultExchange(camelContext);
 
         exchange.getMessage().setBody(mapper.readTree(baseJson));
@@ -53,4 +58,29 @@ class MaskFieldTest {
         Assertions.assertEquals("\"xxxx\"" , s.get("name").toString());
     }
 
+    @Test
+    void shouldMaskFieldWithNull() throws Exception {
+        Exchange exchange = new DefaultExchange(camelContext);
+
+        exchange.getMessage().setBody(mapper.readTree(baseJson));
+
+        JsonNode s = processor.process("name", null, exchange);
+        Assertions.assertEquals("\"\"" , s.get("name").toString());
+    }
+
+    @Test
+    void shouldMaskFieldList() throws Exception {
+        Map<String, List> names = new HashMap<>();
+        Exchange exchange = new DefaultExchange(camelContext);
+        List<String> els = new ArrayList<>();
+        els.add("Sheldon");
+        els.add("Rajesh");
+        els.add("Leonard");
+        names.put("names", els);
+
+        exchange.getMessage().setBody(mapper.writeValueAsString(names));
+
+        JsonNode s = processor.process("names", null, exchange);
+        Assertions.assertEquals("[]" , s.get("names").toString());
+    }
 }