@Override public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException { return getWrappedProperty().getAncestor(depth); }
/** * Test if getting the ancestor of negative depth throws an * <code>ItemNotFoundException</code>. * * @throws RepositoryException */ public void testGetAncestorOfNegativeDepth() throws RepositoryException { try { property.getAncestor(-1); fail("Getting ancestor of depth < 0 must throw an ItemNotFoundException."); } catch (ItemNotFoundException e) { // success } }
/** * Test if getting the ancestor of depth = n, where n is greater than depth * of this <code>Property</code>, throws an <code>ItemNotFoundException</code>. * * @throws RepositoryException */ public void testGetAncestorOfGreaterDepth() throws RepositoryException { try { int greaterDepth = property.getDepth() + 1; property.getAncestor(greaterDepth); fail("Getting ancestor of depth n, where n is greater than depth of" + "this Property must throw an ItemNotFoundException"); } catch (ItemNotFoundException e) { // success } }
/** * Test if the ancestor at depth = n, where n is the depth of this * <code>Item</code>, returns this <code>Property</code> itself. * * @throws RepositoryException */ public void testGetAncestorOfItemDepth() throws RepositoryException { Property propertyAtDepth = (Property) property.getAncestor(property.getDepth()); assertTrue("The ancestor of depth = n, where n is the depth of this " + "Property must be the item itself.", property.isSame(propertyAtDepth)); }
@Test public void secondAncestorOfPropertyShouldBeParentOfParentNode() throws Exception { assertThat(newPropertyOnModifiedNode.getAncestor(2), is((Item)newPropertyOnModifiedNode)); assertThat(modifiedPropertyOnModifiedNode.getAncestor(2), is((Item)modifiedPropertyOnModifiedNode)); assertThat(unmodifiedPropertyOnModifiedNode.getAncestor(2), is((Item)unmodifiedPropertyOnModifiedNode)); }
@Test public void zerothAncestorOfPropertyShouldBeRootNode() throws Exception { assertThat(newPropertyOnModifiedNode.getAncestor(0), is((Item)rootNode)); assertThat(modifiedPropertyOnModifiedNode.getAncestor(0), is((Item)rootNode)); assertThat(unmodifiedPropertyOnModifiedNode.getAncestor(0), is((Item)rootNode)); }
@Test public void firstAncestorOfPropertyShouldBeParentNode() throws Exception { assertThat(newPropertyOnModifiedNode.getAncestor(1), is((Item)nodeWithModifiedProperty)); assertThat(modifiedPropertyOnModifiedNode.getAncestor(1), is((Item)nodeWithModifiedProperty)); assertThat(unmodifiedPropertyOnModifiedNode.getAncestor(1), is((Item)nodeWithModifiedProperty)); }
public void testRevertInvalidatedMovedTree() throws RepositoryException { superuser.refresh(false); try { childNode.getAncestor(0); fail("Reverting move of a new node must remove the tree completely"); } catch (RepositoryException e) { // OK } try { childProperty.getAncestor(0); fail("Reverting move of a new node must remove the tree completely"); } catch (RepositoryException e) { // OK } try { grandChildNode.getAncestor(0); fail("Reverting move of a new node must remove the tree completely"); } catch (RepositoryException e) { // OK } }
public void testTreeAncestors() throws RepositoryException { int degree = destParentNode.getDepth(); Item ancestor = childNode.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); ancestor = childProperty.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); ancestor = grandChildNode.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); }
public void testTreeAncestors() throws RepositoryException { int degree = destParentNode.getDepth(); Item ancestor = childNode.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); ancestor = childProperty.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); ancestor = grandChildNode.getAncestor(degree); assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode)); }