Skip to content

Commit 2710fad

Browse files
author
Stephen Braimah
committed
added test class Java8FindAnyFindFirstTest
1 parent ac84f1b commit 2710fad

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.baeldung.java8;
2+
3+
import org.junit.Test;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
import java.util.Optional;
8+
9+
import static org.junit.Assert.assertEquals;
10+
11+
/**
12+
* Created by Steve on 1/10/2017.
13+
*/
14+
public class Java8FindAnyFindFirstTest {
15+
16+
@Test
17+
public void createStream_whenFindAnyResultIsPresent_thenCorrect() {
18+
19+
List<String> list = Arrays.asList("A","B","C","D");
20+
21+
Optional<String> result = list.stream().findAny();
22+
23+
if(result.isPresent()){
24+
System.out.println(result.get());
25+
}
26+
27+
}
28+
29+
@Test
30+
public void createStream_whenFindFirstResultIsPresent_thenCorrect() {
31+
32+
List<String> list = Arrays.asList("A","B","C","D");
33+
34+
Optional<String> result = list.stream().findFirst();
35+
36+
if(result.isPresent()){
37+
System.out.println(result.get());
38+
}
39+
40+
}
41+
}

0 commit comments

Comments
 (0)