@Test(expected = ItemNotFoundException.class) public void shouldFailToReturnAncestorWhenDepthIsGreaterThanNodeDepth() throws Exception { altimaModel.getAncestor(40); }
@Test public void shouldReturnSelfForAncestorOfDepthEqualToDepthOfNode() throws Exception { assertThat(altimaModel.getAncestor(altimaModel.getDepth()), is((Item) altimaModel)); assertThat(altimaModel.getAncestor(altimaModel.getDepth() - 1), is((Item) altima)); }
@Test public void shouldReturnRootForAncestorOfDepthZero() throws Exception { assertThat(altimaModel.getAncestor(0), is((Item) rootNode)); }
@Test public void shouldReturnAncestorAtLevelOneForAncestorOfDepthOne() throws Exception { assertThat(altimaModel.getAncestor(1), is((Item) cars)); }
@Test(expected = ItemNotFoundException.class) public void shouldNotAllowNegativeAncestorDepth() throws Exception { altimaModel.getAncestor(-1); }