Skip to content

Commit 4119fc9

Browse files
author
Stephen Braimah
committed
BAEL-583: Removed print statements and added assertments to test class
1 parent 016d02a commit 4119fc9

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package com.baeldung.java8;
22

33

4+
import org.assertj.core.condition.AnyOf;
5+
import org.hamcrest.Matchers;
6+
import org.junit.Assert;
47
import org.junit.Test;
58

69
import java.util.Arrays;
710
import java.util.List;
811
import java.util.Optional;
912

13+
import static org.hamcrest.Matchers.*;
14+
import static org.junit.Assert.*;
15+
1016
public class Java8FindAnyFindFirstTest {
1117

1218
@Test
@@ -16,10 +22,8 @@ public void createStream_whenFindAnyResultIsPresent_thenCorrect() {
1622

1723
Optional<String> result = list.stream().findAny();
1824

19-
if(result.isPresent()){
20-
System.out.println(result.get());
21-
}
22-
25+
assert result.isPresent();
26+
assertThat(result.get(), anyOf(is("A"), is("B"), is("C"), is("D")));
2327
}
2428

2529
@Test
@@ -29,9 +33,7 @@ public void createStream_whenFindFirstResultIsPresent_thenCorrect() {
2933

3034
Optional<String> result = list.stream().findFirst();
3135

32-
if(result.isPresent()){
33-
System.out.println(result.get());
34-
}
35-
36+
assert result.isPresent();
37+
assertThat(result.get(),is("A"));
3638
}
3739
}

0 commit comments

Comments
 (0)