对EasyStream中补充peekIdx()方法,mapMulti适配于更高版本JDK

This commit is contained in:
臧臧 2022-08-24 13:49:09 +08:00
parent e410b2685e
commit 97ce543b47

View File

@ -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<Integer> list = Arrays.asList(1, 2, 3);