Package barsuift.simLife.tree

Examples of barsuift.simLife.tree.MockTreeLeaf



public class TreeGrowthTest extends TestCase {

    public void testExecuteCyclicStep() {
        MockTreeLeaf mockLeaf = new MockTreeLeaf();

        MockTreeBranchPart mockBranchPart = new MockTreeBranchPart();
        mockBranchPart.addLeaf(mockLeaf);

        MockTreeBranch mockBranch = new MockTreeBranch();
        mockBranch.addPart(mockBranchPart);

        MockTree mockTree = new MockTree();
        mockTree.addBranch(mockBranch);

        TreeGrowth treeGrowth = new TreeGrowth(UtilDataCreatorForTests.createSpecificConditionalTaskState(), mockTree);
        treeGrowth.executeConditionalStep();

        assertEquals(1, mockLeaf.getNbImproveEfficiencyCalled());

        assertEquals(1, mockBranchPart.getNbGrowCalled());
    }
View Full Code Here


            treeLeaf3D.deleteSubscriber(treeLeaf);
            assertEquals(0, treeLeaf3D.countSubscribers());

        }

        MockTreeLeaf treeLeaf = new MockTreeLeaf();
        gravity.addFallingLeaf(treeLeaf);
        assertEquals(3, gravity.getFallingLeaves().size());
        assertEquals(3, gravity.getGravity3D().getGroup().numChildren());
        // gravity is subscriber of the leaf
        assertEquals(1, treeLeaf.countSubscribers());
        treeLeaf.deleteSubscriber(gravity);
        // assert the gravity is really one of the subscribers of the leaf
        assertEquals(0, treeLeaf.countSubscribers());
    }
View Full Code Here

        assertEquals(0, treeLeaf.countSubscribers());
    }

    public void testUpdate() {
        BasicGravity gravity = new BasicGravity(gravityState, universe);
        MockTreeLeaf treeLeaf = new MockTreeLeaf();

        gravity.addFallingLeaf(treeLeaf);
        assertTrue(gravity.getFallingLeaves().contains(treeLeaf));
        assertFalse(universe.getFallenLeaves().contains(treeLeaf));
        assertEquals(1, gravity.getGravity3D().getGroup().numChildren());
View Full Code Here

        BasicGravity gravity = new BasicGravity(gravityState, universe);

        assertEquals(gravityState, gravity.getState());
        assertSame(gravityState, gravity.getState());
        assertEquals(0, gravity.getState().getFallingLeaves().size());
        gravity.addFallingLeaf(new MockTreeLeaf());
        assertEquals(gravityState, gravity.getState());
        assertSame(gravityState, gravity.getState());
        assertEquals(1, gravity.getState().getFallingLeaves().size());
    }
View Full Code Here

    }

    public void testInitFromUniverse() {
        BasicUniverse3D universe3D = new BasicUniverse3D(new Universe3DState(), new MockUniverse());
        Universe universe = new MockUniverse();
        MockTreeLeaf treeLeaf = new MockTreeLeaf();
        treeLeaf.setState(CoreDataCreatorForTests.createSpecificTreeLeafState());
        universe.addFallenLeaf(treeLeaf);
        MockTree tree = new MockTree();
        tree.setState(CoreDataCreatorForTests.createSpecificTreeState());
        universe.addTree(tree);
        universe3D.initFromUniverse(universe);

        assertTrue(universe3D.getElements3D().contains(universe.getEnvironment().getEnvironment3D().getGroup()));
        assertTrue(universe3D.getElements3D().contains(universe.getPhysics().getPhysics3D().getGroup()));

        Set<Node> elements3d = universe3D.getElements3D();
        assertNotNull(elements3d);
        assertEquals(4, elements3d.size());
        // the 3D node is added to a transform group, itself added to a branch group
        // that's why i test the parent of the parent
        // TODO 050. 032. the test will need to be fixed then
        assertTrue(elements3d.contains(tree.getTree3D().getBranchGroup().getParent().getParent()));
        assertTrue(elements3d.contains(treeLeaf.getTreeLeaf3D().getBranchGroup()));

    }
