Merge branch 'pr/1014-stephen'
This commit is contained in:
commit
d939853fe6
|
@ -17,7 +17,7 @@ public class Java8FindAnyFindFirstTest {
|
|||
@Test
|
||||
public void createStream_whenFindAnyResultIsPresent_thenCorrect() {
|
||||
|
||||
List<String> list = Arrays.asList("A","B","C","D");
|
||||
List<String> list = Arrays.asList("A", "B", "C", "D");
|
||||
|
||||
Optional<String> result = list.stream().findAny();
|
||||
|
||||
|
@ -25,14 +25,27 @@ public class Java8FindAnyFindFirstTest {
|
|||
assertThat(result.get(), anyOf(is("A"), is("B"), is("C"), is("D")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createParallelStream_whenFindAnyResultIsPresent_thenCorrect() throws Exception {
|
||||
List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
|
||||
Optional<Integer> result = list
|
||||
.stream()
|
||||
.parallel()
|
||||
.filter(num -> num < 4)
|
||||
.findAny();
|
||||
|
||||
assertTrue(result.isPresent());
|
||||
assertThat(result.get(), anyOf(is(1), is(2), is(3)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createStream_whenFindFirstResultIsPresent_thenCorrect() {
|
||||
|
||||
List<String> list = Arrays.asList("A","B","C","D");
|
||||
List<String> list = Arrays.asList("A", "B", "C", "D");
|
||||
|
||||
Optional<String> result = list.stream().findFirst();
|
||||
|
||||
assertTrue(result.isPresent());
|
||||
assertThat(result.get(),is("A"));
|
||||
assertThat(result.get(), is("A"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue