AbstractJcrItem implements Item, Namespaced { @Override public int getDepth() throws RepositoryException { checkSession(); return path().size(); } protected  AbstractJcrItem( JcrSession session ); @Override Item getAncestor( int depth ); @Override int getDepth(); @Override abstract AbstractJcrNode getParent();  }
@Test public void shouldReportCorrectDepthForNodes() throws Exception { assertThat(rootNode.getDepth(), is(0)); assertThat(savedNode.getDepth(), is(1)); assertThat(newNode.getDepth(), is(1)); assertThat(nodeWithModifiedProperty.getDepth(), is(1)); assertThat(nodeWithModifiedChildren.getDepth(), is(1)); assertThat(nodeOfDepth2.getDepth(), is(2)); }