View Full Code Here

    public void testAddElement3D() {
        BasicUniverse3D universe3D = new BasicUniverse3D(new Universe3DState(), new MockUniverse());
        TreeLeaf3DStateFactory stateFactory = new TreeLeaf3DStateFactory();
        TreeLeaf3DState leaf3dState = stateFactory.createRandomTreeLeaf3DState(new Transform3D());
        BasicTreeLeaf3D treeLeaf3D = new BasicTreeLeaf3D(universe3D, leaf3dState, new MockTreeLeaf());
        universe3D.addElement3D(treeLeaf3D.getBranchGroup());
        Set<Node> elements3d = universe3D.getElements3D();
        assertNotNull(elements3d);
        assertEquals(1, elements3d.size());
        assertTrue(elements3d.contains(treeLeaf3D.getBranchGroup()));
View Full Code Here

    private MockUniverse3D mockUniverse3D;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        mockLeaf = new MockTreeLeaf();
        leaf3DState = DisplayDataCreatorForTests.createRandomTreeLeaf3DState();
        mockUniverse3D = new MockUniverse3D();
    }
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        mockBranchPart = new MockTreeBranchPart();
        nbLeaves = 5;
        for (int index = 0; index < nbLeaves; index++) {
            MockTreeLeaf mockLeaf = new MockTreeLeaf();
            mockLeaf.getTreeLeaf3D().getState().setTransform(DisplayDataCreatorForTests.createRandomTransform3DState());
            mockBranchPart.addLeaf(mockLeaf);
        }
        mockUniverse3D = new MockUniverse3D();
        part3DState = DisplayDataCreatorForTests.createRandomTreeBranchPart3DState();
    }
View Full Code Here

    }

    public void testInitFromUniverse() {
        BasicUniverse3D universe3D = new BasicUniverse3D();
        Universe universe = new MockUniverse();
        MockTreeLeaf treeLeaf = new MockTreeLeaf();
        treeLeaf.setState(CoreDataCreatorForTests.createSpecificTreeLeafState());
        universe.addFallenLeaf(treeLeaf);
        MockTree tree = new MockTree();
        tree.setState(CoreDataCreatorForTests.createSpecificTreeState());
        universe.addTree(tree);
        universe3D.initFromUniverse(universe);

        assertNotNull(universe3D.getLights());

        Set<Node> elements3d = universe3D.getElements3D();
        assertNotNull(elements3d);
        assertEquals(3, elements3d.size());
        // the 3D branch group is added to a transform group, itself added to a branch group
        // that's why i test the parent of the parent
        assertTrue(elements3d.contains(tree.getTree3D().getBranchGroup().getParent().getParent()));
        assertTrue(elements3d.contains(treeLeaf.getTreeLeaf3D().getBranchGroup().getParent().getParent()));

    }
View Full Code Here

    public void testAddElement3D() {
        BasicUniverse3D universe3D = new BasicUniverse3D();
        TreeLeaf3DStateFactory stateFactory = new TreeLeaf3DStateFactory();
        Point3d leafAttachPoint = new Point3d(Math.random(), Math.random(), Math.random());
        TreeLeaf3DState leaf3dState = stateFactory.createRandomTreeLeaf3DState(leafAttachPoint);
        BasicTreeLeaf3D treeLeaf3D = new BasicTreeLeaf3D(universe3D, leaf3dState, new MockTreeLeaf());
        universe3D.addElement3D(treeLeaf3D.getBranchGroup());
        Set<Node> elements3d = universe3D.getElements3D();
        assertNotNull(elements3d);
        assertEquals(1, elements3d.size());
        assertTrue(elements3d.contains(treeLeaf3D.getBranchGroup()));
View Full Code Here

TOP

Related Classes of barsuift.simLife.tree.MockTreeLeaf

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.