Class PredicateAssertions
- java.lang.Object
-
- com.github.robtimus.junit.support.PredicateAssertions
-
public final class PredicateAssertions extends Object
A collection of utility methods that support asserting conditions on objects using predicates. These methods are likeAssertions.assertTrue(boolean)
andAssertions.assertFalse(boolean)
, but use an actual object that's not alwaystrue
orfalse
. As a result, the assertions in this class provide more information about why assertions fail.- Author:
- Rob Spoor
- Since:
- 2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> void
assertDoesNotMatch(Predicate<? super T> matcher, T actual)
Asserts that the supplied value does not match the supplied predicate.static <T> void
assertDoesNotMatch(Predicate<? super T> matcher, T actual, String message)
Asserts that the supplied value does not match the supplied predicate.static <T> void
assertDoesNotMatch(Predicate<? super T> matcher, T actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.static void
assertDoubleDoesNotMatch(DoublePredicate matcher, double actual)
Asserts that the supplied value does not match the supplied predicate.static void
assertDoubleDoesNotMatch(DoublePredicate matcher, double actual, String message)
Asserts that the supplied value does not match the supplied predicate.static void
assertDoubleDoesNotMatch(DoublePredicate matcher, double actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.static void
assertDoubleMatches(DoublePredicate matcher, double actual)
Asserts that the supplied value matches the supplied predicate.static void
assertDoubleMatches(DoublePredicate matcher, double actual, String message)
Asserts that the supplied value matches the supplied predicate.static void
assertDoubleMatches(DoublePredicate matcher, double actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.static void
assertIntDoesNotMatch(IntPredicate matcher, int actual)
Asserts that the supplied value does not match the supplied predicate.static void
assertIntDoesNotMatch(IntPredicate matcher, int actual, String message)
Asserts that the supplied value does not match the supplied predicate.static void
assertIntDoesNotMatch(IntPredicate matcher, int actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.static void
assertIntMatches(IntPredicate matcher, int actual)
Asserts that the supplied value matches the supplied predicate.static void
assertIntMatches(IntPredicate matcher, int actual, String message)
Asserts that the supplied value matches the supplied predicate.static void
assertIntMatches(IntPredicate matcher, int actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.static void
assertLongDoesNotMatch(LongPredicate matcher, long actual)
Asserts that the supplied value does not match the supplied predicate.static void
assertLongDoesNotMatch(LongPredicate matcher, long actual, String message)
Asserts that the supplied value does not match the supplied predicate.static void
assertLongDoesNotMatch(LongPredicate matcher, long actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.static void
assertLongMatches(LongPredicate matcher, long actual)
Asserts that the supplied value matches the supplied predicate.static void
assertLongMatches(LongPredicate matcher, long actual, String message)
Asserts that the supplied value matches the supplied predicate.static void
assertLongMatches(LongPredicate matcher, long actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.static <T> void
assertMatches(Predicate<? super T> matcher, T actual)
Asserts that the supplied value matches the supplied predicate.static <T> void
assertMatches(Predicate<? super T> matcher, T actual, String message)
Asserts that the supplied value matches the supplied predicate.static <T> void
assertMatches(Predicate<? super T> matcher, T actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.
-
-
-
Method Detail
-
assertMatches
public static <T> void assertMatches(Predicate<? super T> matcher, T actual)
Asserts that the supplied value matches the supplied predicate.- Type Parameters:
T
- The value type.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertMatches
public static <T> void assertMatches(Predicate<? super T> matcher, T actual, String message)
Asserts that the supplied value matches the supplied predicate.- Type Parameters:
T
- The value type.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertMatches
public static <T> void assertMatches(Predicate<? super T> matcher, T actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.- Type Parameters:
T
- The value type.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertIntMatches
public static void assertIntMatches(IntPredicate matcher, int actual)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertIntMatches
public static void assertIntMatches(IntPredicate matcher, int actual, String message)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertIntMatches
public static void assertIntMatches(IntPredicate matcher, int actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertLongMatches
public static void assertLongMatches(LongPredicate matcher, long actual)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertLongMatches
public static void assertLongMatches(LongPredicate matcher, long actual, String message)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertLongMatches
public static void assertLongMatches(LongPredicate matcher, long actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertDoubleMatches
public static void assertDoubleMatches(DoublePredicate matcher, double actual)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertDoubleMatches
public static void assertDoubleMatches(DoublePredicate matcher, double actual, String message)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertDoubleMatches
public static void assertDoubleMatches(DoublePredicate matcher, double actual, Supplier<String> messageSupplier)
Asserts that the supplied value matches the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertDoesNotMatch
public static <T> void assertDoesNotMatch(Predicate<? super T> matcher, T actual)
Asserts that the supplied value does not match the supplied predicate.- Type Parameters:
T
- The value type.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertDoesNotMatch
public static <T> void assertDoesNotMatch(Predicate<? super T> matcher, T actual, String message)
Asserts that the supplied value does not match the supplied predicate.- Type Parameters:
T
- The value type.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertDoesNotMatch
public static <T> void assertDoesNotMatch(Predicate<? super T> matcher, T actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.- Type Parameters:
T
- The value type.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertIntDoesNotMatch
public static void assertIntDoesNotMatch(IntPredicate matcher, int actual)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertIntDoesNotMatch
public static void assertIntDoesNotMatch(IntPredicate matcher, int actual, String message)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertIntDoesNotMatch
public static void assertIntDoesNotMatch(IntPredicate matcher, int actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertLongDoesNotMatch
public static void assertLongDoesNotMatch(LongPredicate matcher, long actual)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertLongDoesNotMatch
public static void assertLongDoesNotMatch(LongPredicate matcher, long actual, String message)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertLongDoesNotMatch
public static void assertLongDoesNotMatch(LongPredicate matcher, long actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
assertDoubleDoesNotMatch
public static void assertDoubleDoesNotMatch(DoublePredicate matcher, double actual)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.
-
assertDoubleDoesNotMatch
public static void assertDoubleDoesNotMatch(DoublePredicate matcher, double actual, String message)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.message
- The failure message to fail with.
-
assertDoubleDoesNotMatch
public static void assertDoubleDoesNotMatch(DoublePredicate matcher, double actual, Supplier<String> messageSupplier)
Asserts that the supplied value does not match the supplied predicate.- Parameters:
matcher
- The predicate to use.actual
- The value to check.messageSupplier
- The supplier for the failure message to fail with.
-
-