@Test
  public void testReOrderingOfChildNodesWithRemovedChild() throws Exception {
    // GIVEN
    ((MockNode) baseNode).setPrimaryNodeType(new MockNodeType(NodeTypes.Content.NAME, null, true));
    baseNode.addNode("child-a");
    baseNode.addNode("child-b");
    baseNode.addNode("child-c");
    JcrNodeAdapter item = new JcrNodeAdapter(baseNode);
    item.removeChild(new JcrNodeAdapter(baseNode.getNode("child-c")));
    item.addChild(new JcrNodeAdapter(baseNode.getNode("child-b")));
    item.addChild(new JcrNodeAdapter(baseNode.getNode("child-a")));

    // WHEN
    item.applyChanges();

    // THEN
    List<String> nodes =
        Lists.newArrayList(
            Iterators.transform(
                item.getJcrItem().getNodes(),
                new Function<Node, String>() {
                  @Nullable
                  @Override
                  public String apply(@Nullable Node node) {
                    return NodeUtil.getName(node);
                  }
                }));

    assertThat(nodes, contains("child-b", "child-a"));
  }