Package org.jboss.dna.sequencer.ddl.node

Examples of org.jboss.dna.sequencer.ddl.node.AstNode


        parent.getChildren().clear();
    }

    @Test
    public void shouldReturnIteratorOfChildren() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        Iterator<AstNode> children = parent.iterator();
        assertThat(children.next(), is(sameInstance(child1)));
        assertThat(children.next(), is(sameInstance(child2)));
        assertThat(children.next(), is(sameInstance(child3)));
        assertThat(children.hasNext(), is(false));
View Full Code Here


        assertThat(children.hasNext(), is(false));
    }

    @Test( expected = UnsupportedOperationException.class )
    public void shouldReturnImmutableIteratorOfChildren() {
        parent = new AstNode(name("parent"));
        new AstNode(parent, name("childA"));
        new AstNode(parent, name("childB"));
        new AstNode(parent, name("childC"));
        Iterator<AstNode> iter = parent.iterator();
        iter.next();
        iter.remove();
    }
View Full Code Here

        iter.remove();
    }

    @Test
    public void shouldRemoveAllChildrenOfParentWithNoChildrenByReturningEmptyList() {
        parent = new AstNode(name("parent"));
        // Perform the remove, and verify the list has all the children ...
        List<AstNode> children = parent.removeAllChildren();
        assertThat(children.size(), is(0));
        assertThat(parent.getChildCount(), is(0));
        // Add a new child to the parent ...
        AstNode child1a = new AstNode(parent, name("child1A"));
        assertThat(parent.getFirstChild(), is(sameInstance(child1a)));
        // The returned copy should not be modified ...
        assertThat(children.size(), is(0));
    }
View Full Code Here

        assertThat(children.size(), is(0));
    }

    @Test
    public void shouldRemoveAllChildrenAndReturnCopyOfListOfChildren() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        // Perform the remove, and verify the list has all the children ...
        List<AstNode> children = parent.removeAllChildren();
        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));
        assertThat(parent.getChildCount(), is(0));
        // Add a new child to the parent ...
        AstNode child1a = new AstNode(parent, name("child1A"));
        assertThat(parent.getFirstChild(), is(sameInstance(child1a)));
        // The returned copy should not be modified ...
        assertThat(children.get(0), is(sameInstance(child1)));
        assertThat(children.get(1), is(sameInstance(child2)));
        assertThat(children.get(2), is(sameInstance(child3)));
View Full Code Here

        assertThat(children.size(), is(3));
    }

    @Test
    public void shouldReturnCorrectChildCount() {
        parent = new AstNode(name("parent"));
        assertThat(parent.getChildCount(), is(0));
        for (int i = 0; i != 10; ++i) {
            new AstNode(parent, name("child"));
            assertThat(parent.getChildCount(), is(i + 1));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void shouldAddChildrenAtEnd() {
        parent = new AstNode(name("parent"));
        List<AstNode> children = new ArrayList<AstNode>();
        children.add(new AstNode(parent, name("child")));
        children.add(new AstNode(parent, name("child")));
        children.add(new AstNode(parent, name("child")));
        parent.addChildren(children);
        int index = 0;
        for (AstNode child : children) {
            assertThat(parent.getChild(index++), is(sameInstance(child)));
        }
View Full Code Here

        }
    }

    @Test
    public void shouldRemoveChild() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        assertThat(parent.getChild(0), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(child2)));
        assertThat(parent.getChild(2), is(sameInstance(child3)));
        // Perform the remove, and verify children have changed ...
        assertThat(parent.removeChild(child2), is(true));
View Full Code Here

        assertThat(parent.getChild(1), is(sameInstance(child3)));
    }

    @Test
    public void shouldNotRemoveChildIfNotReallyAChild() {
        node = new AstNode(name("node"));
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        assertThat(parent.getChild(0), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(child2)));
        assertThat(parent.getChild(2), is(sameInstance(child3)));
        // Try to remove the non-child, and verify the children have no changed ...
        assertThat(parent.removeChild(node), is(false));
View Full Code Here

        assertThat(parent.getChild(2), is(sameInstance(child3)));
    }

    @Test
    public void shouldNotRemoveChildIfReferenceIsNull() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        assertThat(parent.getChild(0), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(child2)));
        assertThat(parent.getChild(2), is(sameInstance(child3)));
        // Try to remove the non-child, and verify the children have no changed ...
        assertThat(parent.removeChild(null), is(false));
View Full Code Here

        assertThat(parent.getChild(2), is(sameInstance(child3)));
    }

    @Test
    public void shouldExtractChildByRemovingIfChildHasNoChildren() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        assertThat(parent.getChild(0), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(child2)));
        assertThat(parent.getChild(2), is(sameInstance(child3)));
        // Perform the extraction ...
        parent.extractChild(child2);
View Full Code Here

TOP

Related Classes of org.jboss.dna.sequencer.ddl.node.AstNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.