Author: stefanegli
Date: Mon Nov 21 10:27:47 2016
New Revision: 1770640

URL: http://svn.apache.org/viewvc?rev=1770640&view=rev
Log:
OAK-4940 : adding an 'all' node type set to the ChangeSet which includes any 
traveres node's node type - ie including all great/grand-parents

Modified:
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProvider.java
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSet.java
    
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSetBuilder.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProviderTest.java
    
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProvider.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProvider.java?rev=1770640&r1=1770639&r2=1770640&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProvider.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProvider.java
 Mon Nov 21 10:27:47 2016
@@ -142,6 +142,11 @@ public class ChangeCollectorProvider ext
         private Set<String> getPropertyNames() {
             return changeSetBuilder.getPropertyNames();
         }
+
+        private Set<String> getAllNodeTypes() {
+            return changeSetBuilder.getAllNodeTypes();
+        }
+
     }
 
     /**
@@ -159,7 +164,8 @@ public class ChangeCollectorProvider ext
         private final CollectorSupport support;
 
         private final boolean isRoot;
-        private final NodeState parentNodeOrNull;
+        private final NodeState beforeParentNodeOrNull;
+        private final NodeState afterParentNodeOrNull;
         private final String path;
         private final String childName;
         private final int level;
@@ -169,18 +175,19 @@ public class ChangeCollectorProvider ext
         private static ChangeCollector newRootCollector(@Nonnull CommitInfo 
info, int maxItems, int maxPathDepth) {
             ChangeSetBuilder changeSetBuilder = new ChangeSetBuilder(maxItems, 
maxPathDepth);
             CollectorSupport support = new CollectorSupport(info, 
changeSetBuilder, maxPathDepth);
-            return new ChangeCollector(support, true, null, "/", null, 0);
+            return new ChangeCollector(support, true, null, null, "/", null, 
0);
         }
 
-        private ChangeCollector newChildCollector(@Nonnull NodeState 
parentNode, @Nonnull String childName) {
-            return new ChangeCollector(support, false, parentNode, 
concat(path, childName), childName, level + 1);
+        private ChangeCollector newChildCollector(@Nullable NodeState 
beforeParentNodeOrNull, @Nullable NodeState afterParentNodeOrNull, @Nonnull 
String childName) {
+            return new ChangeCollector(support, false, beforeParentNodeOrNull, 
afterParentNodeOrNull, concat(path, childName), childName, level + 1);
         }
 
-        private ChangeCollector(@Nonnull CollectorSupport support, boolean 
isRoot, @Nullable NodeState parentNodeOrNull,
-                @Nonnull String path, @Nullable String childNameOrNull, int 
level) {
+        private ChangeCollector(@Nonnull CollectorSupport support, boolean 
isRoot, @Nullable NodeState beforeParentNodeOrNull,
+                @Nullable NodeState afterParentNodeOrNull, @Nonnull String 
path, @Nullable String childNameOrNull, int level) {
             this.support = support;
             this.isRoot = isRoot;
-            this.parentNodeOrNull = parentNodeOrNull;
+            this.beforeParentNodeOrNull = beforeParentNodeOrNull;
+            this.afterParentNodeOrNull = afterParentNodeOrNull;
             this.path = path;
             this.childName = childNameOrNull;
             this.level = level;
@@ -205,12 +212,19 @@ public class ChangeCollectorProvider ext
             if (changed && childName != null) {
                 support.getParentNodeNames().add(childName);
             }
-            if (changed && parentNodeOrNull != null) {
-                String primaryType = 
parentNodeOrNull.getName(JcrConstants.JCR_PRIMARYTYPE);
+            if (changed && beforeParentNodeOrNull != null) {
+                String primaryType = 
beforeParentNodeOrNull.getName(JcrConstants.JCR_PRIMARYTYPE);
                 if (primaryType != null) {
                     support.getParentNodeTypes().add(primaryType);
                 }
-                Iterables.addAll(support.getParentNodeTypes(), 
parentNodeOrNull.getNames(JcrConstants.JCR_MIXINTYPES));
+                Iterables.addAll(support.getParentNodeTypes(), 
beforeParentNodeOrNull.getNames(JcrConstants.JCR_MIXINTYPES));
+            }
+            if (changed && afterParentNodeOrNull != null) {
+                String primaryType = 
afterParentNodeOrNull.getName(JcrConstants.JCR_PRIMARYTYPE);
+                if (primaryType != null) {
+                    support.getParentNodeTypes().add(primaryType);
+                }
+                Iterables.addAll(support.getParentNodeTypes(), 
afterParentNodeOrNull.getNames(JcrConstants.JCR_MIXINTYPES));
             }
 
             // then if we're not at the root, we're done
@@ -247,7 +261,8 @@ public class ChangeCollectorProvider ext
         @Override
         public Validator childNodeAdded(String childName, NodeState after) 
throws CommitFailedException {
             changed = true;
-            return newChildCollector(after, childName);
+            addToAllNodeType(after);
+            return newChildCollector(null, after, childName);
         }
 
         @Override
@@ -261,14 +276,27 @@ public class ChangeCollectorProvider ext
                 // however, continue normally to handle names/types/properties
                 // below
             }
+            
+            // in theory the node type could be changed, so collecting both 
before and after
+            addToAllNodeType(before);
+            addToAllNodeType(after);
 
-            return newChildCollector(after, childName);
+            return newChildCollector(before, after, childName);
         }
 
         @Override
         public Validator childNodeDeleted(String childName, NodeState before) 
throws CommitFailedException {
             changed = true;
-            return newChildCollector(before, childName);
+            addToAllNodeType(before);
+            return newChildCollector(before, null, childName);
+        }
+        
+        private void addToAllNodeType(NodeState state) {
+            String primaryType = state.getName(JcrConstants.JCR_PRIMARYTYPE);
+            if (primaryType != null) {
+                support.getAllNodeTypes().add(primaryType);
+            }
+            Iterables.addAll(support.getAllNodeTypes(), 
state.getNames(JcrConstants.JCR_MIXINTYPES));
         }
 
     }

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSet.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSet.java?rev=1770640&r1=1770639&r2=1770640&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSet.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSet.java
 Mon Nov 21 10:27:47 2016
@@ -60,20 +60,23 @@ public class ChangeSet {
     private final Set<String> parentNodeNames;
     private final Set<String> parentNodeTypes;
     private final Set<String> propertyNames;
+    private final Set<String> allNodeTypes;
 
     ChangeSet(int maxPathDepth, Set<String> parentPaths, Set<String> 
parentNodeNames, Set<String> parentNodeTypes,
-            Set<String> propertyNames) {
+            Set<String> propertyNames, Set<String> allNodeTypes) {
         this.maxPathDepth = maxPathDepth;
         this.parentPaths = parentPaths == null ? null : 
ImmutableSet.copyOf(parentPaths);
         this.parentNodeNames = parentNodeNames == null ? null : 
ImmutableSet.copyOf(parentNodeNames);
         this.parentNodeTypes = parentNodeTypes == null ? null : 
ImmutableSet.copyOf(parentNodeTypes);
         this.propertyNames = propertyNames == null ? null : 
ImmutableSet.copyOf(propertyNames);
+        this.allNodeTypes = allNodeTypes == null ? null : 
ImmutableSet.copyOf(allNodeTypes);
     }
 
     @Override
     public String toString() {
         return "ChangeSet{paths[maxDepth:" + maxPathDepth + "]=" + parentPaths 
+ ", propertyNames=" + propertyNames
-                + ", nodeNames=" + parentNodeNames + ", nodeTypes=" + 
parentNodeTypes + "}";
+                + ", parentNodeNames=" + parentNodeNames + ", 
parentNodeTypes=" + parentNodeTypes 
+                + ", allNodeTypes=" + allNodeTypes + "}";
     }
 
     @CheckForNull
@@ -100,4 +103,9 @@ public class ChangeSet {
         return maxPathDepth;
     }
 
+    @CheckForNull
+    public Set<String> getAllNodeTypes() {
+        return allNodeTypes;
+    }
+
 }
\ No newline at end of file

Modified: 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSetBuilder.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSetBuilder.java?rev=1770640&r1=1770639&r2=1770640&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSetBuilder.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/observation/ChangeSetBuilder.java
 Mon Nov 21 10:27:47 2016
@@ -20,7 +20,6 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.util.Set;
 
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 
 /**
@@ -34,11 +33,13 @@ public class ChangeSetBuilder {
     private final Set<String> parentNodeNames = Sets.newHashSet();
     private final Set<String> parentNodeTypes = Sets.newHashSet();
     private final Set<String> propertyNames = Sets.newHashSet();
+    private final Set<String> allNodeTypes = Sets.newHashSet();
 
     private boolean parentPathOverflow;
     private boolean parentNodeNameOverflow;
     private boolean parentNodeTypeOverflow;
     private boolean propertyNameOverflow;
+    private boolean allNodeTypeOverflow;
 
     public ChangeSetBuilder(int maxItems, int maxPathDepth) {
         this.maxItems = maxItems;
@@ -47,8 +48,9 @@ public class ChangeSetBuilder {
 
     @Override
     public String toString() {
-        return "ChangeSetBuilder{paths[maxDepth:" + maxPathDepth + "]=" + 
parentPaths + ", propertyNames="
-                + propertyNames + ", nodeNames=" + parentNodeNames + ", 
nodeTypes=" + parentNodeTypes + "}";
+        return "ChangeSetBuilder{parentPaths[maxDepth:" + maxPathDepth + "]=" 
+ parentPaths + ", propertyNames="
+                + propertyNames + ", parentNodeNames=" + parentNodeNames + ", 
parentNodeTypes=" + parentNodeTypes
+                + ", allNodeTypes=" + allNodeTypes + "}";
     }
 
     public boolean getParentPathOverflown() {
@@ -103,6 +105,19 @@ public class ChangeSetBuilder {
         return propertyNames;
     }
 
+    public boolean getAllNodeTypeOverflown() {
+        return allNodeTypeOverflow;
+    }
+
+    public Set<String> getAllNodeTypes() {
+        if (allNodeTypeOverflow || allNodeTypes.size() > maxItems) {
+            // if already overflown, reset the buffers anyway
+            allNodeTypeOverflow = true;
+            allNodeTypes.clear();
+        }
+        return allNodeTypes;
+    }
+
     public int getMaxPrefilterPathDepth() {
         return maxPathDepth;
     }
@@ -113,10 +128,12 @@ public class ChangeSetBuilder {
         getParentNodeNames();
         getParentNodeTypes();
         getPropertyNames();
+        getAllNodeTypes();
         return new ChangeSet(maxPathDepth, parentPathOverflow ? null : 
parentPaths,
                 parentNodeNameOverflow ? null : parentNodeNames,
                 parentNodeTypeOverflow ? null : parentNodeTypes,
-                propertyNameOverflow ? null : propertyNames);
+                propertyNameOverflow ? null : propertyNames,
+                allNodeTypeOverflow ? null : allNodeTypes);
     }
 
 }

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProviderTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProviderTest.java?rev=1770640&r1=1770639&r2=1770640&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProviderTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/ChangeCollectorProviderTest.java
 Mon Nov 21 10:27:47 2016
@@ -178,6 +178,8 @@ public class ChangeCollectorProviderTest
                 "grandChild1", "grandChild2");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType", "test:childType",
                 "test:grandChildType", "test:greatGrandChildType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType",
+                "test:grandChildType", "test:greatGrandChildType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE, "child1Prop",
                 "child2Prop", "grandChild1Prop", "grandChild2Prop", 
"greatGrandChild1Prop");
 
@@ -221,6 +223,8 @@ public class ChangeCollectorProviderTest
                 "greatGrandChild1");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType", "test:childType",
                 "test:grandChildType", "test:greatGrandChildType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType",
+                "test:grandChildType", "test:greatGrandChildType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE, "child1Prop",
                 "grandChild1Prop", "greatGrandChild1Prop");
     }
@@ -238,6 +242,8 @@ public class ChangeCollectorProviderTest
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"grandChild1", "greatGrandChild1");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:greatGrandChildType",
                 "test:grandChildType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType",
+                "test:grandChildType", "test:greatGrandChildType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE,
                 "greatGrandChild1Prop");
     }
@@ -254,6 +260,8 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), 
"/test/child1/grandChild1/greatGrandChild1");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"greatGrandChild1");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:greatGrandChildType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType",
+                "test:grandChildType", "test:greatGrandChildType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
"greatGrandChild1Prop");
     }
 
@@ -272,6 +280,8 @@ public class ChangeCollectorProviderTest
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"grandChild1", "greatGrandChild1");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:grandChildType",
                 "test:greatGrandChildType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType",
+                "test:grandChildType", "test:greatGrandChildType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
"grandChild1Prop", "greatGrandChild1Prop");
     }
 
@@ -286,6 +296,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), "/test");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"test");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType");
         assertMatches("propertyNames", changeSet.getPropertyNames());
     }
 
@@ -301,6 +312,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), "/test", 
"/test/child");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"test", "child");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType");
         assertMatches("propertyNames", changeSet.getPropertyNames());
     }
 
@@ -318,6 +330,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), "/test", 
"/test/child", "/test/child/grandChild");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"test", "child", "grandChild");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
"childProperty", "grandChildProperty");
     }
 
@@ -340,6 +353,9 @@ public class ChangeCollectorProviderTest
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType", "test:type0", "test:type1",
                 "test:type2", "test:type3", "test:type4", "test:type5", 
"test:type6", "test:type7", "test:type8",
                 "test:type9");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:type0", "test:type1",
+                "test:type2", "test:type3", "test:type4", "test:type5", 
"test:type6", "test:type7", "test:type8",
+                "test:type9");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE, "foo0", "foo1",
                 "foo2", "foo3", "foo4", "foo5", "foo6", "foo7", "foo8", 
"foo9");
     }
@@ -359,6 +375,8 @@ public class ChangeCollectorProviderTest
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"test", "child", "child2", "grandChild2");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType", "test:childType",
                 "test:grandChildType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType",
+                "test:grandChildType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE, "child2Prop",
                 "grandChild2Prop");
     }
@@ -405,6 +423,7 @@ public class ChangeCollectorProviderTest
                 "n14"/* , "n15" */);
         assertMatches("parentNodeTypes-" + maxPathDepth, 
changeSet.getParentNodeTypes(), "test:parentType", "test:even",
                 "test:odd");
