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) );