Examples of TestUElementComposite


Examples of etherstrategy.simulation.TestUElementComposite

        LinkedList<UniverseElement> testCollection =
            new LinkedList<UniverseElement>();
        testCollection.add( new TestUElement() );
        testCollection.add(testElement);
        testCollection.add( new TestUElementComposite() );

        try
        {
            testElement.addAll( testCollection );
            fail("Adding a collection with a reference to the UniverseElementComposite it is being added to, and other valid elements, should throw an IllegalArgumentException due to the self reference, but did not.");
        }
        catch ( IllegalArgumentException e )
        {
        }
        catch ( Exception e )
        {
            fail("Adding a collection with a reference to the UniverseElementComposite it is being added to should throw only an IllegalArgumentException, but a(n) " + e.getClass().getName() + " exception was thrown.");
        }
       
        assertTrue(
                "After failing to add a collection containing a reference to the UniverseElementComposite to which it was being added, the UniverseElementComposite should not have changed.",
                testElement.size() == 1
                && testElement.contains( element1 ) );

        testCollection.clear();
        testCollection.add( new TestUElementComposite() );
        testCollection.add( new TestUElement() );
        testCollection.add( testElement );

        try
        {
            testElement.addAll( testCollection );
            fail("Adding a collection with valid elements and a reference to the UniverseElementComposite to which it is being added as the last element should throw an IllegalArgumentException due to the self reference, but did not.");
        }
        catch ( IllegalArgumentException e )
        {
        }
        catch ( Exception e )
        {
            fail("Adding a collection with a reference to the UniverseElementComposite it is being added to as the last element in the collection should throw only an IllegalArgumentException, but a(n) " + e.getClass().getName() + " exception was thrown.");
        }

        assertTrue(
                "After failing to add a collection containing a reference to the UniverseElementComposite to which it was being added, the UniverseElementComposite should not have changed.",
                testElement.size() == 1
                && testElement.contains(element1) );

        testCollection.clear();
        testCollection.add( testElement );
        testCollection.add( new TestUElement() );
        testCollection.add( new TestUElementComposite() );

        try
        {
            testElement.addAll( testCollection );
            fail("Adding a collection with valid elements and a reference to the UniverseElementComposite to which it is being added as the first element should throw an IllegalArgumentException due to the self reference, but did not.");
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

                && testElement.contains( element1 ) );

        testCollection.clear();
        testCollection.add( new TestUElement() );
        testCollection.add( null );
        testCollection.add( new TestUElementComposite() );

        try
        {
            testElement.addAll( testCollection );
            fail("Adding a collection with a null reference and other valid elements should throw a NullPointerException due to the null reference, but did not.");
        }
        catch ( NullPointerException e )
        {
        }
        catch ( Exception e )
        {
            fail("Adding a collection containing a null to a UniverseElementComposite should throw only a NullPointerException, but a(n) " + e.getClass().getName() + " exception was thrown.");
        }

        assertTrue(
                "After failing to add a collection with a null reference to a UniverseElementComposite, the UniverseElementComposite should not have changed.",
                testElement.size() == 1
                && testElement.contains( element1 ) );

        testCollection.clear();
        testCollection.add( new TestUElementComposite() );
        testCollection.add( new TestUElement() );
        testCollection.add( null );

        try
        {
            testElement.addAll( testCollection );
            fail("Adding a collection with valid elements and a null reference as the last element should throw a NullPointerException due to the null reference, but did not.");
        }
        catch ( NullPointerException e )
        {
        }
        catch ( Exception e )
        {
            fail("Adding a collection containing a null reference as the last element to a UniverseElementComposite should throw only a NullPointerException, but a(n) " + e.getClass().getName() + " exception was thrown.");
        }

        assertTrue(
                "After failing to add a collection with a null reference to a UniverseElementComposite, the UniverseElementComposite should not have changed.",
                testElement.size() == 1
                && testElement.contains( element1 ) );

        testCollection.clear();
        testCollection.add( null );
        testCollection.add( new TestUElementComposite() );
        testCollection.add( new TestUElement() );

        try
        {
            testElement.addAll( testCollection );
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<Object>();
        LinkedList<Object> emptyCollection =
            new LinkedList<Object>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();

        testCollection.add(element1);
        testCollection.add(element2);
       
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<Object>();
        LinkedList<Object> emptyCollection =
            new LinkedList<Object>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();
        TestUElement element4 = new TestUElement();

        testCollection.add(element1);
        testCollection.add(element2);
       
        assertFalse(
                "Removing an empty collection from an empty UniverseElementComposite should return false (nothing changed).",
                testElement.removeAll( emptyCollection ) );

        assertTrue(
                "After removing an empty collection from an empty UniverseElementComposite, the UniverseElementComposite should still be empty.",
                testElement.isEmpty() );

        assertFalse(
                "Removing a non-empty collection from an empty UniverseElementComposite should return false (nothing changed).",
                testElement.removeAll( testCollection ) );

        assertTrue(
                "After removing a non-empty collection from an empty UniverseElementComposite, the UniverseElementComposite should still be empty.",
                testElement.isEmpty() );

        testElement.add(element3);
       
        assertFalse(
                "Removing a non-empty collection from a non-empty UniverseElementComposite, when the collection and the UniverseElementComposite have no children in common, should return false (nothing changed).",
                testElement.removeAll( testCollection ) );

        assertTrue(
                "After removing a non-empty collection from a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite have no children in common, the UniverseElementComposite should not have changed.",
                testElement.contains( element3 ) && (testElement.size() == 1));

        testElement.add( element2 );
        testElement.add( element1 );

        testCollection.add( element4 );

        assertTrue(
                "Before removal through removeAll, elements should report that they are contained.",
                element1.isContained()
                && element2.isContained()
                && element3.isContained() );

        assertTrue(
                "Removing a non-empty collection from a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite have children in common, should return true (something changed).",
                testElement.removeAll( testCollection ) );
       
        assertFalse(
                "After removing a non-empty collection from a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite had children in common, the children that were common to both collections should no longer be present in the UniverseElementComposite.",
                testElement.contains( element1 )
                || testElement.contains( element2 ) );
       
        assertFalse(
                "After removing elements using removeAll, the removed elements should not report that they are contained.",
                element1.isContained()
                || element2.isContained() );

        assertTrue(
                "After removing a non-empty collection from a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite had children in common, the children that were in the UniverseElementComposite and not common to both collections should still be present in the UniverseElementComposite.",
                testElement.contains(element3) );
       
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<Object>();
        LinkedList<UniverseElement> checkCollection =
            new LinkedList<UniverseElement>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();
        TestUElement element4 = new TestUElement();

        checkCollection.add( element1 );
        checkCollection.add( element2 );
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<UniverseElement>();
        LinkedList<UniverseElement> checkCollection =
            new LinkedList<UniverseElement>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();
        TestUElement element4 = new TestUElement();

        checkCollection.add( element1 );
        checkCollection.add( element2 );
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<Object>();
        LinkedList<Object> emptyCollection =
            new LinkedList<Object>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();
        TestUElement element4 = new TestUElement();

        testCollection.add(element1);
        testCollection.add(element2);
       
        assertFalse(
                "Retaining an empty collection in an empty UniverseElementComposite should return false (nothing changed).",
                testElement.retainAll( emptyCollection ) );

        assertTrue(
                "After retaining an empty collection in an empty UniverseElementComposite, the UniverseElementComposite should still be empty.",
                testElement.isEmpty() );

        assertFalse(
                "Retaining a non-empty collection in an empty UniverseElementComposite should return false (nothing changed).",
                testElement.retainAll( testCollection ) );

        assertTrue(
                "After retaining a non-empty collection in an empty UniverseElementComposite, the UniverseElementComposite should still be empty.",
                testElement.isEmpty() );

        testElement.add(element3);
       
        assertTrue(
                "Retaining a non-empty collection in a non-empty UniverseElementComposite, when the collection and the UniverseElementComposite have no children in common, should return true.",
                testElement.retainAll( testCollection ) );

        assertTrue(
                "After retaining a non-empty collection in a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite have no children in common, the UniverseElementComposite should be empty.",
                testElement.isEmpty() );

        testElement.add( element2 );
        testElement.add( element1 );

        assertFalse(
                "Retaining a non-empty collection in a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite have only children in common, should return false (nothing changed).",
                testElement.retainAll( testCollection ) );
       
        assertTrue(
                "After retaining a non-empty collection in a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite had only children in common, the children that were common to both collections should still be present in the UniverseElementComposite.",
                testElement.contains( element1 )
                && testElement.contains( element2 ) );

        testElement.add( element3 );
        testCollection.add( element4 );

        assertTrue(
                "Before removal through retainAll, elements should report that they are contained.",
                element1.isContained()
                && element2.isContained()
                && element3.isContained() );

        assertTrue(
                "Retaining a non-empty collection in a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite have some children in common, but the UniverseElementComposite has elements that are not common to the collection, should return true.",
                testElement.retainAll( testCollection ) );
       
        assertTrue(
                "After retaining a non-empty collection in a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite had some children in common, the children that were common to both collections should still be present in the UniverseElementComposite.",
                testElement.contains( element1 )
                && testElement.contains( element2 ) );

        assertTrue(
                "After removing elements using retainAll, elements that were not removed (but were originally contained) should still report that they are contained.",
                element1.isContained()
                && element2.isContained() );

        assertFalse(
                "After retaining a non-empty collection in a non-empty UniverseElementComposite, where the collection and the UniverseElementComposite had children in common, the children that were in the UniverseElementComposite and not common to both collections should still not present in the UniverseElementComposite.",
                testElement.contains(element3) );
       
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<Object>();
        LinkedList<UniverseElement> checkCollection =
            new LinkedList<UniverseElement>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();
        TestUElement element4 = new TestUElement();

        checkCollection.add( element1 );
        checkCollection.add( element2 );
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

            new LinkedList<UniverseElement>();
        LinkedList<UniverseElement> checkCollection =
            new LinkedList<UniverseElement>();

        TestUElement element1 = new TestUElement();
        TestUElementComposite element2 = new TestUElementComposite();
        TestUElement element3 = new TestUElement();
        TestUElement element4 = new TestUElement();

        checkCollection.add( element1 );
        checkCollection.add( element2 );
View Full Code Here

Examples of etherstrategy.simulation.TestUElementComposite

        catch ( Exception e )
        {
            fail("Attempting to iterate to the next element in an empty UniverseElementComposite should only throw a NoSuchElementException, but a(n) " + e.getClass().getName() + " was thrown.");
        }

        testElement.add( new TestUElementComposite() );
        testElement.add( new TestA() );
        testElement.add( new TestC() );
        testElement.add( new TestDerivedFromC() );
        testElement.add( new TestA() );
        testElement.add( new TestB() );
        testElement.add( new TestA() );
        testElement.add( new TestUElement() );
        testElement.add( new TestUElementComposite() );

        testIter = testElement.iterator();

        try
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.