+        assertMatches("allNodeTypes-" + maxPathDepth, 
changeSet.getAllNodeTypes(), "test:parentType", "test:even", "test:odd");
         assertMatches("propertyNames-" + maxPathDepth, 
changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE,
                 /* "nextProp0", */"nextProp1", "nextProp2", /* "nextProp3", */ 
"nextProp4",
                 "nextProp5"/* , "nextProp6" */
@@ -425,6 +444,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), "/test", 
"/test/child");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"test", "child");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType", "aMixin1", "aMixin2");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "aMixin1", "aMixin2");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_MIXINTYPES);
     }
 
@@ -441,6 +461,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), "/test", 
"/test/newchild");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"test", "newchild");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType", "aPrimaryType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "aPrimaryType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE, "aProp");
     }
 
@@ -471,6 +492,8 @@ public class ChangeCollectorProviderTest
                 expectedParentNodeNames.toArray(new String[0]));
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(),
                 expectedParentNodeTypes.toArray(new String[0]));
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(),
+                expectedParentNodeTypes.toArray(new String[0]));
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
JcrConstants.JCR_PRIMARYTYPE, "aProperty");
     }
 
@@ -495,6 +518,7 @@ public class ChangeCollectorProviderTest
         assertEquals("parentPaths", null, changeSet.getParentPaths());
         assertEquals("parentNodeNames", null, changeSet.getParentNodeNames());
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:parentType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
"aProperty");
     }
 
