From 1d9c7827965fdadaa291aefc3066a275aa10409d Mon Sep 17 00:00:00 2001
From: Filip Hrisafov
Date: Thu, 2 Jun 2016 23:44:02 +0200
Subject: [PATCH] fixes #658 add support for java 8 Predicates
---
.../core/api/AbstractPredicateAssert.java | 127 +++++++++++++++++
.../core/api/AbstractPredicateLikeAssert.java | 128 ++++++++++++++++++
.../core/api/AssertionsForClassTypes.java | 2 +
.../core/api/AssertionsForInterfaceTypes.java | 51 +++++++
.../core/api/DoublePredicateAssert.java | 106 +++++++++++++++
.../assertj/core/api/IntPredicateAssert.java | 106 +++++++++++++++
.../assertj/core/api/LongPredicateAssert.java | 106 +++++++++++++++
.../org/assertj/core/api/PredicateAssert.java | 30 ++++
.../core/error/NoElementsShouldMatch.java | 26 ++++
.../org/assertj/core/error/ShouldAccept.java | 48 +++++++
.../assertj/core/error/ShouldNotAccept.java | 48 +++++++
.../assertj/core/error/ShouldNotMatch.java | 58 ++++++++
.../org/assertj/core/internal/Iterables.java | 11 ++
.../presentation/PredicateDescription.java | 10 ++
..._assertThat_with_DoublePredicate_Test.java | 48 +++++++
...ons_assertThat_with_IntPredicate_Test.java | 48 +++++++
...ns_assertThat_with_LongPredicate_Test.java | 48 +++++++
...rtions_assertThat_with_Predicate_Test.java | 48 +++++++
.../assertj/core/api/BaseTestTemplate.java | 2 +-
.../api/DoublePredicateAssertBaseTest.java | 44 ++++++
.../core/api/IntPredicateAssertBaseTest.java | 44 ++++++
.../core/api/LongPredicateAssertBaseTest.java | 44 ++++++
.../core/api/PredicateAssertBaseTest.java | 41 ++++++
...DoublePredicateAssert_acceptsAll_Test.java | 65 +++++++++
.../DoublePredicateAssert_accepts_Test.java | 73 ++++++++++
...DoublePredicateAssert_rejectsAll_Test.java | 68 ++++++++++
.../DoublePredicateAssert_rejects_Test.java | 73 ++++++++++
.../IntPredicateAssert_acceptsAll_Test.java | 65 +++++++++
.../IntPredicateAssert_accepts_Test.java | 74 ++++++++++
.../IntPredicateAssert_rejectsAll_Test.java | 68 ++++++++++
.../IntPredicateAssert_rejects_Test.java | 74 ++++++++++
.../LongPredicateAssert_acceptsAll_Test.java | 66 +++++++++
.../LongPredicateAssert_accepts_Test.java | 74 ++++++++++
.../LongPredicateAssert_rejectsAll_Test.java | 68 ++++++++++
.../LongPredicateAssert_rejects_Test.java | 74 ++++++++++
.../PredicateAssert_acceptsAll_Test.java | 69 ++++++++++
.../PredicateAssert_accepts_Test.java | 68 ++++++++++
.../PredicateAssert_rejectsAllTest.java | 69 ++++++++++
.../PredicateAssert_rejects_Test.java | 68 ++++++++++
.../NoElementsShouldMatch_create_Test.java | 40 ++++++
.../core/error/ShouldAccept_create_Test.java | 57 ++++++++
.../error/ShouldNotAccept_create_Test.java | 57 ++++++++
.../error/ShouldNotMatch_create_Test.java | 54 ++++++++
.../Iterables_assertNoneMatch_Test.java | 57 ++++++++
44 files changed, 2604 insertions(+), 1 deletion(-)
create mode 100644 src/main/java/org/assertj/core/api/AbstractPredicateAssert.java
create mode 100644 src/main/java/org/assertj/core/api/AbstractPredicateLikeAssert.java
create mode 100644 src/main/java/org/assertj/core/api/DoublePredicateAssert.java
create mode 100644 src/main/java/org/assertj/core/api/IntPredicateAssert.java
create mode 100644 src/main/java/org/assertj/core/api/LongPredicateAssert.java
create mode 100644 src/main/java/org/assertj/core/api/PredicateAssert.java
create mode 100644 src/main/java/org/assertj/core/error/NoElementsShouldMatch.java
create mode 100644 src/main/java/org/assertj/core/error/ShouldAccept.java
create mode 100644 src/main/java/org/assertj/core/error/ShouldNotAccept.java
create mode 100644 src/main/java/org/assertj/core/error/ShouldNotMatch.java
create mode 100644 src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoublePredicate_Test.java
create mode 100644 src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntPredicate_Test.java
create mode 100644 src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongPredicate_Test.java
create mode 100644 src/test/java/org/assertj/core/api/Assertions_assertThat_with_Predicate_Test.java
create mode 100644 src/test/java/org/assertj/core/api/DoublePredicateAssertBaseTest.java
create mode 100644 src/test/java/org/assertj/core/api/IntPredicateAssertBaseTest.java
create mode 100644 src/test/java/org/assertj/core/api/LongPredicateAssertBaseTest.java
create mode 100644 src/test/java/org/assertj/core/api/PredicateAssertBaseTest.java
create mode 100644 src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_acceptsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_accepts_Test.java
create mode 100644 src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejectsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejects_Test.java
create mode 100644 src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_acceptsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_accepts_Test.java
create mode 100644 src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejectsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejects_Test.java
create mode 100644 src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_acceptsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_accepts_Test.java
create mode 100644 src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejectsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejects_Test.java
create mode 100644 src/test/java/org/assertj/core/api/predicate/PredicateAssert_acceptsAll_Test.java
create mode 100644 src/test/java/org/assertj/core/api/predicate/PredicateAssert_accepts_Test.java
create mode 100644 src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejectsAllTest.java
create mode 100644 src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejects_Test.java
create mode 100644 src/test/java/org/assertj/core/error/NoElementsShouldMatch_create_Test.java
create mode 100644 src/test/java/org/assertj/core/error/ShouldAccept_create_Test.java
create mode 100644 src/test/java/org/assertj/core/error/ShouldNotAccept_create_Test.java
create mode 100644 src/test/java/org/assertj/core/error/ShouldNotMatch_create_Test.java
create mode 100644 src/test/java/org/assertj/core/internal/iterables/Iterables_assertNoneMatch_Test.java
diff --git a/src/main/java/org/assertj/core/api/AbstractPredicateAssert.java b/src/main/java/org/assertj/core/api/AbstractPredicateAssert.java
new file mode 100644
index 0000000000..8f1fbe0fa0
--- /dev/null
+++ b/src/main/java/org/assertj/core/api/AbstractPredicateAssert.java
@@ -0,0 +1,127 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.error.ShouldNotAccept;
+import org.assertj.core.internal.Iterables;
+import org.assertj.core.presentation.PredicateDescription;
+import org.assertj.core.util.VisibleForTesting;
+
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.error.ShouldNotMatch.shouldNotMatch;
+import static org.assertj.core.presentation.PredicateDescription.fromDescription;
+
+/**
+ * Assertions for {@link Predicate}.
+ *
+ * @param type of the value contained in the {@link Predicate}.
+ *
+ * @author Filip Hrisafov
+ */
+public abstract class AbstractPredicateAssert, T> extends
+ AbstractAssert> {
+
+ @VisibleForTesting
+ Iterables iterables = Iterables.instance();
+
+ protected AbstractPredicateAssert(Predicate actual, Class> selfType) {
+ super(actual, selfType);
+ }
+
+ /**
+ *
+ * Verifies that the {@link Predicate} evaluates {@code true} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .accepts("something");
+ *
+ * Assertion will fail :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .accepts("something else");
+ *
+ * @return this assertion object.
+ */
+ public S accepts(T value) {
+ isNotNull();
+ if (!actual.test(value)) { throwAssertionError(shouldAccept(actual, value, fromDescription(info.description()))); }
+ return myself;
+ }
+
+ /**
+ *
+ * Verifies that the {@link Predicate} evaluates {@code false} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .rejects("something else");
+ *
+ * Assertion will fail :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .rejects("something");
+ *
+ * @return this assertion object.
+ */
+ public S rejects(T value) {
+ isNotNull();
+ if (actual.test(value)) { throwAssertionError(shouldNotAccept(actual, value, fromDescription(info.description()))); }
+ return myself;
+ }
+
+ /**
+ *
+ * Verifies that {@link Predicate} evaluates to {@code true} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).acceptsAll(elements);
+ *
+ * Assertion will fail:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).acceptsAll(Arrays.asList("first", "third"));
+ *
+ * @return this assertion object
+ */
+ public S acceptsAll(Iterable extends T> values) {
+ isNotNull();
+ iterables.assertAllMatch(info, values, actual);
+ return myself;
+ }
+
+ /**
+ *
+ * Verifies that {@link Predicate} evaluates to {@code false} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).rejectsAll(Arrays.asList("third", "fourth"));
+ *
+ * Assertion will fail:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).rejectsAll(Arrays.asList("first", "third"));
+ *
+ * @return this assertion object
+ */
+ public S rejectsAll(Iterable extends T> values) {
+ isNotNull();
+ iterables.assertNoneMatch(info, values, actual);
+ return myself;
+ }
+}
diff --git a/src/main/java/org/assertj/core/api/AbstractPredicateLikeAssert.java b/src/main/java/org/assertj/core/api/AbstractPredicateLikeAssert.java
new file mode 100644
index 0000000000..4c1d8aaeab
--- /dev/null
+++ b/src/main/java/org/assertj/core/api/AbstractPredicateLikeAssert.java
@@ -0,0 +1,128 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.internal.Iterables;
+import org.assertj.core.presentation.PredicateDescription;
+import org.assertj.core.util.VisibleForTesting;
+
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.presentation.PredicateDescription.fromDescription;
+
+/**
+ * Assertions for {@link Predicate}.
+ *
+ * @param the actual type
+ * @param the type of the wrapped variable in one of the special predicates
+ *
+ * @author Filip Hrisafov
+ */
+public abstract class AbstractPredicateLikeAssert, T, W> extends
+ AbstractAssert {
+
+ @VisibleForTesting
+ Iterables iterables = Iterables.instance();
+
+ @VisibleForTesting
+ Predicate wrappedPredicate;
+
+ protected AbstractPredicateLikeAssert(T actual, Predicate wrappedPredicate, Class> selfType) {
+ super(actual, selfType);
+ this.wrappedPredicate = wrappedPredicate;
+ }
+
+ /**
+ * Verifies that the {@link Predicate} evaluates {@code true} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .accepts("something");
+ *
+ * Assertion will fail :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .accepts("something else");
+ *
+ * @return this assertion object.
+ */
+ protected S acceptsInternal(W value) {
+ isNotNull();
+ if (!wrappedPredicate.test(value)) { throwAssertionError(shouldAccept(wrappedPredicate, value, fromDescription(info.description()))); }
+ return myself;
+ }
+
+ /**
+ * Verifies that the {@link Predicate} evaluates {@code false} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .rejects("something else");
+ *
+ * Assertion will fail :
+ * assertThat(predicate -> predicate.equals("something"))
+ * .rejects("something");
+ *
+ * @return this assertion object.
+ */
+ protected S rejectsInternal(W value) {
+ isNotNull();
+ if (wrappedPredicate.test(value)) { throwAssertionError(shouldNotAccept(wrappedPredicate, value, fromDescription(info.description()))); }
+ return myself;
+ }
+
+ /**
+ *
+ * Verifies that {@link Predicate} evaluates to {@code true} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).acceptsAll(elements);
+ *
+ * Assertion will fail:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).acceptsAll(Arrays.asList("first", "third"));
+ *
+ * @return this assertion object
+ */
+ protected S acceptsAllInternal(Iterable extends W> values) {
+ isNotNull();
+ iterables.assertAllMatch(info, values, wrappedPredicate);
+ return myself;
+ }
+
+ /**
+ *
+ * Verifies that {@link Predicate} evaluates to {@code false} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).rejectsAll(Arrays.asList("third", "fourth"));
+ *
+ * Assertion will fail:
+ *
+ * List elements = Arrays.asList("first", "second");
+ * assertThat(value -> elements.contains(value)).rejectsAll(Arrays.asList("first", "third"));
+ *
+ * @return this assertion object
+ */
+ protected S rejectsAllInternal(Iterable extends W> values) {
+ isNotNull();
+ iterables.assertNoneMatch(info, values, wrappedPredicate);
+ return myself;
+ }
+}
diff --git a/src/main/java/org/assertj/core/api/AssertionsForClassTypes.java b/src/main/java/org/assertj/core/api/AssertionsForClassTypes.java
index 70d2b3aa32..ce3c1c6567 100644
--- a/src/main/java/org/assertj/core/api/AssertionsForClassTypes.java
+++ b/src/main/java/org/assertj/core/api/AssertionsForClassTypes.java
@@ -35,6 +35,8 @@
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.concurrent.CompletableFuture;
+import java.util.function.IntPredicate;
+import java.util.function.Predicate;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.api.exception.RuntimeIOException;
diff --git a/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java b/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java
index 91d6e5b35f..fe379c915f 100644
--- a/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java
+++ b/src/main/java/org/assertj/core/api/AssertionsForInterfaceTypes.java
@@ -16,6 +16,10 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+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;
/**
@@ -218,4 +222,51 @@ public static > AbstractComparableAssert, T> a
public static T assertThat(T assertion) {
return assertion;
}
+
+ /**
+ * Create assertion for {@link Predicate}.
+ *
+ * @param actual the actual value.
+ * @param the type of the value contained in the {@link Predicate}.
+ * @return the created assertion object.
+ * @since 3.5.0
+ */
+ public static PredicateAssert assertThat(Predicate actual) {
+ return new PredicateAssert<>(actual);
+ }
+
+ /**
+ * Create assertion for {@link IntPredicate}.
+ *
+ * @param actual the actual value.
+ * @return the created assertion object.
+ * @since 3.5.0
+ */
+ public static IntPredicateAssert assertThat(IntPredicate actual) {
+ return new IntPredicateAssert(actual);
+ }
+
+ /**
+ * Create assertion for {@link LongPredicate}.
+ *
+ * @param actual the actual value.
+ * @return the created assertion object.
+ * @since 3.5.0
+ */
+ public static LongPredicateAssert assertThat(LongPredicate actual) {
+ return new LongPredicateAssert(actual);
+ }
+
+ /**
+ * Create assertion for {@link DoublePredicate}.
+ *
+ * @param actual the actual value.
+ * @return the created assertion object.
+ * @since 3.5.0
+ */
+ public static DoublePredicateAssert assertThat(DoublePredicate actual) {
+ return new DoublePredicateAssert(actual);
+ }
+
+
}
diff --git a/src/main/java/org/assertj/core/api/DoublePredicateAssert.java b/src/main/java/org/assertj/core/api/DoublePredicateAssert.java
new file mode 100644
index 0000000000..170a3480e9
--- /dev/null
+++ b/src/main/java/org/assertj/core/api/DoublePredicateAssert.java
@@ -0,0 +1,106 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.DoublePredicate;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.DoubleStream;
+
+/**
+ * Assertions for {@link Predicate}.
+ *
+ * @author Filip Hrisafov
+ * @since 3.5.0
+ */
+public class DoublePredicateAssert extends AbstractPredicateLikeAssert {
+
+ public DoublePredicateAssert(DoublePredicate actual) {
+ super(actual, toPredicate(actual), DoublePredicateAssert.class);
+ }
+
+ private static Predicate toPredicate(DoublePredicate actual) {
+ return actual != null ? actual::test : null;
+ }
+
+ /**
+ *
+ * Verifies that the {@link DoublePredicate} evaluates {@code true} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate < 2)
+ * .accepts(1);
+ *
+ * Assertion will fail :
+ *
assertThat(predicate -> predicate < 2)
+ * .accepts(2);
+ *
+ * @return this assertion object.
+ */
+ public DoublePredicateAssert accepts(double value) {
+ return acceptsInternal(value);
+ }
+
+ /**
+ * Verifies that the {@link DoublePredicate} evaluates {@code false} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate < 2)
+ * .rejects(3);
+ *
+ * Assertion will fail :
+ *
assertThat(predicate -> predicate < 2)
+ * .rejects(1);
+ *
+ * @return this assertion object.
+ */
+ public DoublePredicateAssert rejects(double value) {
+ return rejectsInternal(value);
+ }
+
+ /**
+ *
+ * Verifies that {@link DoublePredicate} evaluates to {@code true} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * assertThat(value -> value < 2).acceptsAll(0, 1);
+ *
+ * Assertion will fail:
+ *
+ * assertThat(value -> value < 2).acceptsAll(1, 2);
+ *
+ * @return this assertion object
+ */
+ public DoublePredicateAssert acceptsAll(double... values) {
+ return acceptsAllInternal(DoubleStream.of(values).boxed().collect(Collectors.toList()));
+ }
+
+ /**
+ *
+ * Verifies that {@link DoublePredicate} evaluates to {@code false} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * assertThat(value -> value < 2).rejectsAll(0, 1);
+ *
+ * Assertion will fail:
+ *
+ * assertThat(value -> value < 2).rejectsAll(1, 2);
+ *
+ * @return this assertion object
+ */
+ public DoublePredicateAssert rejectsAll(double... values) {
+ return rejectsAllInternal(DoubleStream.of(values).boxed().collect(Collectors.toList()));
+ }
+}
diff --git a/src/main/java/org/assertj/core/api/IntPredicateAssert.java b/src/main/java/org/assertj/core/api/IntPredicateAssert.java
new file mode 100644
index 0000000000..d0760476ce
--- /dev/null
+++ b/src/main/java/org/assertj/core/api/IntPredicateAssert.java
@@ -0,0 +1,106 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.IntPredicate;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Assertions for {@link Predicate}.
+ *
+ * @author Filip Hrisafov
+ * @since 3.5.0
+ */
+public class IntPredicateAssert extends AbstractPredicateLikeAssert {
+
+ public IntPredicateAssert(IntPredicate actual) {
+ super(actual, toPredicate(actual), IntPredicateAssert.class);
+ }
+
+ private static Predicate toPredicate(IntPredicate actual) {
+ return actual != null ? actual::test : null;
+ }
+
+ /**
+ *
+ * Verifies that the {@link IntPredicate} evaluates {@code true} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate < 2)
+ * .accepts(1);
+ *
+ * Assertion will fail :
+ * assertThat(predicate -> predicate < 2)
+ * .accepts(2);
+ *
+ * @return this assertion object.
+ */
+ public IntPredicateAssert accepts(int value) {
+ return acceptsInternal(value);
+ }
+
+ /**
+ * Verifies that the {@link IntPredicate} evaluates {@code false} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate < 2)
+ * .rejects(3);
+ *
+ * Assertion will fail :
+ * assertThat(predicate -> predicate < 2)
+ * .rejects(1);
+ *
+ * @return this assertion object.
+ */
+ public IntPredicateAssert rejects(int value) {
+ return rejectsInternal(value);
+ }
+
+ /**
+ *
+ * Verifies that {@link IntPredicate} evaluates to {@code true} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * assertThat(value -> value < 2).acceptsAll(0, 1);
+ *
+ * Assertion will fail:
+ *
+ * assertThat(value -> value < 2).acceptsAll(1, 2);
+ *
+ * @return this assertion object
+ */
+ public IntPredicateAssert acceptsAll(int... values) {
+ return acceptsAllInternal(IntStream.of(values).boxed().collect(Collectors.toList()));
+ }
+
+ /**
+ *
+ * Verifies that {@link IntPredicate} evaluates to {@code false} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * assertThat(value -> value < 2).rejectsAll(0, 1);
+ *
+ * Assertion will fail:
+ *
+ * assertThat(value -> value < 2).rejectsAll(1, 2);
+ *
+ * @return this assertion object
+ */
+ public IntPredicateAssert rejectsAll(int... values) {
+ return rejectsAllInternal(IntStream.of(values).boxed().collect(Collectors.toList()));
+ }
+}
diff --git a/src/main/java/org/assertj/core/api/LongPredicateAssert.java b/src/main/java/org/assertj/core/api/LongPredicateAssert.java
new file mode 100644
index 0000000000..39a3acd7fe
--- /dev/null
+++ b/src/main/java/org/assertj/core/api/LongPredicateAssert.java
@@ -0,0 +1,106 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.LongStream;
+
+/**
+ * Assertions for {@link LongPredicate}.
+ *
+ * @author Filip Hrisafov
+ * @since 3.5.0
+ */
+public class LongPredicateAssert extends AbstractPredicateLikeAssert {
+
+ public LongPredicateAssert(LongPredicate actual) {
+ super(actual, toPredicate(actual), LongPredicateAssert.class);
+ }
+
+ private static Predicate toPredicate(LongPredicate actual) {
+ return actual != null ? actual::test : null;
+ }
+
+ /**
+ *
+ * Verifies that the {@link LongPredicate} evaluates {@code true} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate < 2)
+ * .accepts(1);
+ *
+ * Assertion will fail :
+ *
assertThat(predicate -> predicate < 2)
+ * .accepts(2);
+ *
+ * @return this assertion object.
+ */
+ public LongPredicateAssert accepts(long value) {
+ return acceptsInternal(value);
+ }
+
+ /**
+ * Verifies that the {@link LongPredicate} evaluates {@code false} for the given value.
+ *
+ * Assertion will pass :
+ * assertThat(predicate -> predicate < 2)
+ * .rejects(3);
+ *
+ * Assertion will fail :
+ *
assertThat(predicate -> predicate < 2)
+ * .rejects(1);
+ *
+ * @return this assertion object.
+ */
+ public LongPredicateAssert rejects(long value) {
+ return rejectsInternal(value);
+ }
+
+ /**
+ *
+ * Verifies that {@link LongPredicate} evaluates to {@code true} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * assertThat(value -> value < 2).acceptsAll(0, 1);
+ *
+ * Assertion will fail:
+ *
+ * assertThat(value -> value < 2).acceptsAll(1, 2);
+ *
+ * @return this assertion object
+ */
+ public LongPredicateAssert acceptsAll(long... values) {
+ return acceptsAllInternal(LongStream.of(values).boxed().collect(Collectors.toList()));
+ }
+
+ /**
+ *
+ * Verifies that {@link LongPredicate} evaluates to {@code false} for all the elements from the {@code values}.
+ *
+ * Assertion will pass:
+ *
+ * assertThat(value -> value < 2).rejectsAll(0, 1);
+ *
+ * Assertion will fail:
+ *
+ * assertThat(value -> value < 2).rejectsAll(1, 2);
+ *
+ * @return this assertion object
+ */
+ public LongPredicateAssert rejectsAll(long... values) {
+ return rejectsAllInternal(LongStream.of(values).boxed().collect(Collectors.toList()));
+ }
+}
diff --git a/src/main/java/org/assertj/core/api/PredicateAssert.java b/src/main/java/org/assertj/core/api/PredicateAssert.java
new file mode 100644
index 0000000000..4f56343476
--- /dev/null
+++ b/src/main/java/org/assertj/core/api/PredicateAssert.java
@@ -0,0 +1,30 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.Predicate;
+
+/**
+ * Assertions for {@link Predicate}.
+ *
+ * @param type of the value contained in the {@link Predicate}.
+ * @author Filip Hrisafov
+ *
+ * @since 3.5.0
+ */
+public class PredicateAssert extends AbstractPredicateAssert, T> {
+
+ protected PredicateAssert(Predicate actual) {
+ super(actual, PredicateAssert.class);
+ }
+}
diff --git a/src/main/java/org/assertj/core/error/NoElementsShouldMatch.java b/src/main/java/org/assertj/core/error/NoElementsShouldMatch.java
new file mode 100644
index 0000000000..5f17a0e0f7
--- /dev/null
+++ b/src/main/java/org/assertj/core/error/NoElementsShouldMatch.java
@@ -0,0 +1,26 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+public class NoElementsShouldMatch extends BasicErrorMessageFactory {
+
+ public static ErrorMessageFactory noElementsShouldMatch(Object actual, T elementMatchingPredicate) {
+ return new NoElementsShouldMatch(actual, elementMatchingPredicate);
+ }
+
+ private NoElementsShouldMatch(Object actual, Object satisfies) {
+ super("%nExpecting no elements of:%n <%s>%nto match given predicate but this element did:%n <%s>", actual,
+ satisfies);
+ }
+
+}
diff --git a/src/main/java/org/assertj/core/error/ShouldAccept.java b/src/main/java/org/assertj/core/error/ShouldAccept.java
new file mode 100644
index 0000000000..4515c2cf96
--- /dev/null
+++ b/src/main/java/org/assertj/core/error/ShouldAccept.java
@@ -0,0 +1,48 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.presentation.PredicateDescription;
+
+import static java.lang.String.format;
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Creates an error message indicating that an assertion that verifies that
+ * {@link Predicate}
accepts a value failed.
+ *
+ * @author Filip Hrisafov
+ */
+public class ShouldAccept extends BasicErrorMessageFactory {
+
+ /**
+ * Creates a new {@link ShouldAccept}.
+ *
+ * @param guarantees that the type of the value value and the generic type of the {@code Predicate} are the same.
+ * @param predicate the {@code Predicate}.
+ * @param value the value value in the failed assertion.
+ * @param description predicate description to include in the error message,
+ * @return the created {@code ErrorMessageFactory}.
+ */
+ public static ErrorMessageFactory shouldAccept(Predicate super T> predicate, T value,
+ PredicateDescription description) {
+ requireNonNull(description, "The predicate description must not be null");
+ return new ShouldAccept(predicate, value, description);
+ }
+
+ private ShouldAccept(Predicate> predicate, Object value, PredicateDescription description) {
+ super("%nExpecting:%n <%s predicate>%nto accept <%s> but it did not.", description, value);
+ }
+}
diff --git a/src/main/java/org/assertj/core/error/ShouldNotAccept.java b/src/main/java/org/assertj/core/error/ShouldNotAccept.java
new file mode 100644
index 0000000000..9288eb77a8
--- /dev/null
+++ b/src/main/java/org/assertj/core/error/ShouldNotAccept.java
@@ -0,0 +1,48 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.presentation.PredicateDescription;
+
+import static java.lang.String.format;
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Creates an error message indicating that an assertion that verifies that
+ * {@link Predicate}
not accepting a value failed.
+ *
+ * @author Filip Hrisafov
+ */
+public class ShouldNotAccept extends BasicErrorMessageFactory {
+
+ /**
+ * Creates a new {@link ShouldNotAccept}.
+ *
+ * @param guarantees that the type of the value value and the generic type of the {@code Predicate} are the same.
+ * @param predicate the {@code Predicate}.
+ * @param value the value value in the failed assertion.
+ * @param description predicate description to include in the error message,
+ * @return the created {@code ErrorMessageFactory}.
+ */
+ public static ErrorMessageFactory shouldNotAccept(Predicate super T> predicate, T value,
+ PredicateDescription description) {
+ requireNonNull(description, "The predicate description must not be null");
+ return new ShouldNotAccept(predicate, value, description);
+ }
+
+ private ShouldNotAccept(Predicate> predicate, Object value, PredicateDescription description) {
+ super("%nExpecting:%n <%s predicate>%nnot to accept <%s> but it did.", description, value);
+ }
+}
diff --git a/src/main/java/org/assertj/core/error/ShouldNotMatch.java b/src/main/java/org/assertj/core/error/ShouldNotMatch.java
new file mode 100644
index 0000000000..592a9815ec
--- /dev/null
+++ b/src/main/java/org/assertj/core/error/ShouldNotMatch.java
@@ -0,0 +1,58 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.presentation.PredicateDescription;
+
+import static java.lang.String.format;
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Creates an error message indicating that an assertion that verifies that a value not satisfying a
+ * {@link Predicate}
failed.
+ */
+public class ShouldNotMatch extends BasicErrorMessageFactory {
+
+ // @format:off
+ public static final String ADVICE = format("%n%n"+
+ "You can use 'doesNotMatch(Predicate p, String description)' to have a better error message%n" +
+ "For example:%n" +
+ " assertThat(player).doesNotMatch(p -> p.isRookie(), \"is not rookie\");%n" +
+ "will give an error message looking like:%n" +
+ "%n" +
+ "Expecting:%n" +
+ " %n" +
+ "not to match 'is not rookie' predicate");
+ // @format:on
+
+ /**
+ * Creates a new {@link ShouldNotMatch}.
+ *
+ * @param guarantees that the type of the actual value and the generic type of the {@code Predicate} are the same.
+ * @param actual the actual value in the failed assertion.
+ * @param predicate the {@code Predicate}.
+ * @param predicateDescription predicate description to include in the error message
+ * @return the created {@code ErrorMessageFactory}.
+ */
+ public static ErrorMessageFactory shouldNotMatch(T actual, Predicate super T> predicate,
+ PredicateDescription predicateDescription) {
+ requireNonNull(predicateDescription, "The predicate description must not be null");
+ return new ShouldNotMatch(actual, predicate, predicateDescription);
+ }
+
+ private ShouldNotMatch(Object actual, Predicate> predicate, PredicateDescription description) {
+ super("%nExpecting:%n <%s>%nnot to match %s predicate." + (description.isDefault() ? ADVICE : ""), actual, description);
+ }
+}
diff --git a/src/main/java/org/assertj/core/internal/Iterables.java b/src/main/java/org/assertj/core/internal/Iterables.java
index a281c35eb2..a3c12989ee 100644
--- a/src/main/java/org/assertj/core/internal/Iterables.java
+++ b/src/main/java/org/assertj/core/internal/Iterables.java
@@ -24,6 +24,7 @@
import static org.assertj.core.error.ElementsShouldHaveExactly.elementsShouldHaveExactly;
import static org.assertj.core.error.ElementsShouldNotBe.elementsShouldNotBe;
import static org.assertj.core.error.ElementsShouldNotHave.elementsShouldNotHave;
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
import static org.assertj.core.error.ShouldBeEmpty.shouldBeEmpty;
import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty;
import static org.assertj.core.error.ShouldBeSubsetOf.shouldBeSubsetOf;
@@ -825,6 +826,16 @@ public void assertContainsExactly(AssertionInfo info, Iterable> actual, Object
shouldContainExactly(actual, values, diff.missing, diff.unexpected, comparisonStrategy));
}
+ public void assertNoneMatch(AssertionInfo info, Iterable extends E> actual, Predicate super E> predicate) {
+ assertNotNull(info, actual);
+ predicates.assertIsNotNull(predicate);
+ stream(actual.spliterator(), false).filter(predicate)
+ .findFirst()
+ .ifPresent(e -> {
+ throw failures.failure(info, noElementsShouldMatch(actual, e));
+ });
+ }
+
public void assertContainsExactlyInAnyOrder(AssertionInfo info, Iterable> actual, Object[] values) {
checkIsNotNull(values);
assertNotNull(info, actual);
diff --git a/src/main/java/org/assertj/core/presentation/PredicateDescription.java b/src/main/java/org/assertj/core/presentation/PredicateDescription.java
index bda7537abf..423bdf0e84 100644
--- a/src/main/java/org/assertj/core/presentation/PredicateDescription.java
+++ b/src/main/java/org/assertj/core/presentation/PredicateDescription.java
@@ -16,6 +16,8 @@
import java.util.function.Predicate;
+import org.assertj.core.description.Description;
+
/**
* Encapsulate a {@link Predicate} description to be able to control how it is formatted in error messages using a
* {@link Representation}.
@@ -43,4 +45,12 @@ public boolean isDefault() {
return DEFAULT.equals(description);
}
+ public static PredicateDescription fromDescription(Description description) {
+ PredicateDescription desc = PredicateDescription.GIVEN;
+ if (description != null) {
+ String value = description.value();
+ desc = value != null ? new PredicateDescription(value) : desc;
+ }
+ return desc;
+ }
}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoublePredicate_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoublePredicate_Test.java
new file mode 100644
index 0000000000..95028c3553
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_DoublePredicate_Test.java
@@ -0,0 +1,48 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.DoublePredicate;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+/**
+ * Tests for {@link Assertions#assertThat(DoublePredicate)}
.
+ *
+ * @author Filip Hrisafov
+ */
+public class Assertions_assertThat_with_DoublePredicate_Test {
+
+ private DoublePredicate actual;
+
+ @Before
+ public void before() {
+ actual = value -> value == 1;
+ }
+
+ @Test
+ public void should_create_Assert() {
+ DoublePredicateAssert assertions = Assertions.assertThat(actual);
+ assertNotNull(assertions);
+ }
+
+ @Test
+ public void should_pass_actual() {
+ DoublePredicateAssert assertions = Assertions.assertThat(actual);
+ assertSame(actual, assertions.actual);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntPredicate_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntPredicate_Test.java
new file mode 100644
index 0000000000..4bfc3a2f9d
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_IntPredicate_Test.java
@@ -0,0 +1,48 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.IntPredicate;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+/**
+ * Tests for {@link Assertions#assertThat(IntPredicate)}
.
+ *
+ * @author Filip Hrisafov
+ */
+public class Assertions_assertThat_with_IntPredicate_Test {
+
+ private IntPredicate actual;
+
+ @Before
+ public void before() {
+ actual = value -> value == 1;
+ }
+
+ @Test
+ public void should_create_Assert() {
+ IntPredicateAssert assertions = Assertions.assertThat(actual);
+ assertNotNull(assertions);
+ }
+
+ @Test
+ public void should_pass_actual() {
+ IntPredicateAssert assertions = Assertions.assertThat(actual);
+ assertSame(actual, assertions.actual);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongPredicate_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongPredicate_Test.java
new file mode 100644
index 0000000000..ef2cd7f3c4
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_LongPredicate_Test.java
@@ -0,0 +1,48 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.LongPredicate;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+/**
+ * Tests for {@link Assertions#assertThat(LongPredicate)}
.
+ *
+ * @author Filip Hrisafov
+ */
+public class Assertions_assertThat_with_LongPredicate_Test {
+
+ private LongPredicate actual;
+
+ @Before
+ public void before() {
+ actual = value -> value == 1;
+ }
+
+ @Test
+ public void should_create_Assert() {
+ LongPredicateAssert assertions = Assertions.assertThat(actual);
+ assertNotNull(assertions);
+ }
+
+ @Test
+ public void should_pass_actual() {
+ LongPredicateAssert assertions = Assertions.assertThat(actual);
+ assertSame(actual, assertions.actual);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Predicate_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Predicate_Test.java
new file mode 100644
index 0000000000..939731b1b5
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_with_Predicate_Test.java
@@ -0,0 +1,48 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.Predicate;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+/**
+ * Tests for {@link Assertions#assertThat(Predicate)}
.
+ *
+ * @author Filip Hrisafov
+ */
+public class Assertions_assertThat_with_Predicate_Test {
+
+ private Predicate actual;
+
+ @Before
+ public void before() {
+ actual = value -> value.equals("something");
+ }
+
+ @Test
+ public void should_create_Assert() {
+ PredicateAssert assertions = Assertions.assertThat(actual);
+ assertNotNull(assertions);
+ }
+
+ @Test
+ public void should_pass_actual() {
+ PredicateAssert assertions = Assertions.assertThat(actual);
+ assertSame(actual, assertions.actual);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/BaseTestTemplate.java b/src/test/java/org/assertj/core/api/BaseTestTemplate.java
index 92823367b4..e3f76d6536 100644
--- a/src/test/java/org/assertj/core/api/BaseTestTemplate.java
+++ b/src/test/java/org/assertj/core/api/BaseTestTemplate.java
@@ -45,7 +45,7 @@
*
* @author Olivier Michallat
*/
-public abstract class BaseTestTemplate, A> {
+public abstract class BaseTestTemplate, A> extends BaseTest {
protected S assertions;
protected Objects objects;
protected Conditions conditions;
diff --git a/src/test/java/org/assertj/core/api/DoublePredicateAssertBaseTest.java b/src/test/java/org/assertj/core/api/DoublePredicateAssertBaseTest.java
new file mode 100644
index 0000000000..8b90a3a6a9
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/DoublePredicateAssertBaseTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.DoublePredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.internal.Iterables;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Base class for {@link DoublePredicateAssert} tests.
+ *
+ * @author Filip Hrisafov
+ */
+public abstract class DoublePredicateAssertBaseTest extends BaseTestTemplate {
+
+ protected Iterables iterables;
+ protected Predicate wrapped;
+
+ @Override
+ protected DoublePredicateAssert create_assertions() {
+ return new DoublePredicateAssert(value -> value <= 2);
+ }
+
+ @Override
+ protected void inject_internal_objects() {
+ super.inject_internal_objects();
+ iterables = mock(Iterables.class);
+ assertions.iterables = iterables;
+ wrapped = assertions.wrappedPredicate;
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/IntPredicateAssertBaseTest.java b/src/test/java/org/assertj/core/api/IntPredicateAssertBaseTest.java
new file mode 100644
index 0000000000..570de5f536
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/IntPredicateAssertBaseTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.IntPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.internal.Iterables;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Base class for {@link IntPredicateAssert} tests.
+ *
+ * @author Filip Hrisafov
+ */
+public abstract class IntPredicateAssertBaseTest extends BaseTestTemplate {
+
+ protected Iterables iterables;
+ protected Predicate wrapped;
+
+ @Override
+ protected IntPredicateAssert create_assertions() {
+ return new IntPredicateAssert(value -> value <= 2);
+ }
+
+ @Override
+ protected void inject_internal_objects() {
+ super.inject_internal_objects();
+ iterables = mock(Iterables.class);
+ assertions.iterables = iterables;
+ wrapped = assertions.wrappedPredicate;
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/LongPredicateAssertBaseTest.java b/src/test/java/org/assertj/core/api/LongPredicateAssertBaseTest.java
new file mode 100644
index 0000000000..d78e1ffc8a
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/LongPredicateAssertBaseTest.java
@@ -0,0 +1,44 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.internal.Iterables;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Base class for {@link LongPredicateAssert} tests.
+ *
+ * @author Filip Hrisafov
+ */
+public abstract class LongPredicateAssertBaseTest extends BaseTestTemplate {
+
+ protected Iterables iterables;
+ protected Predicate wrapped;
+
+ @Override
+ protected LongPredicateAssert create_assertions() {
+ return new LongPredicateAssert(value -> value <= 2);
+ }
+
+ @Override
+ protected void inject_internal_objects() {
+ super.inject_internal_objects();
+ iterables = mock(Iterables.class);
+ assertions.iterables = iterables;
+ wrapped = assertions.wrappedPredicate;
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/PredicateAssertBaseTest.java b/src/test/java/org/assertj/core/api/PredicateAssertBaseTest.java
new file mode 100644
index 0000000000..a9a389ff92
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/PredicateAssertBaseTest.java
@@ -0,0 +1,41 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.internal.Iterables;
+
+import static org.mockito.Mockito.mock;
+
+/**
+ * Base class for {@link PredicateAssert} tests.
+ *
+ * @author Filip Hrisafov
+ */
+public abstract class PredicateAssertBaseTest extends BaseTestTemplate, Predicate> {
+
+ protected Iterables iterables;
+
+ @Override
+ protected PredicateAssert create_assertions() {
+ return new PredicateAssert<>(value -> true);
+ }
+
+ @Override
+ protected void inject_internal_objects() {
+ super.inject_internal_objects();
+ iterables = mock(Iterables.class);
+ assertions.iterables = iterables;
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_acceptsAll_Test.java b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_acceptsAll_Test.java
new file mode 100644
index 0000000000..231c29f0a7
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_acceptsAll_Test.java
@@ -0,0 +1,65 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.doublepredicate;
+
+import java.util.function.DoublePredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.DoublePredicateAssert;
+import org.assertj.core.api.DoublePredicateAssertBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class DoublePredicateAssert_acceptsAll_Test extends DoublePredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ double[] acceptedValues = new double[] { 1, 2 };
+
+ assertThat((DoublePredicate) null).acceptsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_all_values() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double[] matchValues = new double[] { 1, 2, 3 };
+ thrown.expectAssertionError(elementsShouldMatch(matchValues, 3D, wrapPredicate).create());
+ assertThat(predicate).acceptsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_all_values() {
+ DoublePredicate predicate = val -> val <= 2;
+ assertThat(predicate).acceptsAll(1, 2);
+ }
+
+ @Override
+ protected DoublePredicateAssert invoke_api_method() {
+ return assertions.acceptsAll(1, 2);
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertAllMatch(getInfo(assertions), newArrayList(1D, 2D), wrapped);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_accepts_Test.java b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_accepts_Test.java
new file mode 100644
index 0000000000..d6fca8ae4b
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_accepts_Test.java
@@ -0,0 +1,73 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.doublepredicate;
+
+import java.util.function.DoublePredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.error.ShouldAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.error.ShouldMatch.shouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class DoublePredicateAssert_accepts_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((DoublePredicate) null).accepts(1);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_string_description() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_description() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TextDescription("test")).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_value() {
+ DoublePredicate predicate = val -> val <= 2;
+ assertThat(predicate).accepts(1);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejectsAll_Test.java b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejectsAll_Test.java
new file mode 100644
index 0000000000..e23781125b
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejectsAll_Test.java
@@ -0,0 +1,68 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.doublepredicate;
+
+import java.util.List;
+import java.util.function.DoublePredicate;
+import java.util.stream.Collectors;
+import java.util.stream.DoubleStream;
+
+import org.assertj.core.api.DoublePredicateAssert;
+import org.assertj.core.api.DoublePredicateAssertBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class DoublePredicateAssert_rejectsAll_Test extends DoublePredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ double[] acceptedValues = new double[] { 1, 2, 3 };
+
+ assertThat((DoublePredicate) null).rejectsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_some_value() {
+ DoublePredicate predicate = num -> num <= 2;
+ double[] matchValues = new double[] { 1, 2, 3 };
+ List matchValuesList = DoubleStream.of(matchValues).boxed().collect(Collectors.toList());
+ thrown.expectAssertionError(noElementsShouldMatch(matchValuesList, 1D).create());
+ assertThat(predicate).rejectsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_no_value() {
+ DoublePredicate predicate = num -> num <= 2;
+ double[] acceptedValues = new double[] { 3, 4, 5 };
+ assertThat(predicate).rejectsAll(acceptedValues);
+ }
+
+ @Override
+ protected DoublePredicateAssert invoke_api_method() {
+ return assertions.rejectsAll(3, 4);
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertNoneMatch(getInfo(assertions), newArrayList(3D, 4D), wrapped);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejects_Test.java b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejects_Test.java
new file mode 100644
index 0000000000..5a06b61312
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/doublepredicate/DoublePredicateAssert_rejects_Test.java
@@ -0,0 +1,73 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.doublepredicate;
+
+import java.util.function.DoublePredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.error.ShouldNotAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.error.ShouldNotMatch.shouldNotMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class DoublePredicateAssert_rejects_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((DoublePredicate) null).accepts(1);
+ }
+
+ @Test
+ public void should_pass_when_predicate_does_not_accept_value() {
+ DoublePredicate predicate = val -> val <= 2;
+ assertThat(predicate).rejects(3);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).rejects(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_string_description() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").rejects(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_description() {
+ DoublePredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ double expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TextDescription("test")).rejects(expectedValue);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_acceptsAll_Test.java b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_acceptsAll_Test.java
new file mode 100644
index 0000000000..5fedf243b1
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_acceptsAll_Test.java
@@ -0,0 +1,65 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.intpredicate;
+
+import java.util.function.IntPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.IntPredicateAssert;
+import org.assertj.core.api.IntPredicateAssertBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class IntPredicateAssert_acceptsAll_Test extends IntPredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ int[] acceptedValues = new int[] { 1, 2 };
+
+ assertThat((IntPredicate) null).acceptsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_values() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int[] matchValues = new int[] { 1, 2, 3 };
+ thrown.expectAssertionError(elementsShouldMatch(matchValues, 3, wrapPredicate).create());
+ assertThat(predicate).acceptsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_all_values() {
+ IntPredicate predicate = val -> val <= 2;
+ assertThat(predicate).acceptsAll(1, 2);
+ }
+
+ @Override
+ protected IntPredicateAssert invoke_api_method() {
+ return assertions.acceptsAll(1, 2);
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertAllMatch(getInfo(assertions), newArrayList(1, 2), wrapped);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_accepts_Test.java b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_accepts_Test.java
new file mode 100644
index 0000000000..9fc383b890
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_accepts_Test.java
@@ -0,0 +1,74 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.intpredicate;
+
+import java.util.function.IntPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.error.ShouldAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.error.ShouldMatch.shouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class IntPredicateAssert_accepts_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((IntPredicate) null).accepts(1);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_string_description() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_description() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TextDescription("test")).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_value() {
+ IntPredicate predicate = val -> val <= 2;
+ assertThat(predicate).accepts(1);
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejectsAll_Test.java b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejectsAll_Test.java
new file mode 100644
index 0000000000..8c2ad27464
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejectsAll_Test.java
@@ -0,0 +1,68 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.intpredicate;
+
+import java.util.List;
+import java.util.function.IntPredicate;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import org.assertj.core.api.IntPredicateAssert;
+import org.assertj.core.api.IntPredicateAssertBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class IntPredicateAssert_rejectsAll_Test extends IntPredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ int[] acceptedValues = new int[] { 1, 2, 3 };
+
+ assertThat((IntPredicate) null).rejectsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_some_value() {
+ IntPredicate predicate = num -> num <= 2;
+ int[] matchValues = new int[] { 1, 2, 3 };
+ List matchValuesList = IntStream.of(matchValues).boxed().collect(Collectors.toList());
+ thrown.expectAssertionError(noElementsShouldMatch(matchValuesList, 1).create());
+ assertThat(predicate).rejectsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_no_value() {
+ IntPredicate predicate = num -> num <= 2;
+ int[] acceptedValues = new int[] { 3, 4, 5 };
+ assertThat(predicate).rejectsAll(acceptedValues);
+ }
+
+ @Override
+ protected IntPredicateAssert invoke_api_method() {
+ return assertions.rejectsAll(3, 4);
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertNoneMatch(getInfo(assertions), newArrayList(3, 4), wrapped);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejects_Test.java b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejects_Test.java
new file mode 100644
index 0000000000..4fb426f625
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/intpredicate/IntPredicateAssert_rejects_Test.java
@@ -0,0 +1,74 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.intpredicate;
+
+import java.util.function.IntPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.error.ShouldNotAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.error.ShouldNotMatch.shouldNotMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class IntPredicateAssert_rejects_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((IntPredicate) null).accepts(1);
+ }
+
+ @Test
+ public void should_pass_when_predicate_does_not_accept_value() {
+ IntPredicate predicate = val -> val <= 2;
+ assertThat(predicate).rejects(3);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).rejects(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_string_description() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").rejects(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_description() {
+ IntPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ int expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TextDescription("test")).rejects(expectedValue);
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_acceptsAll_Test.java b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_acceptsAll_Test.java
new file mode 100644
index 0000000000..65dbdeb142
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_acceptsAll_Test.java
@@ -0,0 +1,66 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.longpredicate;
+
+import java.util.function.IntPredicate;
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.LongPredicateAssert;
+import org.assertj.core.api.LongPredicateAssertBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class LongPredicateAssert_acceptsAll_Test extends LongPredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ int[] acceptedValues = new int[] { 1, 2 };
+
+ assertThat((IntPredicate) null).acceptsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_values() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long[] matchValues = new long[] { 1, 2, 3 };
+ thrown.expectAssertionError(elementsShouldMatch(matchValues, 3L, wrapPredicate).create());
+ assertThat(predicate).acceptsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_all_values() {
+ IntPredicate predicate = val -> val <= 2;
+ assertThat(predicate).acceptsAll(1, 2);
+ }
+
+ @Override
+ protected LongPredicateAssert invoke_api_method() {
+ return assertions.acceptsAll(1, 2);
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertAllMatch(getInfo(assertions), newArrayList(1L, 2L), wrapped);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_accepts_Test.java b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_accepts_Test.java
new file mode 100644
index 0000000000..fc98db85ed
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_accepts_Test.java
@@ -0,0 +1,74 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.longpredicate;
+
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.error.ShouldAccept;
+import org.assertj.core.internal.TestDescription;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.error.ShouldMatch.shouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class LongPredicateAssert_accepts_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((LongPredicate) null).accepts(1);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_string_description() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_description() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long expectedValue = 3;
+ thrown.expectAssertionError(shouldAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TestDescription("test")).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_value() {
+ LongPredicate predicate = val -> val <= 2;
+ assertThat(predicate).accepts(1);
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejectsAll_Test.java b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejectsAll_Test.java
new file mode 100644
index 0000000000..f1df788978
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejectsAll_Test.java
@@ -0,0 +1,68 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.longpredicate;
+
+import java.util.List;
+import java.util.function.LongPredicate;
+import java.util.stream.Collectors;
+import java.util.stream.LongStream;
+
+import org.assertj.core.api.LongPredicateAssert;
+import org.assertj.core.api.LongPredicateAssertBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class LongPredicateAssert_rejectsAll_Test extends LongPredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ long[] acceptedValues = new long[] { 1, 2, 3 };
+
+ assertThat((LongPredicate) null).rejectsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_some_value() {
+ LongPredicate predicate = num -> num <= 2;
+ long[] matchValues = new long[] { 1, 2, 3 };
+ List matchValuesList = LongStream.of(matchValues).boxed().collect(Collectors.toList());
+ thrown.expectAssertionError(noElementsShouldMatch(matchValuesList, 1L).create());
+ assertThat(predicate).rejectsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_no_value() {
+ LongPredicate predicate = num -> num <= 2;
+ long[] acceptedValues = new long[] { 3, 4, 5 };
+ assertThat(predicate).rejectsAll(acceptedValues);
+ }
+
+ @Override
+ protected LongPredicateAssert invoke_api_method() {
+ return assertions.rejectsAll(3, 4);
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertNoneMatch(getInfo(assertions), newArrayList(3L, 4L), wrapped);
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejects_Test.java b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejects_Test.java
new file mode 100644
index 0000000000..64d6c6feae
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/longpredicate/LongPredicateAssert_rejects_Test.java
@@ -0,0 +1,74 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.longpredicate;
+
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.error.ShouldNotAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.error.ShouldNotMatch.shouldNotMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class LongPredicateAssert_rejects_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((LongPredicate) null).accepts(1);
+ }
+
+ @Test
+ public void should_pass_when_predicate_does_not_accept_value() {
+ LongPredicate predicate = val -> val <= 2;
+ assertThat(predicate).rejects(3);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).rejects(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_string_description() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").rejects(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_description() {
+ LongPredicate predicate = val -> val <= 2;
+ Predicate wrapPredicate = predicate::test;
+ long expectedValue = 2;
+ thrown.expectAssertionError(shouldNotAccept(wrapPredicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TextDescription("test")).rejects(expectedValue);
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/api/predicate/PredicateAssert_acceptsAll_Test.java b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_acceptsAll_Test.java
new file mode 100644
index 0000000000..95863d2dec
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_acceptsAll_Test.java
@@ -0,0 +1,69 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.predicate;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.PredicateAssert;
+import org.assertj.core.api.PredicateAssertBaseTest;
+import org.assertj.core.util.Sets;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ElementsShouldMatch.elementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class PredicateAssert_acceptsAll_Test extends PredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ LinkedHashSet acceptedValues = Sets.newLinkedHashSet("first", "second");
+
+ assertThat((Predicate) null).acceptsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_values() {
+ Set acceptedValues = Sets.newLinkedHashSet("first", "second");
+ Predicate predicate = acceptedValues::contains;
+ Set matchValues = Sets.newHashSet(acceptedValues);
+ matchValues.add("third");
+ thrown.expectAssertionError(elementsShouldMatch(matchValues, "third", predicate).create());
+ assertThat(predicate).acceptsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_all_values() {
+ Set acceptedValues = Sets.newLinkedHashSet("first", "second");
+ Predicate predicate = acceptedValues::contains;
+ assertThat(predicate).acceptsAll(acceptedValues);
+ }
+
+ @Override
+ protected PredicateAssert invoke_api_method() {
+ return assertions.acceptsAll(newArrayList(true, true));
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertAllMatch(getInfo(assertions), newArrayList(true, true), getActual(assertions));
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/predicate/PredicateAssert_accepts_Test.java b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_accepts_Test.java
new file mode 100644
index 0000000000..44d35083d9
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_accepts_Test.java
@@ -0,0 +1,68 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.predicate;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.error.ShouldAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.error.ShouldMatch.shouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class PredicateAssert_accepts_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((Predicate) null).accepts("something");
+ }
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value() {
+ Predicate predicate = val -> val.equals("something");
+ String expectedValue = "something else";
+ thrown.expectAssertionError(shouldAccept(predicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_string_description() {
+ Predicate predicate = val -> val.equals("something");
+ String expectedValue = "something else";
+ thrown.expectAssertionError(shouldAccept(predicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").accepts(expectedValue);
+ }
+
+ @Test
+ public void should_fail_when_predicate_does_not_accept_value_with_description() {
+ Predicate predicate = val -> val.equals("something");
+ String expectedValue = "something else";
+ thrown.expectAssertionError(shouldAccept(predicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").accepts(expectedValue);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_value() {
+ Predicate predicate = val -> val.equals("something");
+ assertThat(predicate).accepts("something");
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejectsAllTest.java b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejectsAllTest.java
new file mode 100644
index 0000000000..86f38029cc
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejectsAllTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.predicate;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.function.Predicate;
+
+import org.assertj.core.api.PredicateAssert;
+import org.assertj.core.api.PredicateAssertBaseTest;
+import org.assertj.core.util.Sets;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class PredicateAssert_rejectsAllTest extends PredicateAssertBaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+ LinkedHashSet acceptedValues = Sets.newLinkedHashSet("first", "second");
+
+ assertThat((Predicate) null).rejectsAll(acceptedValues);
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_some_value() {
+ Set acceptedValues = Sets.newLinkedHashSet("first", "second");
+ Predicate predicate = acceptedValues::contains;
+ Set matchValues = Sets.newHashSet(acceptedValues);
+ matchValues.add("third");
+ thrown.expectAssertionError(noElementsShouldMatch(matchValues, "first").create());
+ assertThat(predicate).rejectsAll(matchValues);
+ }
+
+ @Test
+ public void should_pass_when_predicate_accepts_no_value() {
+ Set acceptedValues = Sets.newLinkedHashSet("first", "second");
+ Predicate predicate = acceptedValues::contains;
+ assertThat(predicate).rejectsAll(Sets.newLinkedHashSet("third", "fourth"));
+ }
+
+ @Override
+ protected PredicateAssert invoke_api_method() {
+ return assertions.rejectsAll(newArrayList(false, false));
+ }
+
+ @Override
+ protected void verify_internal_effects() {
+ verify(iterables).assertNoneMatch(getInfo(assertions), newArrayList(false, false), getActual(assertions));
+ }
+}
diff --git a/src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejects_Test.java b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejects_Test.java
new file mode 100644
index 0000000000..44aa0a1fa2
--- /dev/null
+++ b/src/test/java/org/assertj/core/api/predicate/PredicateAssert_rejects_Test.java
@@ -0,0 +1,68 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.api.predicate;
+
+import java.util.function.Predicate;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.error.ShouldNotAccept;
+import org.assertj.core.presentation.PredicateDescription;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.error.ShouldNotMatch.shouldNotMatch;
+import static org.assertj.core.util.FailureMessages.actualIsNull;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class PredicateAssert_rejects_Test extends BaseTest {
+
+ @Test
+ public void should_fail_when_predicate_is_null() {
+ thrown.expectAssertionError(actualIsNull());
+
+ assertThat((Predicate) null).accepts("something");
+ }
+ @Test
+ public void should_pass_when_predicate_does_not_accept_value() {
+ Predicate predicate = val -> val.equals("something");
+ assertThat(predicate).rejects("something else");
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_no_description() {
+ Predicate predicate = val -> val.equals("something");
+ String expectedValue = "something";
+ thrown.expectAssertionError(shouldNotAccept(predicate, expectedValue, PredicateDescription.GIVEN).create());
+ assertThat(predicate).rejects("something");
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_given_string_description() {
+ Predicate predicate = val -> val.equals("something");
+ String expectedValue = "something";
+ thrown.expectAssertionError(shouldNotAccept(predicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as("test").rejects("something");
+ }
+
+ @Test
+ public void should_fail_when_predicate_accepts_value_with_given_description() {
+ Predicate predicate = val -> val.equals("something");
+ String expectedValue = "something";
+ thrown.expectAssertionError(shouldNotAccept(predicate, expectedValue, new PredicateDescription("test")).create());
+ assertThat(predicate).as(new TextDescription("test")).rejects("something");
+ }
+}
diff --git a/src/test/java/org/assertj/core/error/NoElementsShouldMatch_create_Test.java b/src/test/java/org/assertj/core/error/NoElementsShouldMatch_create_Test.java
new file mode 100644
index 0000000000..c2018a6c73
--- /dev/null
+++ b/src/test/java/org/assertj/core/error/NoElementsShouldMatch_create_Test.java
@@ -0,0 +1,40 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.presentation.StandardRepresentation;
+import org.junit.Test;
+
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
+import static org.assertj.core.util.Lists.newArrayList;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class NoElementsShouldMatch_create_Test {
+
+ @Test
+ public void should_create_error_message() {
+ ErrorMessageFactory factory = noElementsShouldMatch(newArrayList("Luke", "Yoda"), "Yoda");
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message).isEqualTo(format("[Test] %n" +
+ "Expecting no elements of:%n" +
+ " <[\"Luke\", \"Yoda\"]>%n" +
+ "to match given predicate but this element did:%n" +
+ " <\"Yoda\">"));
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/error/ShouldAccept_create_Test.java b/src/test/java/org/assertj/core/error/ShouldAccept_create_Test.java
new file mode 100644
index 0000000000..d23dd8d894
--- /dev/null
+++ b/src/test/java/org/assertj/core/error/ShouldAccept_create_Test.java
@@ -0,0 +1,57 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.presentation.PredicateDescription;
+import org.assertj.core.presentation.StandardRepresentation;
+import org.assertj.core.test.ExpectedException;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldAccept.shouldAccept;
+import static org.assertj.core.test.ExpectedException.none;
+
+public class ShouldAccept_create_Test {
+
+ @Rule
+ public ExpectedException thrown = none();
+
+ @Test
+ public void should_create_error_message_with_default_predicate_description() {
+ ErrorMessageFactory factory = shouldAccept(color -> color.equals("green"), "Yoda", PredicateDescription.GIVEN);
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message)
+ .isEqualTo(format("[Test] %nExpecting:%n %nto accept <\"Yoda\"> but it did not."));
+ }
+
+ @Test
+ public void should_create_error_message_with_predicate_description() {
+ ErrorMessageFactory factory = shouldAccept((String color) -> color.equals("green"), "Yoda",
+ new PredicateDescription("green light saber"));
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message).isEqualTo(
+ format("[Test] %nExpecting:%n <'green light saber' predicate>%nto accept <\"Yoda\"> but it did not."));
+ }
+
+ @Test
+ public void should_fail_if_predicate_description_is_null() {
+ // then
+ thrown.expectNullPointerException("The predicate description must not be null");
+ // when
+ shouldAccept(color -> color.equals("green"), "Yoda", null);
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/error/ShouldNotAccept_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotAccept_create_Test.java
new file mode 100644
index 0000000000..c156143ced
--- /dev/null
+++ b/src/test/java/org/assertj/core/error/ShouldNotAccept_create_Test.java
@@ -0,0 +1,57 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.presentation.PredicateDescription;
+import org.assertj.core.presentation.StandardRepresentation;
+import org.assertj.core.test.ExpectedException;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldNotAccept.shouldNotAccept;
+import static org.assertj.core.test.ExpectedException.none;
+
+public class ShouldNotAccept_create_Test {
+
+ @Rule
+ public ExpectedException thrown = none();
+
+ @Test
+ public void should_create_error_message_with_default_predicate_description() {
+ ErrorMessageFactory factory = shouldNotAccept(color -> color.equals("red"), "Yoda", PredicateDescription.GIVEN);
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message)
+ .isEqualTo(format("[Test] %nExpecting:%n %nnot to accept <\"Yoda\"> but it did."));
+ }
+
+ @Test
+ public void should_create_error_message_with_predicate_description() {
+ ErrorMessageFactory factory = shouldNotAccept((String color) -> color.equals("red"), "Yoda",
+ new PredicateDescription("red light saber"));
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message).isEqualTo(
+ format("[Test] %nExpecting:%n <'red light saber' predicate>%nnot to accept <\"Yoda\"> but it did."));
+ }
+
+ @Test
+ public void should_fail_if_predicate_description_is_null() {
+ // then
+ thrown.expectNullPointerException("The predicate description must not be null");
+ // when
+ shouldNotAccept(color -> color.equals("red"), "Yoda", null);
+ }
+
+}
diff --git a/src/test/java/org/assertj/core/error/ShouldNotMatch_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotMatch_create_Test.java
new file mode 100644
index 0000000000..82c88e67fc
--- /dev/null
+++ b/src/test/java/org/assertj/core/error/ShouldNotMatch_create_Test.java
@@ -0,0 +1,54 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.error;
+
+import org.assertj.core.api.BaseTest;
+import org.assertj.core.description.TextDescription;
+import org.assertj.core.presentation.PredicateDescription;
+import org.assertj.core.presentation.StandardRepresentation;
+import org.junit.Test;
+
+import static java.lang.String.format;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.error.ShouldNotMatch.shouldNotMatch;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class ShouldNotMatch_create_Test extends BaseTest {
+
+ @Test
+ public void should_create_error_message_with_default_predicate_description() {
+ ErrorMessageFactory factory = shouldNotMatch("Yoda", color -> color.equals("green"), PredicateDescription.GIVEN);
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message)
+ .isEqualTo(format("[Test] %nExpecting:%n <\"Yoda\">%nnot to match given predicate." + ShouldNotMatch.ADVICE));
+ }
+
+ @Test
+ public void should_create_error_message_with_predicate_description() {
+ ErrorMessageFactory factory = shouldNotMatch("Yoda", (String color) -> color.equals("green"),
+ new PredicateDescription("green light saber"));
+ String message = factory.create(new TextDescription("Test"), new StandardRepresentation());
+ assertThat(message)
+ .isEqualTo(format("[Test] %nExpecting:%n <\"Yoda\">%nnot to match 'green light saber' predicate."));
+ }
+
+ @Test
+ public void should_fail_if_predicate_description_is_null() {
+ // then
+ thrown.expectNullPointerException("The predicate description must not be null");
+ // when
+ shouldNotMatch("Yoda", color -> color.equals("green"), null);
+ }
+}
diff --git a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertNoneMatch_Test.java b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertNoneMatch_Test.java
new file mode 100644
index 0000000000..9ddb6ef90b
--- /dev/null
+++ b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertNoneMatch_Test.java
@@ -0,0 +1,57 @@
+/**
+ * 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-2016 the original author or authors.
+ */
+package org.assertj.core.internal.iterables;
+
+import java.util.List;
+import java.util.function.Predicate;
+
+import org.assertj.core.internal.IterablesBaseTest;
+import org.junit.Test;
+
+import static org.assertj.core.error.NoElementsShouldMatch.noElementsShouldMatch;
+import static org.assertj.core.test.TestData.someInfo;
+import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown;
+import static org.assertj.core.util.Lists.newArrayList;
+import static org.mockito.Mockito.verify;
+
+/**
+ * @author Filip Hrisafov
+ */
+public class Iterables_assertNoneMatch_Test extends IterablesBaseTest {
+
+ @Test
+ public void should_pass_if_each_element_does_not_satisfy_the_predicate() {
+ List actual = newArrayList("123", "1234", "12345");
+ iterables.assertNoneMatch(someInfo(), actual, s -> s.length() < 3);
+ }
+
+ @Test
+ public void should_throw_error_if_predicate_is_null() {
+ thrown.expectNullPointerException("The predicate to evaluate should not be null");
+ iterables.assertNoneMatch(someInfo(), actual, null);
+ }
+
+ @Test
+ public void should_fail_if_predicate_is_met() {
+ List actual = newArrayList("Luke", "Leia", "Yoda");
+ Predicate super String> predicate = s -> s.startsWith("L");
+ try {
+ iterables.assertNoneMatch(info, actual, predicate);
+ } catch (AssertionError e) {
+ verify(failures).failure(info, noElementsShouldMatch(actual, "Luke"));
+ return;
+ }
+ failBecauseExpectedAssertionErrorWasNotThrown();
+ }
+
+}