Package de.ailis.jollada.model

Examples of de.ailis.jollada.model.Node


     */

    @Test(expected = IllegalStateException.class)
    public void testAddChildAlreadyExists()
    {
        final Node parent = new Node();
        final Node child = new Node();
        parent.addChild(child);
        parent.addChild(child);
    }
View Full Code Here


     */

    @Test
    public void testRemoveChild()
    {
        final Node parent = new Node();
        final Node child = new Node();
        child.setId("ID");
        child.setSid("SID");

        // Add child to parent
        parent.addChild(child);
        assertSame(child, parent.getBySid("SID"));

View Full Code Here

     */

    @Test(expected = IllegalStateException.class)
    public void testAddChildNotExists()
    {
        final Node parent = new Node();
        final Node child = new Node();
        parent.removeChild(child);
    }
View Full Code Here

    @Test
    public void testSetId()
    {
        final Document document = new Document();
        final Node node = new Node();
        node.setDocument(document);

        assertNull(document.getById("ID"));

        node.setId("ID");
        assertSame(node, document.getById("ID"));
        node.setId("ID");
        assertSame(node, document.getById("ID"));

        node.setId(null);
        assertNull(document.getById("ID"));
        node.setId(null);
        assertNull(document.getById("ID"));
    }
View Full Code Here

     */

    @Test(expected = IllegalArgumentException.class)
    public void testAddElementListener()
    {
        new Node().addElementListener(null);
    }
View Full Code Here

     */

    @Test(expected = IllegalArgumentException.class)
    public void testRemoveElementListener()
    {
        new Node().removeElementListener(null);
    }
View Full Code Here

     */

    @Test
    public void testRemoveElementListenerNotExists()
    {
        new Node().removeElementListener(new ElementAdapter()
        {
            private static final long serialVersionUID = 1L;
        });
    }
View Full Code Here

     */

    @Test
    public void testElementEvents()
    {
        final Node node = new Node();

        class TestAdapter extends ElementAdapter
        {
            private static final long serialVersionUID = -6339447807055123781L;

            public boolean removedFromDoc = false;

            public boolean insertedIntoDoc = false;

            public boolean inserted = false;

            public boolean removed = false;

            @Override
            public void elementRemovedFromDocument(final Element element)
            {
                this.removedFromDoc = true;
            }

            @Override
            public void elementRemoved(final Element element)
            {
                this.removed = true;
            }

            @Override
            public void elementInsertedIntoDocument(final Element element)
            {
                this.insertedIntoDoc = true;
            }

            @Override
            public void elementInserted(final Element element)
            {
                this.inserted = true;
            }

            public void reset()
            {
                this.removed = false;
                this.inserted = false;
                this.removedFromDoc = false;
                this.insertedIntoDoc = false;
            }
        }
        final TestAdapter adapter = new TestAdapter();
        node.addElementListener(adapter);
        assertFalse(adapter.inserted);
        assertFalse(adapter.insertedIntoDoc);
        assertFalse(adapter.removed);
        assertFalse(adapter.removedFromDoc);

        final Document doc = new Document();
        final Node parent1 = new Node();
        doc.addChild(parent1);
        final Node parent2 = new Node();
        doc.addChild(parent2);

        parent1.addChild(node);
        assertTrue(adapter.inserted);
        assertTrue(adapter.insertedIntoDoc);
        assertFalse(adapter.removed);
        assertFalse(adapter.removedFromDoc);
        adapter.reset();

        parent2.addChild(node);
        assertTrue(adapter.inserted);
        assertFalse(adapter.insertedIntoDoc);
        assertTrue(adapter.removed);
        assertFalse(adapter.removedFromDoc);
        adapter.reset();

        parent2.removeChild(node);
        assertFalse(adapter.inserted);
        assertFalse(adapter.insertedIntoDoc);
        assertTrue(adapter.removed);
        assertTrue(adapter.removedFromDoc);
    }
View Full Code Here

     */

    @Test
    public void testGetBySid()
    {
        final Node root = new Node();
        final Node node1a = new Node();
        final Node node1b = new Node();
        final Node node2a = new Node();
        final Node node2b = new Node();
        node2b.setSid("foo");
        final Node node3a = new Node();
        node3a.setSid("foo");
        final Node node3b = new Node();

        root.addChild(node1a);
        root.addChild(node1b);
        node1a.addChild(node2a);
        node1b.addChild(node2b);
View Full Code Here

     */

    @Test
    public void testConstructor()
    {
        final Node parent = new Node();
        final Elements<Node> elements = new Nodes(parent);

        final Node node = new Node();
        elements.add(node);
        assertSame(parent, node.getParent());
    }
View Full Code Here

TOP

Related Classes of de.ailis.jollada.model.Node

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.