@@ -514,6 +538,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), 
"/test/child1");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"child1");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:childType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType");
         assertMatches("propertyNames", changeSet.getPropertyNames(), 
expectedPropertyNames.toArray(new String[0]));
     }
 
@@ -540,6 +565,7 @@ public class ChangeCollectorProviderTest
         assertMatches("parentPaths", changeSet.getParentPaths(), 
"/test/child1");
         assertMatches("parentNodeNames", changeSet.getParentNodeNames(), 
"child1");
         assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), 
"test:childType");
+        assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), 
"test:parentType", "test:childType");
         assertEquals("propertyNames", null, changeSet.getPropertyNames());
     }
 
@@ -594,6 +620,7 @@ public class ChangeCollectorProviderTest
                 expectedParentPaths.toArray(new String[0]));
         assertMatches("parentNodeNames-" + maxPathDepth, 
changeSet.getParentNodeNames(), "n13", "n14");
         assertMatches("parentNodeTypes-" + maxPathDepth, 
changeSet.getParentNodeTypes(), "test:even", "test:odd");
+        assertMatches("allNodeTypes-" + maxPathDepth, 
changeSet.getAllNodeTypes(), "test:parentType", "test:even", "test:odd");
         assertMatches("propertyNames-" + maxPathDepth, 
changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE,
                 "nextProp14");
     }
