public void testGetNextSibling_SingleChild() { ICompositeNode rootNode = builder.newRootNode("input"); AbstractNode node = createNode(); builder.addChild(rootNode, node); assertFalse(node.hasNextSibling()); assertNull(node.getNextSibling()); }
public void testGetRootNode_Parent() { AbstractNode node = createNode(); ICompositeNode rootNode = builder.newRootNode("My input"); ICompositeNode parent = builder.newCompositeNode(null, 0, rootNode); builder.addChild(parent, node); assertSame(rootNode, node.getRootNode()); }
public void testTreeIterator_Bidi_NoParent() { AbstractNode node = createNode(); BidiIterator<INode> iterator = node.iterator(); assertSame(node, iterator.next()); assertTrue(iterator.hasPrevious()); assertSame(node, iterator.previous()); assertTrue(iterator.hasNext()); }
public void testGetNextSibling_LastChild() { ICompositeNode rootNode = builder.newRootNode("input"); AbstractNode first = createNode(); AbstractNode second = createNode(); builder.addChild(rootNode, first); builder.addChild(rootNode, second); assertFalse(second.hasNextSibling()); assertNull(second.getNextSibling()); }
public void testGetNextSibling_FirstChild() { ICompositeNode rootNode = builder.newRootNode("input"); AbstractNode first = createNode(); AbstractNode second = createNode(); builder.addChild(rootNode, first); builder.addChild(rootNode, second); assertTrue(first.hasNextSibling()); assertSame(second, first.getNextSibling()); }
public void testGetPreviousSibling_LastChild() { ICompositeNode rootNode = builder.newRootNode("input"); AbstractNode first = createNode(); AbstractNode second = createNode(); builder.addChild(rootNode, first); builder.addChild(rootNode, second); assertTrue(second.hasPreviousSibling()); assertSame(first, second.getPreviousSibling()); assertTrue(second.hasSiblings()); }
public void testTreeIterator_Bidi() { ICompositeNode rootNode = builder.newRootNode("input"); AbstractNode node = createNode(); builder.addChild(rootNode, node); BidiIterator<INode> iterator = node.iterator(); assertSame(node, iterator.next()); assertTrue(iterator.hasPrevious()); assertSame(node, iterator.previous()); assertTrue(iterator.hasNext()); }
public void testIterator_Previous() { AbstractNode node = createNode(); BidiIterator<INode> iterator = node.iterator(); assertTrue(iterator.hasPrevious()); assertSame(node, iterator.previous()); assertFalse(iterator.hasPrevious()); try { iterator.previous(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // ok } }
public void testTreeIterator_Next_NoParent() { AbstractNode node = createNode(); BidiIterator<INode> iterator = node.iterator(); assertTrue(iterator.hasNext()); assertSame(node, iterator.next()); assertFalse(iterator.hasNext()); try { iterator.next(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // ok } }
public void testTreeIterator_Previous() { ICompositeNode rootNode = builder.newRootNode("input"); AbstractNode node = createNode(); builder.addChild(rootNode, node); BidiIterator<INode> iterator = node.iterator(); assertTrue(iterator.hasPrevious()); assertSame(node, iterator.previous()); assertFalse(iterator.hasPrevious()); try { iterator.previous(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // ok } }
public void testGetRootNode_NoRoot() { AbstractNode node = createNode(); ICompositeNode parent = new CompositeNode(); builder.addChild(parent, node); assertNull(node.getRootNode()); }
public void testGetRootNode_NoParent() { AbstractNode node = createNode(); assertNull(node.getRootNode()); }
public void testGetRootNode() { AbstractNode node = createNode(); ICompositeNode rootNode = builder.newRootNode("My input"); builder.addChild(rootNode, node); assertSame(rootNode, node.getRootNode()); }
public void testGetParent() { AbstractNode node = createNode(); ICompositeNode parent = builder.newRootNode("input"); builder.addChild(parent, node); assertSame(parent, node.getParent()); }