Merge branch 'pr/1014-stephen'

This commit is contained in:
slavisa-baeldung 2017-01-21 08:06:57 +01:00
commit d939853fe6

View File

@ -25,6 +25,19 @@ public class Java8FindAnyFindFirstTest {
assertThat(result.get(), anyOf(is("A"), is("B"), is("C"), is("D"))); 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 @Test
public void createStream_whenFindFirstResultIsPresent_thenCorrect() { public void createStream_whenFindFirstResultIsPresent_thenCorrect() {