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