BAEL-583: Removed print statements and added assertments to test class

This commit is contained in:
Stephen Braimah 2017-01-14 23:24:11 +00:00
parent 016d02ab17
commit 4119fc9c23
1 changed files with 10 additions and 8 deletions

View File

@ -1,12 +1,18 @@
package com.baeldung.java8; package com.baeldung.java8;
import org.assertj.core.condition.AnyOf;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
public class Java8FindAnyFindFirstTest { public class Java8FindAnyFindFirstTest {
@Test @Test
@ -16,10 +22,8 @@ public class Java8FindAnyFindFirstTest {
Optional<String> result = list.stream().findAny(); Optional<String> result = list.stream().findAny();
if(result.isPresent()){ assert result.isPresent();
System.out.println(result.get()); assertThat(result.get(), anyOf(is("A"), is("B"), is("C"), is("D")));
}
} }
@Test @Test
@ -29,9 +33,7 @@ public class Java8FindAnyFindFirstTest {
Optional<String> result = list.stream().findFirst(); Optional<String> result = list.stream().findFirst();
if(result.isPresent()){ assert result.isPresent();
System.out.println(result.get()); assertThat(result.get(),is("A"));
}
} }
} }