-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad1cb65
commit ff9e0ae
Showing
2 changed files
with
27 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.finance.programming; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class UsageOfStream { | ||
|
||
@Test | ||
@DisplayName("Given a list of numbers, when filter function is applied, then should return the even numbers") | ||
void creatingAnInfiniteStream(){ | ||
int[] actualResult = Stream.iterate(0, x -> x + 2) | ||
.limit(10) | ||
.mapToInt(Integer::intValue) | ||
.toArray(); | ||
int[] expectedResult = {0, 2, 4, 6, 8, 10, 12, 14, 16, 18}; | ||
|
||
|
||
assertArrayEquals(expectedResult, actualResult, | ||
"The array doesn't match"); | ||
} | ||
|
||
} |
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