public void inlineChildNodes() {
NodeMap map = new NodeMap();
map.setDescendantCount(true);
map.setDescendantInlineCount(3);
NodeImpl n = new NodeImpl(map, 0);
Assert.assertEquals("{}", n.asString());
NodeImpl a = new NodeImpl(map, 0);
a.setProperty("name", "\"a\"");
map.addNode(a);
NodeImpl b = new NodeImpl(map, 0);
b.setProperty("name", "\"b\"");
map.addNode(b);
NodeImpl c = new NodeImpl(map, 0);
c.setProperty("name", "\"c\"");
map.addNode(c);
NodeImpl d = new NodeImpl(map, 0);
d.setProperty("name", "\"d\"");
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\":{\"name\":\"a\"}};", n.asString());
NodeImpl n2 = NodeImpl.fromString(map, n.asString());
Assert.assertEquals("n3={\"x\":1,\"a\":{\"name\":\"a\"}};", n2.asString());
n = new NodeImpl(map, 0);
n = n.cloneAndAddChildNode("a", false, null, a, 1);
Assert.assertEquals("{\"a\":{\"name\":\"a\"}}", n.asString());
n = n.cloneAndAddChildNode("b", false, null, b, 2);
String ab = "{\"a\":{\"name\":\"a\"},\"b\":{\"name\":\"b\"}}";
Assert.assertEquals(ab, n.asString());
n = n.cloneAndAddChildNode("c", false, null, c, 3);
String abc = "{\"a\":{\"name\":\"a\"},\"b\":{\"name\":\"b\"},\"c\":{\"name\":\"c\"}}";
Assert.assertEquals(abc, n.asString());
Assert.assertEquals(3, n.getDescendantCount());
Assert.assertEquals(3, n.getDescendantInlineCount());
n2 = NodeImpl.fromString(map, n.asString());
Assert.assertTrue(n2.exists("a"));
Assert.assertTrue(n2.exists("b"));
Assert.assertTrue(n2.exists("c"));
Assert.assertEquals(3, n2.getDescendantCount());
Assert.assertEquals(3, n2.getDescendantInlineCount());
NodeImpl root = new NodeImpl(map, 0);
root = root.cloneAndAddChildNode("test", false, null, n2, 1);
Assert.assertEquals("{\":size\":4,\"test\":n1}", root.asString());
Assert.assertEquals(0, root.getDescendantInlineCount());
n2 = n2.cloneAndRemoveChildNode("c", 4);
root = new NodeImpl(map, 0);
root = root.cloneAndAddChildNode("test", false, null, n2, 1);
Assert.assertEquals("{\":size\":3,\"test\":" + ab + "}", root.asString());
}