@Test
public void testRetainAll()
{
final Document document = new Document();
final Node parent = new Node();
document.addChild(parent);
final Elements<Node> elements = new Nodes(parent);
final Node child = new Node();
child.setId("ID");
child.setSid("SID");
elements.add(child);
final List<Object> toRetain = new ArrayList<Object>();
toRetain.add(child);
toRetain.add(new Node());
toRetain.add("test");
assertFalse(elements.retainAll(toRetain));
toRetain.remove(child);
assertTrue(elements.retainAll(toRetain));
// Check if node was correctly detached from elements
assertEquals(0, elements.size());
assertNull(child.getParent());
assertNull(child.getDocument());
assertNull(document.getById("ID"));
assertNull(document.getBySid("SID"));
assertNull(parent.getBySid("SID"));
}