AstNode implements Iterable<AstNode>, Cloneable { public List<AstNode> getChildren() { return childrenView; } AstNode( String name );  AstNode( AstNode parent,
                    String name ); boolean addMixin( final String mixin ); boolean hasMixin( final String mixin ); String getName(); String getPrimaryType(); int getSameNameSiblingIndex(); String getAbsolutePath(); Object getProperty( String name ); AstNode setProperty( String name,
                                Object value ); AstNode setProperty( String name,
                                Object... values ); Object removeProperty( String name ); List<String> getPropertyNames(); @SuppressWarnings( "unchecked" ) List<String> getMixins(); AstNode getParent(); void setParent( AstNode parent ); void insertAsParent( AstNode newParent ); AstNode removeFromParent(); boolean replaceChild( AstNode child,
                                 AstNode replacement ); int getChildCount(); AstNode getFirstChild(); AstNode getLastChild(); List<AstNode> childrenWithName( final String name ); AstNode getChild( int index ); void addFirstChild( AstNode child ); void addLastChild( AstNode child ); void addChildren( Iterable<AstNode> otherChildren ); void addChildren( AstNode first,
                             AstNode second ); void addChildren( AstNode first,
                             AstNode second,
                             AstNode third ); boolean removeChild( AstNode child ); void extractChild( AstNode child ); void extractFromParent(); List<AstNode> getChildren(); List<AstNode> getChildren( final String mixin ); @Override Iterator<AstNode> iterator(); List<AstNode> removeAllChildren(); boolean isSameAs( AstNode other ); @Override AstNode clone(); @Override String toString();  }
@Test public void shouldReturnListOfChildren() { parent = new AstNode("parent"); AstNode child1 = new AstNode(parent, "childA"); AstNode child2 = new AstNode(parent, "childB"); AstNode child3 = new AstNode(parent, "childC"); List<AstNode> children = parent.getChildren(); assertThat(children.get(0), is(sameInstance(child1))); assertThat(children.get(1), is(sameInstance(child2))); assertThat(children.get(2), is(sameInstance(child3))); assertThat(children.size(), is(3)); }
@Test( expected = UnsupportedOperationException.class ) public void shouldReturnImmutableListOfChildren() { parent = new AstNode("parent"); new AstNode(parent, "childA"); new AstNode(parent, "childB"); new AstNode(parent, "childC"); parent.getChildren().clear(); }