public boolean anyOverflow() { return getAllNodeTypes() == null || getParentNodeNames() == null || getParentNodeTypes() == null || getParentPaths() == null || getPropertyNames() == null; }
public boolean anyOverflow() { return getAllNodeTypes() == null || getParentNodeNames() == null || getParentNodeTypes() == null || getParentPaths() == null || getPropertyNames() == null; }
@Test public void asJson() throws Exception{ ChangeSet cs1 = new ChangeSet(2, of("p-2", "p-3"), null, ImmutableSet.<String>of(), of("pn-2"), of("nt-2")); String json = cs1.asString(); ChangeSet cs2 = ChangeSet.fromString(json); assertEquals(cs1, cs2); assertNull(cs2.getParentNodeNames()); assertTrue(cs2.getParentNodeTypes().isEmpty()); }
@Test public void overflowParentNodeName() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(2, 2); add(cb1, "1"); ChangeSet cs1 = new ChangeSet(2, of("p-2"), null, of("pnt-2"), of("pn-2"), of("nt-2")); ChangeSet cs = cb1.add(cs1).build(); assertNull(cs.getParentNodeNames()); assertThat(cs.getAllNodeTypes(), containsInAnyOrder("nt-1", "nt-2")); assertThat(cs.getParentNodeTypes(), containsInAnyOrder("pnt-1", "pnt-2")); assertThat(cs.getPropertyNames(), containsInAnyOrder("pn-1", "pn-2")); ChangeSet cs2 = new ChangeSet(2, of("p-2"), of("nn-2", "nn-3"), of("pnt-2"), of("pn-2"), of("nt-2")); cs = cb1.add(cs2).build(); assertNull(cs.getParentNodeNames()); }
@Test public void overflowPath() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(2, 2); add(cb1, "1"); ChangeSet cs1 = new ChangeSet(2, null, of("nn-2"), of("pnt-2"), of("pn-2"), of("nt-2")); ChangeSet cs = cb1.add(cs1).build(); assertNull(cs.getParentPaths()); assertThat(cs.getAllNodeTypes(), containsInAnyOrder("nt-1", "nt-2")); assertThat(cs.getParentNodeNames(), containsInAnyOrder("nn-1", "nn-2")); assertThat(cs.getParentNodeTypes(), containsInAnyOrder("pnt-1", "pnt-2")); assertThat(cs.getPropertyNames(), containsInAnyOrder("pn-1", "pn-2")); ChangeSet cs2 = new ChangeSet(2, of("p-2", "p-3"), of("nn-2"), of("pnt-2"), of("pn-2"), of("nt-2")); cs = cb1.add(cs2).build(); assertNull(cs.getParentPaths()); }
@Test public void overflowAllNodeTypes() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(2, 2); add(cb1, "1"); ChangeSet cs1 = new ChangeSet(2, of("p-2"), of("nn-2"), of("pnt-2"), of("pn-2"), null); ChangeSet cs = cb1.add(cs1).build(); assertNull(cs.getAllNodeTypes()); assertThat(cs.getParentPaths(), containsInAnyOrder("p-1", "p-2")); assertThat(cs.getParentNodeNames(), containsInAnyOrder("nn-1", "nn-2")); assertThat(cs.getParentNodeTypes(), containsInAnyOrder("pnt-1", "pnt-2")); assertThat(cs.getPropertyNames(), containsInAnyOrder("pn-1", "pn-2")); }
@Test public void overflowPropertyNames() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(2, 2); add(cb1, "1"); ChangeSet cs1 = new ChangeSet(2, of("p-2"), of("nn-2"), of("pnt-2"), null, of("nt-2")); ChangeSet cs = cb1.add(cs1).build(); assertNull(cs.getPropertyNames()); assertThat(cs.getParentPaths(), containsInAnyOrder("p-1", "p-2")); assertThat(cs.getAllNodeTypes(), containsInAnyOrder("nt-1", "nt-2")); assertThat(cs.getParentNodeNames(), containsInAnyOrder("nn-1", "nn-2")); assertThat(cs.getParentNodeTypes(), containsInAnyOrder("pnt-1", "pnt-2")); }
@Test public void overflowParentNodeTypes() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(2, 2); add(cb1, "1"); ChangeSet cs1 = new ChangeSet(2, of("p-2"), of("nn-2"), null, of("pn-2"), of("nt-2")); ChangeSet cs = cb1.add(cs1).build(); assertNull(cs.getParentNodeTypes()); assertThat(cs.getParentPaths(), containsInAnyOrder("p-1", "p-2")); assertThat(cs.getAllNodeTypes(), containsInAnyOrder("nt-1", "nt-2")); assertThat(cs.getParentNodeNames(), containsInAnyOrder("nn-1", "nn-2")); assertThat(cs.getPropertyNames(), containsInAnyOrder("pn-1", "pn-2")); }
@Test public void testPropertyNotOverflown() throws Exception { Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); Tree child1 = rootTree.getChild("child1"); Set<String> expectedPropertyNames = Sets.newHashSet(); for (int i = 0; i < collectorProvider.getMaxItems(); i++) { child1.setProperty("aProperty" + i, "foo"); expectedPropertyNames.add("aProperty" + i); } root.commit(); ChangeSet changeSet = getSingleChangeSet(); 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])); }
private void doTestPropertyOverflown(int overflowCnt) throws CommitFailedException, PrivilegedActionException { setup(); Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); Tree child1 = rootTree.getChild("child1"); Set<String> expectedPropertyNames = Sets.newHashSet(); for (int i = 0; i < collectorProvider.getMaxItems() + overflowCnt; i++) { child1.setProperty("aProperty" + i, "foo"); expectedPropertyNames.add("aProperty" + i); } root.commit(); ChangeSet changeSet = getSingleChangeSet(); 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()); }
@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); }
@Test public void nullChangeSet() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(10, 8); add(cb1, "1"); cb1.add(null); ChangeSet cs = cb1.build(); assertNull(cs.getParentNodeTypes()); assertNull(cs.getParentNodeNames()); assertNull(cs.getParentPaths()); assertNull(cs.getAllNodeTypes()); assertNull(cs.getPropertyNames()); }
@Test public void testAddEmptyChild() throws CommitFailedException { Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); rootTree.addChild("child"); root.commit(); ChangeSet changeSet = getSingleChangeSet(); 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()); }
@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()); }
private void doTestPathOverflown(int overflowCnt) throws CommitFailedException, PrivilegedActionException { setup(); Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); for (int i = 0; i < collectorProvider.getMaxItems() + overflowCnt; i++) { rootTree.addChild("manychildren" + i).setProperty("aProperty", "foo"); ; } root.commit(); ChangeSet changeSet = getSingleChangeSet(); 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"); }
@Test public void testAddNodeWithProperties() throws Exception { Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); Tree aChild = rootTree.addChild("newchild"); aChild.setProperty("aProp", "aValue", Type.NAME); aChild.setProperty(JcrConstants.JCR_PRIMARYTYPE, "aPrimaryType", Type.NAME); root.commit(); ChangeSet changeSet = getSingleChangeSet(); 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"); }
@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"); }
@Test public void testAddNonEmptyGrandChild() throws CommitFailedException { Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); Tree child = rootTree.addChild("child"); child.setProperty("childProperty", 1); Tree grandChild = child.addChild("grandChild"); grandChild.setProperty("grandChildProperty", 2); root.commit(); ChangeSet changeSet = getSingleChangeSet(); 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"); }
@Test public void testRemoveGreatGrandChild() throws CommitFailedException { Root root = session.getLatestRoot(); Tree rootTree = root.getTree("/test"); assertTrue(rootTree.getChild("child1").getChild("grandChild1").getChild("greatGrandChild1").remove()); root.commit(); ChangeSet changeSet = getSingleChangeSet(); assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child1/grandChild1/greatGrandChild1", "/test/child1/grandChild1"); 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"); }
@Test public void basicMerge() throws Exception{ ChangeSetBuilder cb1 = new ChangeSetBuilder(5, 2); add(cb1, "1"); ChangeSetBuilder cb2 = new ChangeSetBuilder(5, 2); add(cb2, "2"); ChangeSet cs = cb1.add(cb2.build()).build(); assertThat(cs.getAllNodeTypes(), containsInAnyOrder("nt-1", "nt-2")); assertThat(cs.getParentPaths(), containsInAnyOrder("p-1", "p-2")); assertThat(cs.getParentNodeNames(), containsInAnyOrder("nn-1", "nn-2")); assertThat(cs.getParentNodeTypes(), containsInAnyOrder("pnt-1", "pnt-2")); assertThat(cs.getPropertyNames(), containsInAnyOrder("pn-1", "pn-2")); }