mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
提交测试用例
This commit is contained in:
parent
56129cba7b
commit
554c2bdb64
@ -203,6 +203,20 @@ public class CollStreamUtilTest {
|
||||
groupThen);
|
||||
|
||||
// 总之,如果你是想要group分组后还要进行别的操作,用它就对了!
|
||||
// 并且对null值进行了友好处理,例如
|
||||
List<Student> students = Arrays.asList(null, null, new Student(1, 1, 1, "张三"),
|
||||
new Student(1, 2, 1, "李四"));
|
||||
Map<Long, List<Student>> termIdStudentsMap = CollStreamUtil.groupBy(students, Student::getTermId, Collectors.toList());
|
||||
Map<Long, List<Student>> termIdStudentsCompareMap = new HashMap<>();
|
||||
termIdStudentsCompareMap.put(null, Arrays.asList(null, null));
|
||||
termIdStudentsCompareMap.put(1L, Arrays.asList(new Student(1L, 1, 1, "张三"), new Student(1L, 2, 1, "李四")));
|
||||
Assert.assertEquals(termIdStudentsCompareMap, termIdStudentsMap);
|
||||
|
||||
Map<Long, Long> termIdCountMap = CollStreamUtil.groupBy(students, Student::getTermId, Collectors.counting());
|
||||
Map<Long, Long> termIdCountCompareMap = new HashMap<>();
|
||||
termIdCountCompareMap.put(null, 2L);
|
||||
termIdCountCompareMap.put(1L, 2L);
|
||||
Assert.assertEquals(termIdCountCompareMap, termIdCountMap);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user