*/
@Test
public void testAddAllAtIndex()
{
final Document oldDocument = new Document();
final Node oldParent = new Node();
oldDocument.addChild(oldParent);
final Elements<Node> oldElements = new Nodes(oldParent);
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");
oldElements.add(child);
elements.addAll(0, oldElements);
assertSame(document, child.getDocument());
assertSame(parent, child.getParent());
assertSame(child, document.getById("ID"));
assertSame(child, document.getBySid("SID"));
assertSame(child, parent.getBySid("SID"));
// Check if node was correctly detached from old elements
assertEquals(0, oldElements.size());
assertNull(oldDocument.getById("ID"));