From 97ce543b4726dc6469500fe9e83d3522c954fe72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=87=A7=E8=87=A7?= <2556450572@qq.com> Date: Wed, 24 Aug 2022 13:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9EasyStream=E4=B8=AD=E8=A1=A5=E5=85=85p?= =?UTF-8?q?eekIdx()=E6=96=B9=E6=B3=95,mapMulti=E9=80=82=E9=85=8D=E4=BA=8E?= =?UTF-8?q?=E6=9B=B4=E9=AB=98=E7=89=88=E6=9C=ACJDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/hutool/core/stream/EasyStreamTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java b/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java index 098fc12b7..6312d17e3 100644 --- a/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java @@ -208,6 +208,26 @@ public class EasyStreamTest { Assert.assertEquals(Arrays.asList(-1, -1, -1), EasyStream.of(1, 2, 3).parallel().flatMapIdx((e, i) -> EasyStream.of(i)).toList()); } + @Test + public void testPeek(){ + EasyStream.of("one", "two", "three", "four") + .filter(e -> e.length() == 4) + .peek(e -> Assert.assertEquals("four", e)) + .map(String::toUpperCase) + .peek(e -> Assert.assertEquals("FOUR", e)) + .collect(Collectors.toList()); + } + + @Test + public void testPeekIdx(){ + EasyStream.of("one", "two", "three", "four") + .filter(e -> e.length() == 4) + .peekIdx((e,i) -> Assert.assertEquals("four:0", e + ":" + i)) + .map(String::toUpperCase) + .peekIdx((e,i) -> Assert.assertEquals("FOUR:0", e + ":" + i)) + .collect(Collectors.toList()); + } + @Test public void testFlat() { final List list = Arrays.asList(1, 2, 3);