You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2018/08/30 13:15:57 UTC
[15/26] james-project git commit: JAMES-2529 Add tests for
OptionalUtils::ofNullableToStream
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 <bt...@linagora.com>
Authored: Thu Aug 30 14:53:09 2018 +0700
Committer: Antoine Duprat <ad...@linagora.com>
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: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org