You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by np...@apache.org on 2017/10/24 16:42:59 UTC

[sling-org-apache-sling-pipes] branch master updated: SLING-7217 change to use find

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

npeltier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git


The following commit(s) were added to refs/heads/master by this push:
     new a1b1c72  SLING-7217 change to use find
     new ab1f421  Merge branch 'master' of github.com:apache/sling-org-apache-sling-pipes
a1b1c72 is described below

commit a1b1c72e413b8cd93a6a020ff9130c237a285c62
Author: npeltier <pe...@gmail.com>
AuthorDate: Tue Oct 24 18:42:28 2017 +0200

    SLING-7217 change to use find
    
    and added failing unit test
---
 .../java/org/apache/sling/pipes/internal/FilterPipe.java   |  2 +-
 .../org/apache/sling/pipes/internal/FilterPipeTest.java    | 14 ++++++++++++++
 src/test/resources/SLING-INF/jcr_root/content/fruits.json  |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java b/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java
index 5a8f97c..5748ab3 100644
--- a/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/FilterPipe.java
@@ -57,7 +57,7 @@ public class FilterPipe extends BasePipe {
         for (String key : filter.keySet()){
             if (! IGNORED_PROPERTIES.contains(key) && !key.startsWith(PREFIX_FILTER)){
                 Pattern pattern = Pattern.compile(filter.get(key, String.class));
-                if (!pattern.matcher(current.get(key, String.class)).matches()){
+                if (!pattern.matcher(current.get(key, String.class)).find()){
                     return false;
                 }
             }
diff --git a/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java b/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java
index dfdffe8..26fd634 100644
--- a/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java
+++ b/src/test/java/org/apache/sling/pipes/internal/FilterPipeTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Iterator;
+import java.util.Set;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.resource.ModifiableValueMap;
@@ -103,4 +104,17 @@ public class FilterPipeTest extends AbstractPipeTest {
         assertFalse("output has no resource...", resourceIterator.hasNext());
     }
 
+    @Test
+    public void testPropertyRegexp() throws Exception {
+        Set<String> outputs = plumber.newPipe(context.resourceResolver())
+            .echo(PATH_APPLE)
+            .grep("jcr:description","https://en.wikipedia.org").run();
+        assertEquals("there should be an item", 1, outputs.size());
+        outputs = plumber.newPipe(context.resourceResolver())
+                .echo(PATH_APPLE)
+                .grep("jcr:description",".*https://en.wikipedia.org.*").run();
+        assertEquals("there should be an item", 1, outputs.size());
+
+    }
+
 }
diff --git a/src/test/resources/SLING-INF/jcr_root/content/fruits.json b/src/test/resources/SLING-INF/jcr_root/content/fruits.json
index c9b2c71..eb53e89 100644
--- a/src/test/resources/SLING-INF/jcr_root/content/fruits.json
+++ b/src/test/resources/SLING-INF/jcr_root/content/fruits.json
@@ -5,6 +5,7 @@
     "jcr:primaryType":"nt:unstructured",
     "sling:resourceType":"/apps/pipes-it/fruit",
     "jcr:title":"Apple",
+    "jcr:description":"This is an <a href='https://en.wikipedia.org/wiki/Apple'>apple</a>",
     "color":"green",
     "worm": true,
     "isnota":{

-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].