assertThat(path1.getCommonAncestor(path2), is(common));
}
@Test
public void shouldConsiderNodeToBeAncestorOfEveryDecendantNode() {
Path path1 = pathFactory.create("/a/y/z");
Path path2 = pathFactory.create("/a/b/c");
Path path3 = pathFactory.create("/x/b/c");
Path path4 = pathFactory.create("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z");
Path common = pathFactory.create("/a");
assertThat(common.isAncestorOf(path1), is(true));
assertThat(common.isAncestorOf(path2), is(true));
assertThat(common.isAncestorOf(path3), is(false));
assertThat(path1.getParent().isAncestorOf(path1), is(true));
for (int i = 1; i < path1.size(); ++i) {
assertThat(path1.getAncestor(i).isAncestorOf(path1), is(true));
}