Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
}
@Test
public void createViewModel() {
XhtmlTemplate template = new XhtmlTemplate("test");
StartTagNode start = new StartTagNode("li", "prk:for", "item in items");
EndTagNode end = new EndTagNode("li");
ExpressionNode node1 = new ExpressionNode("item.name");
ExpressionNode node2 = new ExpressionNode("item.price");
template.stack(new LoopNode(start, end, new Node[] { node1, node2 }));
template.stack(new ExpressionNode("foo.bar"));
template.stack(new ExpressionNode("poo"));
Map<String, Object> expected = new HashMap<String, Object>();
expected.put("items", new ArrayList<Map<String, Object>>());
Map<String, Object> foo = new HashMap<String, Object>();
foo.put("bar", XhtmlTemplate.NULL_VALUE);
expected.put("foo", foo);
expected.put("poo", XhtmlTemplate.NULL_VALUE);
Assert.assertEquals(expected, template.createViewModel());
Map<String, Object> expectedItem = new HashMap<String, Object>();
expectedItem.put("name", XhtmlTemplate.NULL_VALUE);
expectedItem.put("price", XhtmlTemplate.NULL_VALUE);
Assert.assertEquals(expectedItem, template.createArrayItemModel("items"));
}