added test class Java8FindAnyFindFirstTest

This commit is contained in:
Stephen Braimah 2017-01-11 18:58:44 +00:00
parent ac84f1b303
commit 2710fadcd5
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package com.baeldung.java8;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
/**
* Created by Steve on 1/10/2017.
*/
public class Java8FindAnyFindFirstTest {
@Test
public void createStream_whenFindAnyResultIsPresent_thenCorrect() {
List<String> list = Arrays.asList("A","B","C","D");
Optional<String> result = list.stream().findAny();
if(result.isPresent()){
System.out.println(result.get());
}
}
@Test
public void createStream_whenFindFirstResultIsPresent_thenCorrect() {
List<String> list = Arrays.asList("A","B","C","D");
Optional<String> result = list.stream().findFirst();
if(result.isPresent()){
System.out.println(result.get());
}
}
}