### Question:
Tree { public void createTree(List<Node> nodes) { for (Node node : nodes) { if (node.getPid() == root.getNid()) { root.addChild(node); } else { Node parent = findParent(root, node.getPid()); if (parent != null) { parent.addChild(node); } } } } Tree();  Tree(String text); void createTree(List<Node> nodes); void middlePrint(Node tnode); @Transient List<Node> getLeafList(); String getHtml(Node tnode); boolean checkExist(Node tnode, String text); Node getRoot(); void setRoot(Node root);  }### Answer:
@Test public void testCreateTree() { final Tree tree = new Tree(); final ArrayList<Node> nodes = new ArrayList<>(); tree.setRoot(new Node()); nodes.add(new Node(0, 0, "foo", 0l, 0)); nodes.add(new Node(1, 1, "bar", 0l, 1)); tree.createTree(nodes); assertEquals(new Node(0, 0, "foo", 0l, 0), tree.getRoot().getChildren().get(0)); }