-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify and fix bugs in StreamUtil (#551)
* Simplify and fix bugs in StreamUtil * Fix checkstyle --------- Co-authored-by: Karthik Ramgopal <[email protected]>
- Loading branch information
1 parent
9f838a0
commit 2d0eab0
Showing
3 changed files
with
47 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...builder/builder-spi/src/test/java/com/linkedin/avroutil1/builder/util/StreamUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 LinkedIn Corp. | ||
* Licensed under the BSD 2-Clause License (the "License"). | ||
* See License in the project root for license information. | ||
*/ | ||
|
||
package com.linkedin.avroutil1.builder.util; | ||
|
||
import java.util.stream.IntStream; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
/** | ||
* This is to test {@link StreamUtil} | ||
*/ | ||
public class StreamUtilTest { | ||
|
||
@Test | ||
public void testParallelStreaming() { | ||
int result = IntStream.rangeClosed(1, 100) | ||
.boxed() | ||
.collect(StreamUtil.toParallelStream(x -> x * x, 3, 4)) | ||
.reduce(0, Integer::sum); | ||
|
||
int expected = IntStream.rangeClosed(1, 100).map(x -> x * x).sum(); | ||
|
||
Assert.assertEquals(result, expected); | ||
} | ||
} |