use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testAddMixin.
@Test
public void testAddMixin() throws Exception {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
rootTree.addChild("child").setProperty(JcrConstants.JCR_MIXINTYPES, Arrays.asList("aMixin1", "aMixin2"), Type.NAMES);
root.commit();
ChangeSet changeSet = getSingleChangeSet();
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);
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testChangeGreatGrandChild.
@Test
public void testChangeGreatGrandChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
rootTree.getChild("child1").getChild("grandChild1").getChild("greatGrandChild1").setProperty("greatGrandChild1Prop", 2);
root.commit();
ChangeSet changeSet = getSingleChangeSet();
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");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testAddEmptyRemoveChildren.
@Test
public void testAddEmptyRemoveChildren() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Tree child = rootTree.addChild("child");
child.addChild("grandChild");
assertTrue(rootTree.getChild("child2").remove());
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test", "/test/child", "/test/child2", "/test/child2/grandChild2");
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");
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method testAddEmptyGrandChild.
@Test
public void testAddEmptyGrandChild() throws CommitFailedException {
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Tree child = rootTree.addChild("child");
child.addChild("grandChild");
root.commit();
ChangeSet changeSet = getSingleChangeSet();
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());
}
use of org.apache.jackrabbit.oak.spi.observation.ChangeSet in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method doAddMaxPathDepth.
private void doAddMaxPathDepth(int maxPathDepth) throws CommitFailedException {
collectorProvider.setMaxPathDepth(maxPathDepth);
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/test");
Tree next = rootTree;
for (int i = 0; i < 16; i++) {
next = next.addChild("n" + i);
if (i % 3 != 0) {
next.setProperty("nextProp" + i, i);
next.setProperty(JcrConstants.JCR_PRIMARYTYPE, i % 2 == 0 ? "test:even" : "test:odd", Type.NAME);
}
}
root.commit();
ChangeSet changeSet = getSingleChangeSet();
List<String> expectedParentPaths = new LinkedList<String>();
if (maxPathDepth == 0) {
expectedParentPaths.add("/");
} else {
expectedParentPaths.add("/test");
}
for (int i = 0; i < maxPathDepth - 1; i++) {
StringBuffer path = new StringBuffer("/test");
for (int j = 0; j < i; j++) {
path.append("/n" + j);
}
expectedParentPaths.add(path.toString());
}
assertMatches("parentPaths-" + maxPathDepth, changeSet.getParentPaths(), expectedParentPaths.toArray(new String[0]));
assertMatches("parentNodeNames-" + maxPathDepth, changeSet.getParentNodeNames(), "test", "n0", "n1", "n2", "n3", "n4", "n5", "n6", "n7", "n8", "n9", "n10", "n11", "n12", "n13", "n14");
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" */
"nextProp7", "nextProp8", /* "nextProp9", */
"nextProp10", "nextProp11", /* "nextProp12", */
"nextProp13", "nextProp14");
}
Aggregations