@@ -629,6 +656,7 @@ public class ChangeCollectorProviderTest
         next = rootTree;
         List<String> expectedParentPaths = new LinkedList<String>();
         List<String> expectedParentNodeNames = new LinkedList<String>();
+        Set<String> expectedAllNodeTypes = new HashSet<String>();
         List<String> expectedParentNodeTypes = new LinkedList<String>();
         List<String> expectedPropertyNames = new LinkedList<String>();
         expectedPropertyNames.add(JcrConstants.JCR_PRIMARYTYPE);
@@ -636,20 +664,29 @@ public class ChangeCollectorProviderTest
         if (maxPathDepth > 0) {
             parent = "/test";
         }
+        expectedAllNodeTypes.add("test:parentType");
         for (int i = 0; i <= changeAt; i++) {
             String childName = "n" + i;
             next = next.getChild(childName);
             if (i < maxPathDepth - 1) {
                 parent = concat(parent, childName);
             }
+            final String originalNodeTypeName = i % 2 == 0 ? "test:even" : 
"test:odd";
+            if (i % 3 != 0) {
+                if (i == changeAt) {
+                    expectedParentNodeTypes.add(originalNodeTypeName);
+                }
+                expectedAllNodeTypes.add(originalNodeTypeName);
+            }
             if (i == changeAt) {
                 expectedParentNodeNames.add(next.getName());
                 String propertyName = "nextProp" + i;
                 next.setProperty(propertyName, i + 1);
                 expectedPropertyNames.add(propertyName);
-                final String nodeTypeName = i % 2 == 0 ? "test:evenChanged" : 
"test:oddChanged";
-                expectedParentNodeTypes.add(nodeTypeName);
-                next.setProperty(JcrConstants.JCR_PRIMARYTYPE, nodeTypeName, 
Type.NAME);
+                final String changedNodeTypeName = i % 2 == 0 ? 
"test:evenChanged" : "test:oddChanged";
+                expectedParentNodeTypes.add(changedNodeTypeName);
+                expectedAllNodeTypes.add(changedNodeTypeName);
+                next.setProperty(JcrConstants.JCR_PRIMARYTYPE, 
changedNodeTypeName, Type.NAME);
             }
         }
         expectedParentPaths.add(parent);
