### Question:
PluginTree implements Iterable { @Override public Iterator iterator() { return new PluginTreeIterator(this); } PluginTree();  PluginTree(Plugin plugin); Plugin getPlugin(); List<PluginTree> getChildren(); PluginTree getChild(String id); List<List<PluginTree>> getRoutes(); static PluginTree buildTree(Map<String, Plugin> pluginMap); @Override Iterator iterator();  }### Answer:
@Test public void testIterator() { int index = 0; final String[] order = new String[]{ "root1", "root1.branch1", "root1.branch1.leaf1", "root1.branch1.leaf2", "root1.branch2", "root1.branch2.leaf1", "root2", "root2.branch1", "root2.branch1.leaf1", "root2.branch2", "root2.branch2.leaf1", "root2.branch2.leaf2", "root2.branch2.leaf3" }; for (Object node : tree) { assertTrue("node must be instance of PluginTree", node instanceof PluginTree); assertEquals(order[index++], ((PluginTree) node).getPlugin().getId()); } }