Class AssertionPredicates
AssertionPredicate
objects.
Typically used wherever predicates are allowed for testing of Assertion
objects such as...
FluentObjectAssertion.is(Predicate)
FluentArrayAssertion.is(Predicate...)
FluentPrimitiveArrayAssertion.is(Predicate...)
FluentListAssertion.isEach(Predicate...)
Example:
See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final <T> AssertionPredicate<T>
Combines the specified predicates into a singled AND'ed predicate.static final <T> AssertionPredicate<T>
any()
Predicate that always returnstrue .static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string contains the specified substring.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value equals the specified value.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string matches the specified value.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string does not match the specified value ignoring case.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value is exactly specified type.static final <T> AssertionPredicate<T>
isNull()
Predicate that returnstrue if the tested value is null.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string matches the specified match pattern.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value does not match the specified value.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string does not match the specified value.static final <T> AssertionPredicate<T>
Negates the specified predicate.static final <T> AssertionPredicate<T>
notNull()
Predicate that returnstrue if the tested value is not null.static final <T> AssertionPredicate<T>
Combines the specified predicates into a singled OR'ed predicate.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string matches the specified regular expression.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string matches the specified regular expression.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value converted to a string matches the specified regular expression.static final <T> AssertionPredicate<T>
Predicate that wraps another predicate.static final <T> AssertionPredicate<T>
Predicate that wraps another predicate.static final <T> AssertionPredicate<T>
Predicate that returnstrue if the tested value is the specified or child type.
-
Constructor Details
-
AssertionPredicates
public AssertionPredicates()
-
-
Method Details
-
any
Predicate that always returnstrue .Note that this typically has the same affect as a
null predicate.- Type Parameters:
T
- The object type being tested.- Returns:
- A new predicate.
-
notNull
Predicate that returnstrue if the tested value is not null.Assertion error message is
"Value was null." .- Type Parameters:
T
- The object type being tested.- Returns:
- A new predicate.
-
isNull
Predicate that returnstrue if the tested value is null.Assertion error message is
"Value was not null." .- Type Parameters:
T
- The object type being tested.- Returns:
- A new predicate.
-
eq
Predicate that returnstrue if the tested value equals the specified value.Uses standard Java equality for testing.
Assertion error message is
"Value did not match expected. Expected='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
eq
Predicate that returnstrue if the tested value converted to a string matches the specified value.Assertion error message is
"Value did not match expected. Expected='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
ne
Predicate that returnstrue if the tested value does not match the specified value.Assertion error message is
"Value unexpectedly matched. Value='{0}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
ne
Predicate that returnstrue if the tested value converted to a string does not match the specified value.Assertion error message is
"Value unexpectedly matched. Value='{0}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
eqic
Predicate that returnstrue if the tested value converted to a string does not match the specified value ignoring case.Assertion error message is
"Value did not match expected. Expected='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
contains
Predicate that returnstrue if the tested value converted to a string contains the specified substring.Assertion error message is
"Value did not contain expected. Expected='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
type
Predicate that returnstrue if the tested value is the specified or child type.Assertion error message is
"Value was not expected type. Expected='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
type
- The specified type.- Returns:
- A new predicate.
-
exactType
Predicate that returnstrue if the tested value is exactly specified type.Assertion error message is
"Value was not expected type. Expected='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
type
- The specified type.- Returns:
- A new predicate.
-
match
Predicate that returnstrue if the tested value converted to a string matches the specified match pattern.Match pattern can contain the
"*" meta-character.Assertion error message is
"Value did not match pattern. Pattern='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The specified value.- Returns:
- A new predicate.
-
regex
Predicate that returnstrue if the tested value converted to a string matches the specified regular expression.Assertion error message is
"Value did not match pattern. Pattern='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
expression
- The regular expression to match.- Returns:
- A new predicate.
-
regex
Predicate that returnstrue if the tested value converted to a string matches the specified regular expression.Assertion error message is
"Value did not match pattern. Pattern='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
expression
- The regular expression to match.flags
- Match flags, a bit mask that may include:- Returns:
- A new predicate.
-
regex
Predicate that returnstrue if the tested value converted to a string matches the specified regular expression.Assertion error message is
"Value did not match pattern. Pattern='{0}', Actual='{1}'." .- Type Parameters:
T
- The object type being tested.- Parameters:
value
- The regular expression to match.- Returns:
- A new predicate.
-
test
Predicate that wraps another predicate.If the predicate extends from
AssertionPredicate
, the assertion error message is"Value did not pass test." followed by the inner assertion error. Otherwise the message is"Value did not pass test. Value='{0}'." - Type Parameters:
T
- The object type being tested.- Parameters:
predicate
- The predicate to run.- Returns:
- A new predicate.
-
test
public static final <T> AssertionPredicate<T> test(Predicate<T> predicate, String msg, Object... args) Predicate that wraps another predicate.If the message specified is
null and the predicate extends fromAssertionPredicate
, the assertion error message is"Value did not pass test." followed by the inner assertion error. Otherwise the message is"Value did not pass test. Value='{0}'." - Type Parameters:
T
- The object type being tested.- Parameters:
predicate
- The predicate to run.msg
- The error message if predicate fails.
SupportsMessageFormat
-style arguments.args
- Optional message arguments.
Can contain#VALUE
to specify the value itself as an argument.
Can containfunctions
to apply to the tested value.- Returns:
- A new predicate.
-
and
Combines the specified predicates into a singled AND'ed predicate.Assertion error message is
"Predicate test #x failed." followed by the inner failed message if the failed predicate extends fromAssertionPredicate
.- Type Parameters:
T
- The predicate type.- Parameters:
predicates
- The predicates to combine.- Returns:
- The combined predicates.
-
or
Combines the specified predicates into a singled OR'ed predicate.Assertion error message is
"No predicate tests passed." .- Type Parameters:
T
- The predicate type.- Parameters:
predicates
- The predicates to combine.- Returns:
- The combined predicates.
-
not
Negates the specified predicate.Assertion error message is
"Predicate test unexpectedly passed." .- Type Parameters:
T
- The predicate type.- Parameters:
predicate
- The predicate to negate.- Returns:
- The combined predicates.
-