assertThat(nodes.getMembers()).hasSize(2);
}
@Test
public void itHasATopNodeForFoodWithChildren() throws Exception {
final XmlsonObject representation = presenter.present(hierarchy, Locale.CANADA_FRENCH);
final XmlsonArray nodes = (XmlsonArray) representation.get("nodes");
int checkedNodes = 0;
for (XmlsonMember member : nodes.getMembers()) {
final XmlsonObject node = (XmlsonObject) member;
if (((XmlsonObject) node.get("tag")).getString("name").equals("food")) {
final XmlsonObject sum = (XmlsonObject) node.get("sum");
assertThat(sum.getString("display")).isEqualTo("50,00 $ US");
assertThat(sum.getString("value")).isEqualTo("50.00");
assertThat(sum.getInteger("count")).isEqualTo(2);
checkedNodes++;
for (XmlsonMember innerMember : ((XmlsonArray) node.get("nodes")).getMembers()) {
final XmlsonObject innerNode = (XmlsonObject) innerMember;
if (((XmlsonObject) innerNode.get("tag")).getString("name").equals("groceries")) {
final XmlsonObject innerSum = (XmlsonObject) innerNode.get("sum");
assertThat(innerSum.getString("display")).isEqualTo("30,00 $ US");
assertThat(innerSum.getString("value")).isEqualTo("30.00");
assertThat(innerSum.getInteger("count")).isEqualTo(1);
checkedNodes++;
}
}
for (XmlsonMember innerMember : ((XmlsonArray) node.get("nodes")).getMembers()) {
final XmlsonObject innerNode = (XmlsonObject) innerMember;
if (((XmlsonObject) innerNode.get("tag")).getString("name").equals("restaurants")) {
final XmlsonObject innerSum = (XmlsonObject) innerNode.get("sum");
assertThat(innerSum.getString("display")).isEqualTo("20,00 $ US");
assertThat(innerSum.getString("value")).isEqualTo("20.00");
assertThat(innerSum.getInteger("count")).isEqualTo(1);
checkedNodes++;
}
}