mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
Merge branch 'v5-dev' of gitee.com:dromara/hutool into v5-dev
This commit is contained in:
commit
b6b2107794
@ -0,0 +1,34 @@
|
|||||||
|
package cn.hutool.core.lang.tree;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class IssueI9PDVFTest {
|
||||||
|
@Test
|
||||||
|
public void buildTest() {
|
||||||
|
List<TestList> list = new ArrayList<>();
|
||||||
|
list.add(new TestList(1790187987502895123L, "顶级", 0L));
|
||||||
|
list.add(new TestList(1790187987502895124L, "子集", 1790187987502895123L));
|
||||||
|
|
||||||
|
List<Tree<String>> build = TreeUtil.build(list, "0", (testList, treeNode) -> {
|
||||||
|
treeNode.setId(testList.getId().toString());
|
||||||
|
treeNode.setName(testList.getName());
|
||||||
|
treeNode.setParentId(testList.getParentId().toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.notNull(build);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class TestList {
|
||||||
|
Long id;
|
||||||
|
String name;
|
||||||
|
Long parentId;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user