// +7 not verbatim
// +8
// +9
AttributeBean attr = null;
ElementBean child = null;
ComponentBean root = createVerbatim(ComponentBean.class, "0");
// root is not a verbatim
root.setJsfid("outputText");
child = (ElementBean) createVerbatim(ElementBean.class, "1");
child.setRenderId(1);
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "2");
child.setRenderId(2);
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "3");
child.setRenderId(3);
// root is not a verbatim
child.setJsfid("outputText");
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "4");
child.setRenderId(4);
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "5");
child.setRenderId(5);
// root is not a verbatim
child.setJsfid("outputText");
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "6");
child.setRenderId(6);
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "7");
child.setRenderId(7);
// root is not a verbatim
child.setJsfid("outputText");
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "8");
child.setRenderId(8);
root.addChild(child);
child = (ElementBean) createVerbatim(ElementBean.class, "9");
child.setRenderId(9);
root.addChild(child);
((TemplateConfigBean) htmlTemplateConfigBean).optimizeTree(root);
assertEquals("#Children", 7, root.getChildren().size());
Iterator ci = root.getChildren().iterator();
int i = 0;
while (ci.hasNext()) {
child = (ElementBean) ci.next();
switch (++i) {
case 1: {
// first two nodes merged
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "12", attr.getValue());
break;
}
case 2: {
// non-verbatim
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "3", attr.getValue());
break;
}
case 3: {
// verbatim non-adjacent
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "4", attr.getValue());
break;
}
case 4: {
// non-verbatim
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "5", attr.getValue());
break;
}
case 5: {
// verbatim non-adjacent
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "6", attr.getValue());
break;
}
case 6: {
// non-verbatim
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "7", attr.getValue());
break;
}
case 7: {
// first two nodes merged
attr = child.getAttribute("value");
assertNotNull(attr);
assertEquals("root value", "89", attr.getValue());
break;
}