@Test
  public void testRemoveChild() throws Exception {
    // GIVEN
    JcrNodeAdapter item = new JcrNodeAdapter(baseNode);
    // Create a child node
    Node child = baseNode.addNode("child");
    JcrNodeAdapter childItem = new JcrNodeAdapter(child);
    item.addChild(childItem);
    // Create one new child Item
    JcrNewNodeAdapter newChild = new JcrNewNodeAdapter(baseNode, "mgnl:content");
    item.addChild(newChild);

    // WHEN
    boolean resBoolean = item.removeChild(childItem);

    // THEN
    Map<String, AbstractJcrNodeAdapter> res = item.getChildren();
    assertEquals(true, resBoolean);
    assertEquals(1, res.size());
    assertEquals(null, res.get(childItem.getNodeName()));
    assertEquals(newChild, res.get(newChild.getNodeName()));
    assertEquals(item, newChild.getParent());
    Map<String, AbstractJcrNodeAdapter> resRemobed = item.getRemovedChildren();
    assertEquals(1, resRemobed.size());
    assertEquals(childItem, resRemobed.get(childItem.getNodeName()));
  }
  @Test
  public void testAddChild() throws Exception {
    // GIVEN
    JcrNodeAdapter item = new JcrNodeAdapter(baseNode);
    // Create a child node
    Node child = baseNode.addNode("child");
    JcrNodeAdapter childItem = new JcrNodeAdapter(child);
    item.addChild(childItem);
    // Create one new child Item
    JcrNewNodeAdapter newChild = new JcrNewNodeAdapter(baseNode, "mgnl:content");
    item.addChild(newChild);

    // WHEN
    Map<String, AbstractJcrNodeAdapter> res = item.getChildren();

    // THEN
    assertNotNull(res);
    assertEquals(2, res.size());
    assertEquals(childItem, res.get(childItem.getNodeName()));
    assertEquals(item, childItem.getParent());
    assertEquals(newChild, res.get(newChild.getNodeName()));
    assertEquals(item, newChild.getParent());
  }