JAMES-2529 Add tests for OptionalUtils::ofNullableToStream

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d0ee9686
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d0ee9686
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d0ee9686

Branch: refs/heads/master
Commit: d0ee96861c32bfd6ee5ea9ba50919d16f1d97090
Parents: 1e2124e
Author: Benoit Tellier <[email protected]>
Authored: Thu Aug 30 14:53:09 2018 +0700
Committer: Antoine Duprat <[email protected]>
Committed: Thu Aug 30 15:07:03 2018 +0200

----------------------------------------------------------------------
 .../apache/james/util/OptionalUtilsTest.java    | 23 +++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d0ee9686/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
 
b/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
index 17fe06e..f7d7bf2 100644
--- 
a/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
+++ 
b/server/container/util/src/test/java/org/apache/james/util/OptionalUtilsTest.java
@@ -27,8 +27,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
-import com.github.steveash.guavate.Guavate;
-
 public class OptionalUtilsTest {
 
     @Rule
@@ -69,18 +67,14 @@ public class OptionalUtilsTest {
 
     @Test
     public void toStreamShouldConvertEmptyOptionalToEmptyStream() {
-        assertThat(
-            OptionalUtils.toStream(Optional.empty())
-                .collect(Guavate.toImmutableList()))
+        assertThat(OptionalUtils.toStream(Optional.empty()))
             .isEmpty();
     }
 
     @Test
     public void toStreamShouldConvertFullOptionalToStream() {
         long value = 18L;
-        assertThat(
-            OptionalUtils.toStream(Optional.of(value))
-                .collect(Guavate.toImmutableList()))
+        assertThat(OptionalUtils.toStream(Optional.of(value)))
             .containsExactly(value);
     }
 
@@ -91,6 +85,19 @@ public class OptionalUtilsTest {
     }
 
     @Test
+    public void 
ofNullableToStreamShouldReturnAStreamContainingTheValueWhenNotNull() {
+        long value = 18L;
+        assertThat(OptionalUtils.ofNullableToStream(value))
+            .containsExactly(value);
+    }
+
+    @Test
+    public void ofNullableToStreamShouldReturnAnEmptyStreamWhenNull() {
+        assertThat(OptionalUtils.ofNullableToStream(null))
+            .isEmpty();
+    }
+
+    @Test
     public void orShouldReturnEmptyWhenEmpty() {
         assertThat(
             OptionalUtils.or(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to