### Question:
ChildPath extends AbstractPath { public Path getAncestor( int degree ) { CheckArg.isNonNegative(degree, "degree"); if (degree == 0) return this; if (degree == 1) return parent; return parent.getAncestor(degree - 1); } ChildPath( Path parent,
                      Path.Segment child ); Path getAncestor( int degree ); @Override Segment getLastSegment(); @Override Path getParent(); @Override Segment getSegment( int index ); List<Segment> getSegmentsList(); @Override boolean hasSameAncestor( Path that ); boolean isAbsolute(); @Override boolean isAtOrBelow( Path other ); @Override boolean isDecendantOf( Path ancestor ); boolean isNormalized(); boolean isRoot(); @Override @SuppressWarnings( "synthetic-access" ) Iterator<Segment> iterator(); int size(); @Override Path subpath( int beginIndex,
                         int endIndex );  }### Answer:
@Test public void shouldDelegateToParentForAncestorOfDegreeGreaterThanOne() { parent = mock(Path.class); when(parent.getAncestor(anyInt())).thenReturn(null); path = new ChildPath(parent, segment("d")); for (int i = 2; i != 10; ++i) { path.getAncestor(i); verify(parent).getAncestor(i - 1); } }