diff --git a/src/main/java/org/assertj/core/api/AbstractBDDSoftAssertions.java b/src/main/java/org/assertj/core/api/AbstractBDDSoftAssertions.java
index fd98fe5ea2..0389ef3139 100644
--- a/src/main/java/org/assertj/core/api/AbstractBDDSoftAssertions.java
+++ b/src/main/java/org/assertj/core/api/AbstractBDDSoftAssertions.java
@@ -12,8 +12,6 @@
*/
package org.assertj.core.api;
-import org.assertj.core.util.CheckReturnValue;
-
import java.nio.file.Path;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -31,7 +29,9 @@
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.BaseStream;
+
+import org.assertj.core.util.CheckReturnValue;
public abstract class AbstractBDDSoftAssertions extends Java6AbstractBDDSoftAssertions {
@@ -229,18 +229,21 @@ public LongPredicateAssert then(LongPredicate actual) {
}
/**
- * Creates a new instance of {@link ListAssert}
from the given {@link Stream}.
+ * Creates a new instance of {@link ListAssert}
from the given {@link BaseStream}.
*
- * Be aware that to create the returned {@link ListAssert} the given the {@link Stream} is consumed so it won't be
+ * Be aware that to create the returned {@link ListAssert} the given the {@link BaseStream} is consumed so it won't be
* possible to use it again. Calling multiple methods on the returned {@link ListAssert} is safe as it only
- * interacts with the {@link List} built from the {@link Stream}.
+ * interacts with the {@link List} built from the {@link BaseStream}.
+ *
+ *
This method accepts {@link java.util.stream.Stream} and primitive stream variants
+ * {@link java.util.stream.IntStream}, {@link java.util.stream.LongStream} and {@link java.util.stream.DoubleStream}.
*
- * @param actual the actual {@link Stream} value.
+ * @param actual the actual {@link BaseStream} value.
* @return the created assertion object.
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
- public ListAssert then(Stream extends ELEMENT> actual) {
- return proxy(ListAssert.class, Stream.class, actual);
+ public > ListAssert then(BaseStream extends ELEMENT, STREAM> actual) {
+ return proxy(ListAssert.class, BaseStream.class, actual);
}
}
diff --git a/src/main/java/org/assertj/core/api/AbstractStandardSoftAssertions.java b/src/main/java/org/assertj/core/api/AbstractStandardSoftAssertions.java
index 6e3ff8838b..ae4953c755 100644
--- a/src/main/java/org/assertj/core/api/AbstractStandardSoftAssertions.java
+++ b/src/main/java/org/assertj/core/api/AbstractStandardSoftAssertions.java
@@ -12,8 +12,6 @@
*/
package org.assertj.core.api;
-import org.assertj.core.util.CheckReturnValue;
-
import java.nio.file.Path;
import java.time.LocalDate;
import java.time.LocalDateTime;
@@ -31,7 +29,9 @@
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.BaseStream;
+
+import org.assertj.core.util.CheckReturnValue;
public abstract class AbstractStandardSoftAssertions extends Java6AbstractStandardSoftAssertions {
@@ -69,7 +69,7 @@ public OptionalAssert assertThat(Optional actual) {
*/
@CheckReturnValue
public OptionalDoubleAssert assertThat(OptionalDouble actual) {
- return proxy(OptionalDoubleAssert.class, OptionalDouble.class, actual);
+ return proxy(OptionalDoubleAssert.class, OptionalDouble.class, actual);
}
/**
@@ -81,7 +81,7 @@ public OptionalDoubleAssert assertThat(OptionalDouble actual) {
*/
@CheckReturnValue
public OptionalLongAssert assertThat(OptionalLong actual) {
- return proxy(OptionalLongAssert.class, OptionalLong.class, actual);
+ return proxy(OptionalLongAssert.class, OptionalLong.class, actual);
}
/**
@@ -93,7 +93,7 @@ public OptionalLongAssert assertThat(OptionalLong actual) {
*/
@CheckReturnValue
public OptionalIntAssert assertThat(OptionalInt actual) {
- return proxy(OptionalIntAssert.class, OptionalInt.class, actual);
+ return proxy(OptionalIntAssert.class, OptionalInt.class, actual);
}
/**
@@ -148,7 +148,7 @@ public LocalTimeAssert assertThat(LocalTime actual) {
*/
@CheckReturnValue
public OffsetTimeAssert assertThat(OffsetTime actual) {
- return proxy(OffsetTimeAssert.class, OffsetTime.class, actual);
+ return proxy(OffsetTimeAssert.class, OffsetTime.class, actual);
}
/**
@@ -229,19 +229,22 @@ public LongPredicateAssert assertThat(LongPredicate actual) {
}
/**
- * Creates a new instance of {@link ListAssert}
from the given {@link Stream}.
+ * Creates a new instance of {@link ListAssert}
from the given {@link BaseStream}.
*
- * Be aware that to create the returned {@link ListAssert} the given the {@link Stream} is consumed so it won't be
+ * Be aware that to create the returned {@link ListAssert} the given the {@link BaseStream} is consumed so it won't be
* possible to use it again. Calling multiple methods on the returned {@link ListAssert} is safe as it only
- * interacts with the {@link List} built from the {@link Stream}.
+ * interacts with the {@link List} built from the {@link BaseStream}.
*
- * @param actual the actual {@link Stream} value.
+ *
This method accepts {@link java.util.stream.Stream} and primitive stream variants
+ * {@link java.util.stream.IntStream}, {@link java.util.stream.LongStream} and {@link java.util.stream.DoubleStream}.
+ *
+ * @param actual the actual {@link BaseStream} value.
* @return the created assertion object.
*/
- @SuppressWarnings("unchecked")
@CheckReturnValue
- public ListAssert assertThat(Stream extends ELEMENT> actual) {
- return proxy(ListAssert.class, Stream.class, actual);
+ @SuppressWarnings("unchecked")
+ public > ListAssert assertThat(BaseStream extends ELEMENT, STREAM> actual) {
+ return proxy(ListAssert.class, BaseStream.class, actual);
}
}
diff --git a/src/main/java/org/assertj/core/api/Assertions.java b/src/main/java/org/assertj/core/api/Assertions.java
index 294d33d2c5..e3b5d39f0a 100644
--- a/src/main/java/org/assertj/core/api/Assertions.java
+++ b/src/main/java/org/assertj/core/api/Assertions.java
@@ -41,6 +41,8 @@
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
@@ -53,14 +55,12 @@
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.atomic.AtomicStampedReference;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
import java.util.function.DoublePredicate;
import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.BaseStream;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.api.exception.RuntimeIOException;
@@ -900,7 +900,7 @@ public static AtomicIntegerArrayAssert assertThat(AtomicIntegerArray actual) {
*/
@CheckReturnValue
public static AtomicIntegerFieldUpdaterAssert assertThat(AtomicIntegerFieldUpdater actual) {
- return new AtomicIntegerFieldUpdaterAssert(actual);
+ return new AtomicIntegerFieldUpdaterAssert<>(actual);
}
/**
@@ -937,7 +937,7 @@ public static AtomicLongArrayAssert assertThat(AtomicLongArray actual) {
*/
@CheckReturnValue
public static AtomicLongFieldUpdaterAssert assertThat(AtomicLongFieldUpdater actual) {
- return new AtomicLongFieldUpdaterAssert(actual);
+ return new AtomicLongFieldUpdaterAssert<>(actual);
}
/**
@@ -950,7 +950,7 @@ public static AtomicLongFieldUpdaterAssert assertThat(AtomicLon
*/
@CheckReturnValue
public static AtomicReferenceAssert assertThat(AtomicReference actual) {
- return new AtomicReferenceAssert(actual);
+ return new AtomicReferenceAssert<>(actual);
}
/**
@@ -2276,17 +2276,20 @@ public static ListAssert assertThat(List extends ELEMENT> a
}
/**
- * Creates a new instance of {@link ListAssert}
from the given {@link Stream}.
+ * Creates a new instance of {@link ListAssert}
from the given {@link BaseStream}.
*
- * Be aware that to create the returned {@link ListAssert} the given the {@link Stream} is consumed so it won't be
+ * Be aware that to create the returned {@link ListAssert} the given the {@link BaseStream} is consumed so it won't be
* possible to use it again. Calling multiple methods on the returned {@link ListAssert} is safe as it only
- * interacts with the {@link List} built from the {@link Stream}.
+ * interacts with the {@link List} built from the {@link BaseStream}.
+ *
+ *
This method accepts {@link java.util.stream.Stream} and primitive stream variants
+ * {@link java.util.stream.IntStream}, {@link java.util.stream.LongStream} and {@link java.util.stream.DoubleStream}.
*
- * @param actual the actual {@link Stream} value.
+ * @param actual the actual {@link BaseStream} value.
* @return the created assertion object.
*/
@CheckReturnValue
- public static AbstractListAssert, List extends ELEMENT>, ELEMENT, ObjectAssert> assertThat(Stream extends ELEMENT> actual) {
+ public static > AbstractListAssert, List extends ELEMENT>, ELEMENT, ObjectAssert> assertThat(BaseStream extends ELEMENT, STREAM> actual) {
return AssertionsForInterfaceTypes.assertThat(actual);
}
diff --git a/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java b/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java
index a7defd5d58..34631630f5 100644
--- a/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java
+++ b/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java
@@ -12,8 +12,6 @@
*/
package org.assertj.core.api;
-import org.assertj.core.util.CheckReturnValue;
-
import java.nio.file.Path;
import java.util.Iterator;
import java.util.List;
@@ -22,7 +20,9 @@
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.BaseStream;
+
+import org.assertj.core.util.CheckReturnValue;
/**
* Entry point for assertion methods for different data types. Each method in this class is a static factory for the
@@ -127,20 +127,22 @@ public static ListAssert assertThat(List extends ELEMENT> a
}
/**
- * Creates a new instance of {@link ListAssert}
from the given {@link Stream}.
+ * Creates a new instance of {@link ListAssert}
from the given {@link BaseStream}.
*
- * Be aware that to create the returned {@link ListAssert} the given the {@link Stream} is consumed so it won't be
+ * Be aware that to create the returned {@link ListAssert} the given the {@link BaseStream} is consumed so it won't be
* possible to use it again. Calling multiple methods on the returned {@link ListAssert} is safe as it only
- * interacts with the {@link List} built from the {@link Stream}.
+ * interacts with the {@link List} built from the {@link BaseStream}.
+ *
+ *
This method accepts {@link java.util.stream.Stream} and primitive stream variants
+ * {@link java.util.stream.IntStream}, {@link java.util.stream.LongStream} and {@link java.util.stream.DoubleStream}.
*
- * @param actual the actual {@link Stream} value.
+ * @param actual the actual {@link BaseStream} value.
* @return the created assertion object.
*/
@CheckReturnValue
- public static ListAssert assertThat(Stream extends ELEMENT> actual) {
+ public static > ListAssert assertThat(BaseStream extends ELEMENT, STREAM> actual) {
return new ListAssert<>(actual);
}
-
/**
* Creates a new instance of {@link IterableAssert}
.
diff --git a/src/main/java/org/assertj/core/api/BDDAssertions.java b/src/main/java/org/assertj/core/api/BDDAssertions.java
index 8915b16ba6..89996b2cbb 100644
--- a/src/main/java/org/assertj/core/api/BDDAssertions.java
+++ b/src/main/java/org/assertj/core/api/BDDAssertions.java
@@ -18,13 +18,13 @@
import java.math.BigInteger;
import java.net.URI;
import java.net.URL;
+import java.nio.file.Path;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZonedDateTime;
-import java.nio.file.Path;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -33,6 +33,8 @@
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicIntegerArray;
@@ -45,13 +47,11 @@
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.atomic.AtomicStampedReference;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
import java.util.function.DoublePredicate;
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.BaseStream;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.util.CheckReturnValue;
@@ -139,6 +139,7 @@ public static LongPredicateAssert then(LongPredicate actual) {
public static DoublePredicateAssert then(DoublePredicate actual) {
return assertThat(actual);
}
+
/**
* Create assertion for {@link java.util.Optional}.
*
@@ -652,7 +653,7 @@ public static AbstractIntegerAssert> then(Integer actual) {
* @return the created assertion object.
*/
@CheckReturnValue
- public static ListAssert then(List extends T> actual){
+ public static ListAssert then(List extends T> actual) {
return assertThat(actual);
}
@@ -1137,17 +1138,20 @@ public static T then(final AssertProvider component) {
}
/**
- * Creates a new instance of {@link ListAssert}
from the given {@link Stream}.
+ * Creates a new instance of {@link ListAssert}
from the given {@link BaseStream}.
*
- * Be aware that to create the returned {@link ListAssert} the given the {@link Stream} is consumed so it won't be
+ * Be aware that to create the returned {@link ListAssert} the given the {@link BaseStream} is consumed so it won't be
* possible to use it again. Calling multiple methods on the returned {@link ListAssert} is safe as it only
- * interacts with the {@link List} built from the {@link Stream}.
+ * interacts with the {@link List} built from the {@link BaseStream}.
+ *
+ *
This method accepts {@link java.util.stream.Stream} and primitive stream variants
+ * {@link java.util.stream.IntStream}, {@link java.util.stream.LongStream} and {@link java.util.stream.DoubleStream}.
*
- * @param actual the actual {@link Stream} value.
+ * @param actual the actual {@link BaseStream} value.
* @return the created assertion object.
*/
@CheckReturnValue
- public static AbstractListAssert, List extends ELEMENT>, ELEMENT, ObjectAssert> then(Stream extends ELEMENT> actual) {
+ public static > AbstractListAssert, List extends ELEMENT>, ELEMENT, ObjectAssert> then(BaseStream extends ELEMENT, STREAM> actual) {
return assertThat(actual);
}
diff --git a/src/main/java/org/assertj/core/api/ListAssert.java b/src/main/java/org/assertj/core/api/ListAssert.java
index a63cf8e079..de33f48b5d 100644
--- a/src/main/java/org/assertj/core/api/ListAssert.java
+++ b/src/main/java/org/assertj/core/api/ListAssert.java
@@ -18,10 +18,11 @@
import java.util.AbstractList;
import java.util.Iterator;
import java.util.List;
-import java.util.stream.Collectors;
+import java.util.stream.BaseStream;
import java.util.stream.Stream;
import org.assertj.core.internal.Failures;
+import org.assertj.core.util.Lists;
import org.assertj.core.util.VisibleForTesting;
/**
@@ -44,8 +45,9 @@ public ListAssert(List extends ELEMENT> actual) {
super(actual, ListAssert.class, new ObjectAssertFactory());
}
- protected ListAssert(Stream extends ELEMENT> actual) {
- this(actual == null ? null : new ListFromStream<>(actual));
+ @SuppressWarnings("unchecked")
+ protected > ListAssert(BaseStream extends ELEMENT, STREAM> actual) {
+ this(actual == null ? null : new ListFromStream<>((BaseStream) actual));
}
@Override
@@ -183,23 +185,22 @@ private ListFromStream asListFromStream() {
}
@VisibleForTesting
- static class ListFromStream extends AbstractList {
- private Stream stream;
+ static class ListFromStream> extends AbstractList {
+ private BaseStream stream;
private List list;
- public ListFromStream(Stream stream) {
+ public ListFromStream(BaseStream stream) {
this.stream = stream;
}
+ @Override
public Stream stream() {
initList();
return list.stream();
}
private List initList() {
- if (list == null) {
- list = stream.collect(Collectors.toList());
- }
+ if (list == null) list = Lists.newArrayList(stream.iterator());
return list;
}
diff --git a/src/main/java/org/assertj/core/api/WithAssertions.java b/src/main/java/org/assertj/core/api/WithAssertions.java
index a18a402b1a..f87929cdad 100644
--- a/src/main/java/org/assertj/core/api/WithAssertions.java
+++ b/src/main/java/org/assertj/core/api/WithAssertions.java
@@ -53,7 +53,7 @@
import java.util.function.IntPredicate;
import java.util.function.LongPredicate;
import java.util.function.Predicate;
-import java.util.stream.Stream;
+import java.util.stream.BaseStream;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.api.filter.Filters;
@@ -664,8 +664,8 @@ FactoryBasedNavigableListAssert, ACTUAL, ELEMENT, ELEMENT_ASSERT> assertThat(L
* Delegate call to {@link org.assertj.core.api.Assertions#assertThat(List)}
*/
@CheckReturnValue
- default AbstractListAssert, ? extends List extends T>, T, ObjectAssert> assertThat(
- final Stream extends T> actual) {
+ default > AbstractListAssert, ? extends List extends ELEMENT>, ELEMENT, ObjectAssert> assertThat(
+ final BaseStream extends ELEMENT, STREAM> actual) {
return Assertions.assertThat(actual);
}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoubleStream_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoubleStream_Test.java
new file mode 100644
index 0000000000..160a5e97a3
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoubleStream_Test.java
@@ -0,0 +1,155 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * Copyright 2012-2017 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.atIndex;
+import static org.assertj.core.test.ExpectedException.none;
+import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.util.List;
+import java.util.stream.DoubleStream;
+
+import org.assertj.core.api.IterableAssert.LazyIterable;
+import org.assertj.core.test.ExpectedException;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Assertions_assertThat_with_DoubleStream_Test {
+
+ @Rule
+ public ExpectedException thrown = none();
+
+ private DoubleStream intStream = DoubleStream.empty();
+
+ @Test
+ public void should_create_Assert() {
+ Object assertions = assertThat(DoubleStream.of(823952.8, 1947230585.9));
+ assertThat(assertions).isNotNull();
+ }
+
+ @Test
+ public void should_assert_on_size() {
+ assertThat(DoubleStream.empty()).isEmpty();
+ assertThat(DoubleStream.of(123.3, 5674.5, 363.4)).isNotEmpty()
+ .hasSize(3);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void should_initialise_actual() {
+ DoubleStream iterator = DoubleStream.of(823952.8, 1947230585.9);
+ List extends Double> actual = assertThat(iterator).actual;
+ assertThat((List) actual).contains(823952.8, atIndex(0))
+ .contains(1947230585.9, atIndex(1));
+ }
+
+ @Test
+ public void should_allow_null() {
+ assertThat(assertThat((DoubleStream) null).actual).isNull();
+ }
+
+ @Test
+ public void isEqualTo_should_honor_comparing_the_same_mocked_stream() {
+ DoubleStream stream = mock(DoubleStream.class);
+ assertThat(stream).isEqualTo(stream);
+ }
+
+ @Test
+ public void stream_can_be_asserted_twice() {
+ DoubleStream names = DoubleStream.of(823952.8, 1947230585.9);
+ assertThat(names).containsExactly(823952.8, 1947230585.9)
+ .containsExactly(823952.8, 1947230585.9);
+ }
+
+ @Test
+ public void should_not_consume_stream_when_asserting_non_null() {
+ DoubleStream stream = mock(DoubleStream.class);
+ assertThat(stream).isNotNull();
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isInstanceOf_should_check_the_original_stream_without_consuming_it() {
+ DoubleStream stream = mock(DoubleStream.class);
+ assertThat(stream).isInstanceOf(DoubleStream.class);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isInstanceOfAny_should_check_the_original_stream_without_consuming_it() {
+ DoubleStream stream = mock(DoubleStream.class);
+ assertThat(stream).isInstanceOfAny(DoubleStream.class, String.class);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isOfAnyClassIn_should_check_the_original_stream_without_consuming_it() {
+ DoubleStream stream = mock(DoubleStream.class);
+ assertThat(stream).isOfAnyClassIn(Double.class, stream.getClass());
+ }
+
+ @Test
+ public void isExactlyInstanceOf_should_check_the_original_stream() {
+ // factory creates use internal classes
+ assertThat(intStream).isExactlyInstanceOf(intStream.getClass());
+ }
+
+ @Test
+ public void isNotExactlyInstanceOf_should_check_the_original_stream() {
+ assertThat(intStream).isNotExactlyInstanceOf(DoubleStream.class);
+ try {
+ assertThat(intStream).isNotExactlyInstanceOf(intStream.getClass());
+ } catch (AssertionError e) {
+ // ok
+ return;
+ }
+ failBecauseExpectedAssertionErrorWasNotThrown();
+ }
+
+ @Test
+ public void isNotInstanceOf_should_check_the_original_stream() {
+ assertThat(intStream).isNotInstanceOf(LazyIterable.class);
+ }
+
+ @Test
+ public void isNotInstanceOfAny_should_check_the_original_stream() {
+ assertThat(intStream).isNotInstanceOfAny(LazyIterable.class, String.class);
+ }
+
+ @Test
+ public void isNotOfAnyClassIn_should_check_the_original_stream() {
+ assertThat(intStream).isNotOfAnyClassIn(LazyIterable.class, String.class);
+ }
+
+ @Test
+ public void isSameAs_should_check_the_original_stream_without_consuming_it() {
+ DoubleStream stream = mock(DoubleStream.class);
+ assertThat(stream).isSameAs(stream);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isNotSameAs_should_check_the_original_stream_without_consuming_it() {
+ DoubleStream stream = mock(DoubleStream.class);
+ try {
+ assertThat(stream).isNotSameAs(stream);
+ } catch (AssertionError e) {
+ verifyZeroInteractions(stream);
+ return;
+ }
+ Assertions.fail("Expected assertionError, because assert notSame on same stream.");
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntStream_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntStream_Test.java
new file mode 100644
index 0000000000..57abbc8145
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntStream_Test.java
@@ -0,0 +1,155 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * Copyright 2012-2017 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.atIndex;
+import static org.assertj.core.test.ExpectedException.none;
+import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.util.List;
+import java.util.stream.IntStream;
+
+import org.assertj.core.api.IterableAssert.LazyIterable;
+import org.assertj.core.test.ExpectedException;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Assertions_assertThat_with_IntStream_Test {
+
+ @Rule
+ public ExpectedException thrown = none();
+
+ private IntStream intStream = IntStream.empty();
+
+ @Test
+ public void should_create_Assert() {
+ Object assertions = assertThat(IntStream.of(823952, 1947230585));
+ assertThat(assertions).isNotNull();
+ }
+
+ @Test
+ public void should_assert_on_size() {
+ assertThat(IntStream.empty()).isEmpty();
+ assertThat(IntStream.of(123, 5674, 363)).isNotEmpty()
+ .hasSize(3);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void should_initialise_actual() {
+ IntStream iterator = IntStream.of(823952, 1947230585);
+ List extends Integer> actual = assertThat(iterator).actual;
+ assertThat((List) actual).contains(823952, atIndex(0))
+ .contains(1947230585, atIndex(1));
+ }
+
+ @Test
+ public void should_allow_null() {
+ assertThat(assertThat((IntStream) null).actual).isNull();
+ }
+
+ @Test
+ public void isEqualTo_should_honor_comparing_the_same_mocked_stream() {
+ IntStream stream = mock(IntStream.class);
+ assertThat(stream).isEqualTo(stream);
+ }
+
+ @Test
+ public void stream_can_be_asserted_twice() {
+ IntStream names = IntStream.of(823952, 1947230585);
+ assertThat(names).containsExactly(823952, 1947230585)
+ .containsExactly(823952, 1947230585);
+ }
+
+ @Test
+ public void should_not_consume_stream_when_asserting_non_null() {
+ IntStream stream = mock(IntStream.class);
+ assertThat(stream).isNotNull();
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isInstanceOf_should_check_the_original_stream_without_consuming_it() {
+ IntStream stream = mock(IntStream.class);
+ assertThat(stream).isInstanceOf(IntStream.class);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isInstanceOfAny_should_check_the_original_stream_without_consuming_it() {
+ IntStream stream = mock(IntStream.class);
+ assertThat(stream).isInstanceOfAny(IntStream.class, String.class);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isOfAnyClassIn_should_check_the_original_stream_without_consuming_it() {
+ IntStream stream = mock(IntStream.class);
+ assertThat(stream).isOfAnyClassIn(Double.class, stream.getClass());
+ }
+
+ @Test
+ public void isExactlyInstanceOf_should_check_the_original_stream() {
+ // factory creates use internal classes
+ assertThat(intStream).isExactlyInstanceOf(intStream.getClass());
+ }
+
+ @Test
+ public void isNotExactlyInstanceOf_should_check_the_original_stream() {
+ assertThat(intStream).isNotExactlyInstanceOf(IntStream.class);
+ try {
+ assertThat(intStream).isNotExactlyInstanceOf(intStream.getClass());
+ } catch (AssertionError e) {
+ // ok
+ return;
+ }
+ failBecauseExpectedAssertionErrorWasNotThrown();
+ }
+
+ @Test
+ public void isNotInstanceOf_should_check_the_original_stream() {
+ assertThat(intStream).isNotInstanceOf(LazyIterable.class);
+ }
+
+ @Test
+ public void isNotInstanceOfAny_should_check_the_original_stream() {
+ assertThat(intStream).isNotInstanceOfAny(LazyIterable.class, String.class);
+ }
+
+ @Test
+ public void isNotOfAnyClassIn_should_check_the_original_stream() {
+ assertThat(intStream).isNotOfAnyClassIn(LazyIterable.class, String.class);
+ }
+
+ @Test
+ public void isSameAs_should_check_the_original_stream_without_consuming_it() {
+ IntStream stream = mock(IntStream.class);
+ assertThat(stream).isSameAs(stream);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isNotSameAs_should_check_the_original_stream_without_consuming_it() {
+ IntStream stream = mock(IntStream.class);
+ try {
+ assertThat(stream).isNotSameAs(stream);
+ } catch (AssertionError e) {
+ verifyZeroInteractions(stream);
+ return;
+ }
+ Assertions.fail("Expected assertionError, because assert notSame on same stream.");
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongStream_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongStream_Test.java
new file mode 100644
index 0000000000..9bdc3e0380
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongStream_Test.java
@@ -0,0 +1,155 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ *
+ * Copyright 2012-2017 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.atIndex;
+import static org.assertj.core.test.ExpectedException.none;
+import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import java.util.List;
+import java.util.stream.LongStream;
+
+import org.assertj.core.api.IterableAssert.LazyIterable;
+import org.assertj.core.test.ExpectedException;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Assertions_assertThat_with_LongStream_Test {
+
+ @Rule
+ public ExpectedException thrown = none();
+
+ private LongStream intStream = LongStream.empty();
+
+ @Test
+ public void should_create_Assert() {
+ Object assertions = assertThat(LongStream.of(823952L, 1947230585L));
+ assertThat(assertions).isNotNull();
+ }
+
+ @Test
+ public void should_assert_on_size() {
+ assertThat(LongStream.empty()).isEmpty();
+ assertThat(LongStream.of(123L, 5674L, 363L)).isNotEmpty()
+ .hasSize(3);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void should_initialise_actual() {
+ LongStream iterator = LongStream.of(823952L, 1947230585L);
+ List extends Long> actual = assertThat(iterator).actual;
+ assertThat((List) actual).contains(823952L, atIndex(0))
+ .contains(1947230585L, atIndex(1));
+ }
+
+ @Test
+ public void should_allow_null() {
+ assertThat(assertThat((LongStream) null).actual).isNull();
+ }
+
+ @Test
+ public void isEqualTo_should_honor_comparing_the_same_mocked_stream() {
+ LongStream stream = mock(LongStream.class);
+ assertThat(stream).isEqualTo(stream);
+ }
+
+ @Test
+ public void stream_can_be_asserted_twice() {
+ LongStream names = LongStream.of(823952L, 1947230585L);
+ assertThat(names).containsExactly(823952L, 1947230585L)
+ .containsExactly(823952L, 1947230585L);
+ }
+
+ @Test
+ public void should_not_consume_stream_when_asserting_non_null() {
+ LongStream stream = mock(LongStream.class);
+ assertThat(stream).isNotNull();
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isInstanceOf_should_check_the_original_stream_without_consuming_it() {
+ LongStream stream = mock(LongStream.class);
+ assertThat(stream).isInstanceOf(LongStream.class);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isInstanceOfAny_should_check_the_original_stream_without_consuming_it() {
+ LongStream stream = mock(LongStream.class);
+ assertThat(stream).isInstanceOfAny(LongStream.class, String.class);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isOfAnyClassIn_should_check_the_original_stream_without_consuming_it() {
+ LongStream stream = mock(LongStream.class);
+ assertThat(stream).isOfAnyClassIn(Double.class, stream.getClass());
+ }
+
+ @Test
+ public void isExactlyInstanceOf_should_check_the_original_stream() {
+ // factory creates use internal classes
+ assertThat(intStream).isExactlyInstanceOf(intStream.getClass());
+ }
+
+ @Test
+ public void isNotExactlyInstanceOf_should_check_the_original_stream() {
+ assertThat(intStream).isNotExactlyInstanceOf(LongStream.class);
+ try {
+ assertThat(intStream).isNotExactlyInstanceOf(intStream.getClass());
+ } catch (AssertionError e) {
+ // ok
+ return;
+ }
+ failBecauseExpectedAssertionErrorWasNotThrown();
+ }
+
+ @Test
+ public void isNotInstanceOf_should_check_the_original_stream() {
+ assertThat(intStream).isNotInstanceOf(LazyIterable.class);
+ }
+
+ @Test
+ public void isNotInstanceOfAny_should_check_the_original_stream() {
+ assertThat(intStream).isNotInstanceOfAny(LazyIterable.class, String.class);
+ }
+
+ @Test
+ public void isNotOfAnyClassIn_should_check_the_original_stream() {
+ assertThat(intStream).isNotOfAnyClassIn(LazyIterable.class, String.class);
+ }
+
+ @Test
+ public void isSameAs_should_check_the_original_stream_without_consuming_it() {
+ LongStream stream = mock(LongStream.class);
+ assertThat(stream).isSameAs(stream);
+ verifyZeroInteractions(stream);
+ }
+
+ @Test
+ public void isNotSameAs_should_check_the_original_stream_without_consuming_it() {
+ LongStream stream = mock(LongStream.class);
+ try {
+ assertThat(stream).isNotSameAs(stream);
+ } catch (AssertionError e) {
+ verifyZeroInteractions(stream);
+ return;
+ }
+ Assertions.fail("Expected assertionError, because assert notSame on same stream.");
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_Test.java
index 5f4eb04f04..b86cbec569 100644
--- a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_Test.java
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Stream_Test.java
@@ -38,7 +38,7 @@ public class Assertions_assertThat_with_Stream_Test {
@Test
public void should_create_Assert() {
- Object assertions = Assertions.assertThat(Stream.of("Luke", "Leia"));
+ Object assertions = assertThat(Stream.of("Luke", "Leia"));
assertThat(assertions).isNotNull();
}
@@ -192,4 +192,4 @@ public String toString() {
}
}
-}
\ No newline at end of file
+}