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

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


        assertThat(parent.getLastChild(), is(sameInstance(node)));
    }

    @Test
    public void shouldGetFirstChildAndLastChildWithTwoChildren() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        AstNode child2 = new AstNode(parent, name("childB"));
        assertThat(parent.getFirstChild(), is(sameInstance(child1)));
        assertThat(parent.getLastChild(), is(sameInstance(child2)));
    }
View Full Code Here


        assertThat(parent.getLastChild(), is(sameInstance(child2)));
    }

    @Test
    public void shouldGetFirstChildAndLastChildWithMoreThanTwoChildren() {
        parent = new AstNode(name("parent"));
        AstNode child1 = new AstNode(parent, name("childA"));
        new AstNode(parent, name("childB"));
        AstNode child3 = new AstNode(parent, name("childC"));
        assertThat(parent.getFirstChild(), is(sameInstance(child1)));
        assertThat(parent.getLastChild(), is(sameInstance(child3)));
    }
View Full Code Here

        assertThat(parent.getLastChild(), is(sameInstance(child3)));
    }

    @Test
    public void shouldGetFirstChildAndLastChildWithNoChildren() {
        parent = new AstNode(name("parent"));
        assertThat(parent.getFirstChild(), is(nullValue()));
        assertThat(parent.getLastChild(), is(nullValue()));
    }
View Full Code Here

        assertThat(parent.getLastChild(), is(nullValue()));
    }

    @Test
    public void shouldRemoveNodeFromExistingParentWhenSettingParentToNull() {
        parent = new AstNode(name("parent"));
        node = new AstNode(parent, name("child"));
        assertThat(parent.getFirstChild(), is(sameInstance(node)));
        assertThat(parent.getChildCount(), is(1));
        node.setParent(null);
        assertThat(parent.getChildCount(), is(0));
        assertThat(node.getParent(), is(nullValue()));
View Full Code Here

        assertThat(node.getParent(), is(nullValue()));
    }

    @Test
    public void shouldInsertNewParentNodeInBetweenExistingParentAndChild() {
        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.getFirstChild(), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(child2)));
        assertThat(parent.getLastChild(), is(sameInstance(child3)));
        assertThat(parent.getChildCount(), is(3));
        node = new AstNode(name("inserted"));
        child2.insertAsParent(node);
        assertThat(parent.getChildCount(), is(3));
        assertThat(parent.getFirstChild(), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(node)));
        assertThat(parent.getLastChild(), is(sameInstance(child3)));
View Full Code Here

        assertThat(child2.getParent(), is(sameInstance(node)));
    }

    @Test
    public void shouldInsertNewParentNodeInAboveNodeWithoutParent() {
        AstNode child1 = new AstNode(name("childA"));
        node = new AstNode(name("node"));
        AstNode nodeChild = new AstNode(node, name("child"));
        // Perform the insertAsParent ...
        child1.insertAsParent(node);
        assertThat(node.getParent(), is(nullValue()));
        assertThat(node.getChildCount(), is(2));
        assertThat(node.getFirstChild(), is(sameInstance(nodeChild)));
View Full Code Here

        assertThat(child1.getParent(), is(sameInstance(node)));
    }

    @Test
    public void shouldRemoveFromParentWhenThereIsAParent() {
        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"));
        AstNode grandChild21 = new AstNode(child2, name("grandChild21"));
        assertThat(parent.getFirstChild(), is(sameInstance(child1)));
        assertThat(parent.getChild(1), is(sameInstance(child2)));
        assertThat(parent.getLastChild(), is(sameInstance(child3)));
        assertThat(parent.getChildCount(), is(3));
        assertThat(child2.getFirstChild(), is(sameInstance(grandChild21)));
View Full Code Here

        assertThat(child2.getFirstChild(), is(sameInstance(grandChild21)));
    }

    @Test
    public void shouldRemoveFromParentWhenThereIsNoParent() {
        node = new AstNode(name("node"));
        AstNode child1 = new AstNode(node, name("child"));
        assertThat(node.getFirstChild(), is(sameInstance(child1)));
        assertThat(node.getChildCount(), is(1));
        // Perform the removeFromParent ...
        assertThat(node.removeFromParent(), is(nullValue()));
        assertThat(node.getFirstChild(), is(sameInstance(child1)));
View Full Code Here

        assertThat(node.getChildCount(), is(1));
    }

    @Test
    public void shouldReturnListOfChildren() {
        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"));
        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));
View Full Code Here

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

    @Test( expected = UnsupportedOperationException.class )
    public void shouldReturnImmutableListOfChildren() {
        parent = new AstNode(name("parent"));
        new AstNode(parent, name("childA"));
        new AstNode(parent, name("childB"));
        new AstNode(parent, name("childC"));
        parent.getChildren().clear();
    }
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.