AstNode { @Override public String toString() { StringBuilder result = new StringBuilder(); result.append(name); if (token != null) { result.append(" tokenValue='").append(token.getValue()).append("'"); result.append(" tokenLine=").append(token.getLine()); result.append(" tokenColumn=").append(token.getColumn()); } return result.toString(); } AstNode(Token token);  AstNode(AstNodeType type, String name, @Nullable Token token); AstNode getParent(); void addChild(AstNode child); boolean hasChildren(); List<AstNode> getChildren(); int getNumberOfChildren(); @Deprecated AstNode getChild(int index); @Deprecated AstNode nextAstNode(); AstNode getNextAstNode(); @Deprecated AstNode previousAstNode(); AstNode getPreviousAstNode(); @Deprecated AstNode nextSibling(); AstNode getNextSibling(); @Deprecated AstNode previousSibling(); AstNode getPreviousSibling(); String getTokenValue(); String getTokenOriginalValue(); Token getToken(); int getTokenLine(); boolean hasToken(); String getName(); int getFromIndex(); void setFromIndex(int fromIndex); int getToIndex(); boolean hasToBeSkippedFromAst(); void setToIndex(int toIndex); boolean is(AstNodeType... types); boolean isNot(AstNodeType... types); @Deprecated AstNode findFirstDirectChild(AstNodeType... nodeTypes); AstNode getFirstChild(AstNodeType... nodeTypes); @Deprecated AstNode findFirstChild(AstNodeType... nodeTypes); AstNode getFirstDescendant(AstNodeType... nodeTypes); AstNode getFirstChild(); @Deprecated List<AstNode> findDirectChildren(AstNodeType... nodeTypes); List<AstNode> getChildren(AstNodeType... nodeTypes); @Deprecated List<AstNode> findChildren(AstNodeType... nodeTypes); List<AstNode> getDescendants(AstNodeType... nodeTypes); AstNode getLastChild(); @Nullable AstNode getLastChild(AstNodeType... nodeTypes); boolean hasDirectChildren(AstNodeType... nodeTypes); @Deprecated boolean hasChildren(AstNodeType... nodeTypes); boolean hasDescendant(AstNodeType... nodeTypes); @Deprecated boolean hasParents(AstNodeType nodeType); boolean hasParent(AstNodeType... nodeTypes); boolean hasAncestor(AstNodeType nodeType); boolean hasAncestor(AstNodeType... nodeTypes); @Deprecated AstNode findFirstParent(AstNodeType nodeType); AstNode getFirstAncestor(AstNodeType nodeType); AstNode getFirstAncestor(AstNodeType... nodeTypes); boolean isCopyBookOrGeneratedNode(); AstNodeType getType(); List<Token> getTokens(); @Override String toString(); Token getLastToken(); @Deprecated AstSelect select();  }
@Test public void test_toString() { Token token = mock(Token.class); when(token.getValue()).thenReturn("foo"); when(token.getLine()).thenReturn(42); when(token.getColumn()).thenReturn(24); AstNode node = new AstNode(mock(AstNodeType.class), "node_name", token); assertThat(node.toString()).isEqualTo("node_name tokenValue='foo' tokenLine=42 tokenColumn=24"); node = new AstNode(mock(AstNodeType.class), "node_name", null); assertThat(node.toString()).isEqualTo("node_name"); }