@@ -662,6 +699,8 @@ public class ChangeCollectorProviderTest
                 expectedParentNodeNames.toArray(new String[0]));
         assertMatches("parentNodeTypes-" + changeAt + "-" + maxPathDepth, 
changeSet.getParentNodeTypes(),
                 expectedParentNodeTypes.toArray(new String[0]));
+        assertMatches("allNodeTypes-" + changeAt + "-" + maxPathDepth, 
changeSet.getAllNodeTypes(),
+                expectedAllNodeTypes.toArray(new String[0]));
         assertMatches("propertyNames-" + changeAt + "-" + maxPathDepth, 
changeSet.getPropertyNames(),
                 expectedPropertyNames.toArray(new String[0]));
     }

Modified: 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java?rev=1770640&r1=1770639&r2=1770640&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/observation/filter/ChangeSetFilterImplTest.java
 Mon Nov 21 10:27:47 2016
@@ -40,11 +40,20 @@ public class ChangeSetFilterImplTest {
             Set<String> parentNodeNames,
             Set<String> parentNodeTypes,
             Set<String> propertyNames) {
+        return newChangeSet(maxPathDepth, parentPaths, parentNodeNames, 
parentNodeTypes, propertyNames, s());
+    }
+    
+    private ChangeSet newChangeSet(int maxPathDepth, Set<String> parentPaths,
+            Set<String> parentNodeNames,
+            Set<String> parentNodeTypes,
+            Set<String> propertyNames,
+            Set<String> allNodeTypes) {
         ChangeSetBuilder changeSetBuilder = new 
ChangeSetBuilder(Integer.MAX_VALUE, maxPathDepth);
         changeSetBuilder.getParentPaths().addAll(parentPaths);
         changeSetBuilder.getParentNodeNames().addAll(parentNodeNames);
         changeSetBuilder.getParentNodeTypes().addAll(parentNodeTypes);
         changeSetBuilder.getPropertyNames().addAll(propertyNames);
+        changeSetBuilder.getAllNodeTypes().addAll(allNodeTypes);
         return changeSetBuilder.build();
     }
 


Reply via email to