use of com.puppycrawl.tools.checkstyle.xpath.iterators.DescendantIterator in project checkstyle by checkstyle.
the class ElementNodeTest method testIterateAxisWithChildren.
@Test
public void testIterateAxisWithChildren() {
final DetailAstImpl detailAST = new DetailAstImpl();
detailAST.setType(TokenTypes.METHOD_DEF);
final DetailAstImpl childAst = new DetailAstImpl();
childAst.setType(TokenTypes.VARIABLE_DEF);
detailAST.addChild(childAst);
final ElementNode elementNode = new ElementNode(rootNode, rootNode, detailAST, 1, 0);
try (AxisIterator iterator = elementNode.iterateAxis(AxisInfo.CHILD)) {
assertWithMessage("Invalid iterator").that(iterator instanceof ArrayIterator).isTrue();
}
try (AxisIterator iterator = elementNode.iterateAxis(AxisInfo.DESCENDANT)) {
assertWithMessage("Invalid iterator").that(iterator instanceof DescendantIterator).isTrue();
}
}
Aggregations