NodeMap map = new NodeMap();
map.setMaxMemoryChildren(2);
map.setDescendantInlineCount(-1);
NodeImpl n = new NodeImpl(map, 0);
Assert.assertEquals("{}", n.asString());
n.setId(NodeId.get(255));
Assert.assertEquals("nff={};", n.asString());
n.setPath("/test");
Assert.assertEquals("nff={};/* /test */", n.toString());
n = n.createClone(10);
Assert.assertEquals("{}", n.asString());
NodeImpl a = new NodeImpl(map, 0);
map.addNode(a);
NodeImpl b = new NodeImpl(map, 0);
map.addNode(b);
NodeImpl c = new NodeImpl(map, 0);
map.addNode(c);
NodeImpl d = new NodeImpl(map, 0);
map.addNode(d);
n = n.cloneAndAddChildNode("a", false, null, a, 11);
n = n.cloneAndSetProperty("x", "1", 12);
n.setId(NodeId.get(3));
Assert.assertEquals("n3={\"x\":1,\"a\":n1};", n.asString());
NodeImpl n2 = NodeImpl.fromString(map, n.asString());
Assert.assertEquals("n3={\"x\":1,\"a\":n1};", n2.asString());
n = new NodeImpl(map, 0);
n = n.cloneAndAddChildNode("a", false, null, a, 1);
Assert.assertEquals("{\"a\":n1}", n.asString());
n = n.cloneAndAddChildNode("b", false, null, b, 2);
Assert.assertEquals("{\"a\":n1,\"b\":n2}", n.asString());
n = n.cloneAndAddChildNode("c", false, null, c, 3);
Assert.assertEquals("{\"a\":n1,\"b\":n2,\"c\":n3}", n.asString());
n = n.cloneAndAddChildNode("d", false, null, d, 4);
Assert.assertEquals("{\":children\":n5,\":names\":\"a\",\":children\":n6,\":names\":\"b\",\":children\":n7,\":names\":\"c\",\":children\":n8,\":names\":\"d\",\n\":childCount\":4}",
n.asString());
n2 = NodeImpl.fromString(map, n.asString());
Assert.assertEquals("{\":children\":n5,\":names\":\"a\",\":children\":n6,\":names\":\"b\",\":children\":n7,\":names\":\"c\",\":children\":n8,\":names\":\"d\",\n\":childCount\":4}",
n2.asString());
Assert.assertTrue(n2.exists("a"));
Assert.assertTrue(n2.exists("b"));
Assert.assertTrue(n2.exists("c"));
Assert.assertTrue(n2.exists("d"));
}