org.hamcrest
public class Matchers extends Object
Constructor and Description |
---|
Matchers() |
Modifier and Type | Method and Description |
---|---|
static <T> Matcher<T> |
allOf(Iterable<Matcher<? extends T>> matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
allOf(Matcher<? extends T>... matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
any(Class<T> type)
This matcher always evaluates to true.
|
static <T> Matcher<T> |
anyOf(Iterable<Matcher<? extends T>> matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
anyOf(Matcher<? extends T>... matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
anything()
This matcher always evaluates to true.
|
static <T> Matcher<T> |
anything(String description)
This matcher always evaluates to true.
|
static Matcher<Double> |
closeTo(double operand,
double error) |
static Matcher<String> |
containsString(String substring) |
static <T> Matcher<T> |
describedAs(String description,
Matcher<T> matcher,
Object... values)
Wraps an existing matcher and overrides the description when it fails.
|
static Matcher<String> |
endsWith(String substring) |
static <T> Matcher<T> |
equalTo(T operand)
Is the value equal to another value, as tested by the
Object.equals(java.lang.Object) invokedMethod? |
static Matcher<String> |
equalToIgnoringCase(String string) |
static Matcher<String> |
equalToIgnoringWhiteSpace(String string) |
static Matcher<EventObject> |
eventFrom(Class<? extends EventObject> eventClass,
Object source)
Constructs an IsEventFrom Matcher that returns true for any object
derived from eventClass announced by source.
|
static Matcher<EventObject> |
eventFrom(Object source)
Constructs an IsEventFrom Matcher that returns true for any object
derived from
EventObject announced by source
. |
static <T extends Comparable<T>> |
greaterThan(T value) |
static <T extends Comparable<T>> |
greaterThanOrEqualTo(T value) |
static <K,V> Matcher<Map<K,V>> |
hasEntry(K key,
V value) |
static <K,V> Matcher<Map<K,V>> |
hasEntry(Matcher<K> keyMatcher,
Matcher<V> valueMatcher) |
static <T> Matcher<Iterable<T>> |
hasItem(Matcher<? extends T> elementMatcher) |
static <T> Matcher<Iterable<T>> |
hasItem(T element) |
static <T> Matcher<T[]> |
hasItemInArray(Matcher<T> elementMatcher) |
static <T> Matcher<T[]> |
hasItemInArray(T element) |
static <T> Matcher<Iterable<T>> |
hasItems(Matcher<? extends T>... elementMatchers) |
static <T> Matcher<Iterable<T>> |
hasItems(T... elements) |
static <K,V> Matcher<Map<K,V>> |
hasKey(K key) |
static <K,V> Matcher<Map<K,V>> |
hasKey(Matcher<K> keyMatcher) |
static <T> Matcher<T> |
hasProperty(String propertyName) |
static <T> Matcher<T> |
hasProperty(String propertyName,
Matcher value) |
static <T> Matcher<T> |
hasToString(Matcher<String> toStringMatcher) |
static <K,V> Matcher<Map<K,V>> |
hasValue(Matcher<V> valueMatcher) |
static <K,V> Matcher<Map<K,V>> |
hasValue(V value) |
static Matcher<Node> |
hasXPath(String xPath) |
static Matcher<Node> |
hasXPath(String xPath,
Matcher<String> valueMatcher) |
static Matcher<Object> |
instanceOf(Class<?> type)
Is the value an instance of a particular type?
|
static Matcher<Object> |
is(Class<?> type)
This is a shortcut to the frequently used is(instanceOf(SomeClass.class)).
|
static <T> Matcher<T> |
is(Matcher<T> matcher)
Decorates another Matcher, retaining the behavior but allowing tests
to be slightly more expressive.
|
static <T> Matcher<T> |
is(T value)
This is a shortcut to the frequently used is(equalTo(x)).
|
static <T> Matcher<T> |
isIn(Collection<T> collection) |
static <T> Matcher<T> |
isIn(T[] param1) |
static <T> Matcher<T> |
isOneOf(T... elements) |
static <T extends Comparable<T>> |
lessThan(T value) |
static <T extends Comparable<T>> |
lessThanOrEqualTo(T value) |
static <T> Matcher<T> |
not(Matcher<T> matcher)
Inverts the rule.
|
static <T> Matcher<T> |
not(T value)
This is a shortcut to the frequently used not(equalTo(x)).
|
static <T> Matcher<T> |
notNullValue()
Matches if value is not null.
|
static <T> Matcher<T> |
notNullValue(Class<T> type)
Matches if value is not null.
|
static <T> Matcher<T> |
nullValue()
Matches if value is null.
|
static <T> Matcher<T> |
nullValue(Class<T> type)
Matches if value is null.
|
static <T> Matcher<T> |
sameInstance(T object)
Creates a new instance of IsSame
|
static Matcher<String> |
startsWith(String substring) |
static <T> Matcher<Class<?>> |
typeCompatibleWith(Class<T> baseType) |
public static Matcher<Object> is(Class<?> type)
public static <T> Matcher<T> is(T value)
public static <T> Matcher<T> is(Matcher<T> matcher)
public static <T> Matcher<T> not(T value)
public static <T> Matcher<T> equalTo(T operand)
Object.equals(java.lang.Object)
invokedMethod?public static Matcher<Object> instanceOf(Class<?> type)
public static <T> Matcher<T> allOf(Matcher<? extends T>... matchers)
public static <T> Matcher<T> allOf(Iterable<Matcher<? extends T>> matchers)
public static <T> Matcher<T> anyOf(Matcher<? extends T>... matchers)
public static <T> Matcher<T> anyOf(Iterable<Matcher<? extends T>> matchers)
public static <T> Matcher<T> sameInstance(T object)
object
- The predicate evaluates to true only when the argument is
this object.public static <T> Matcher<T> any(Class<T> type)
public static <T> Matcher<T> anything()
public static <T> Matcher<T> anything(String description)
description
- A meaningful string used when describing itself.public static <T> Matcher<T> nullValue()
public static <T> Matcher<T> nullValue(Class<T> type)
public static <T> Matcher<T> notNullValue()
public static <T> Matcher<T> notNullValue(Class<T> type)
public static <T> Matcher<T> describedAs(String description, Matcher<T> matcher, Object... values)
public static <T> Matcher<T[]> hasItemInArray(T element)
public static <K,V> Matcher<Map<K,V>> hasEntry(Matcher<K> keyMatcher, Matcher<V> valueMatcher)
public static <T> Matcher<T> isIn(Collection<T> collection)
public static <T> Matcher<T> isIn(T[] param1)
public static <T> Matcher<T> isOneOf(T... elements)
public static <T extends Comparable<T>> Matcher<T> greaterThan(T value)
public static <T extends Comparable<T>> Matcher<T> greaterThanOrEqualTo(T value)
public static <T extends Comparable<T>> Matcher<T> lessThan(T value)
public static <T extends Comparable<T>> Matcher<T> lessThanOrEqualTo(T value)
public static Matcher<EventObject> eventFrom(Object source)
EventObject
announced by source
.public static Matcher<EventObject> eventFrom(Class<? extends EventObject> eventClass, Object source)