DepartmentUtil { public static List<SysDeptTree> wrapDeptListToTree(List<SysDept> sysDeptList, List<SysDeptSelect> sysDeptSelects) { sysDeptSelects.clear(); List<SysDeptTree> records = new ArrayList<>(); for (int i = 0; i < sysDeptList.size(); i++) { SysDept dept = sysDeptList.get(i); records.add(new SysDeptTree(dept)); } List<SysDeptTree> sysOrgTreeList = findChildren(records, sysDeptSelects); setEmptyChildrenAsNull(sysOrgTreeList); return sysOrgTreeList; }  static void disableTargetDeptCode(List<SysDeptSelect> sysDeptSelects,
                                          String deptCode); static List<SysDeptTree> wrapDeptListToTree(List<SysDept> sysDeptList,
                                                     List<SysDeptSelect> sysDeptSelects); static long getDeptTreeSize(List<SysDeptTree> sysDeptTreeList);  }
@Test public void wrapDeptListToTreeTest() { List<SysDeptTree> sysDeptTreeList = DepartmentUtil.wrapDeptListToTree(sysDeptList, sysDeptSelects); assertEquals(sysDeptTreeList.size(), 1); assertEquals(sysDeptTreeList.get(0).getChildren().size(), 2); assertEquals(sysDeptTreeList.get(0).getChildren().get(0).getChildren().size(), 1); assertEquals(sysDeptTreeList.get(0).getChildren().get(1).getChildren().size(), 1); assertEquals(sysDeptSelects.size(), 1); assertEquals(sysDeptSelects.get(0).getChildren().size(), 2); assertEquals(sysDeptSelects.get(0).getChildren().get(0).getChildren().size(), 1); assertEquals(sysDeptSelects.get(0).getChildren().get(1).getChildren().size(), 1); }