|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hamcrest.Matchers
public class Matchers
Constructor Summary | |
---|---|
Matchers()
|
Method Summary | ||
---|---|---|
static
|
allOf(java.lang.Iterable<Matcher<? super T>> matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true. |
|
static
|
allOf(Matcher<? super T>... param1)
|
|
static
|
allOf(Matcher<T> first,
Matcher<? super T> second)
Evaluates to true only if ALL of the passed in matchers evaluate to true. |
|
static
|
allOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third)
Evaluates to true only if ALL of the passed in matchers evaluate to true. |
|
static
|
allOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third,
Matcher<? super T> fourth)
Evaluates to true only if ALL of the passed in matchers evaluate to true. |
|
static
|
allOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third,
Matcher<? super T> fourth,
Matcher<? super T> fifth)
Evaluates to true only if ALL of the passed in matchers evaluate to true. |
|
static
|
allOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third,
Matcher<? super T> fourth,
Matcher<? super T> fifth,
Matcher<? super T> sixth)
Evaluates to true only if ALL of the passed in matchers evaluate to true. |
|
static
|
any(java.lang.Class<T> type)
Is the value an instance of a particular type? Use this version to make generics conform, for example in the JMock clause with(any(Thing.class)) |
|
static
|
anyOf(java.lang.Iterable<Matcher<? super T>> matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true. |
|
static
|
anyOf(Matcher<? super T>... param1)
|
|
static
|
anyOf(Matcher<T> first,
Matcher<? super T> second)
Evaluates to true if ANY of the passed in matchers evaluate to true. |
|
static
|
anyOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third)
Evaluates to true if ANY of the passed in matchers evaluate to true. |
|
static
|
anyOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third,
Matcher<? super T> fourth)
Evaluates to true if ANY of the passed in matchers evaluate to true. |
|
static
|
anyOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third,
Matcher<? super T> fourth,
Matcher<? super T> fifth)
Evaluates to true if ANY of the passed in matchers evaluate to true. |
|
static
|
anyOf(Matcher<T> first,
Matcher<? super T> second,
Matcher<? super T> third,
Matcher<? super T> fourth,
Matcher<? super T> fifth,
Matcher<? super T> sixth)
Evaluates to true if ANY of the passed in matchers evaluate to true. |
|
static
|
anything()
This matcher always evaluates to true. |
|
static
|
anything(java.lang.String description)
This matcher always evaluates to true. |
|
static
|
array(Matcher<? super T>... param1)
|
|
static
|
arrayContaining(E... param1)
|
|
static
|
arrayContaining(java.util.List<Matcher<? super E>> matchers)
|
|
static
|
arrayContaining(Matcher<? super E>... param1)
|
|
static
|
arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> matchers)
|
|
static
|
arrayContainingInAnyOrder(E... param1)
|
|
static
|
arrayContainingInAnyOrder(Matcher<? super E>... param1)
|
|
static
|
arrayWithSize(int size)
This is a shortcut to the frequently used arrayWithSize(equalTo(x)). |
|
static
|
arrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
Does array size satisfy a given matcher? |
|
static
|
both(Matcher<? super LHS> matcher)
This is useful for fluently combining matchers that must both pass. |
|
static Matcher<java.lang.Double> |
closeTo(double operand,
double error)
|
|
static
|
comparesEqualTo(T value)
Is value = expected? |
|
static
|
contains(E... param1)
|
|
static
|
contains(java.util.List<Matcher<? super E>> contents)
|
|
static
|
contains(Matcher<? super E>... item)
|
|
static
|
contains(Matcher<E> item)
|
|
static
|
containsInAnyOrder(java.util.Collection<Matcher<? super T>> matchers)
|
|
static
|
containsInAnyOrder(Matcher<? super T>... item)
|
|
static
|
containsInAnyOrder(Matcher<E> item)
|
|
static
|
containsInAnyOrder(T... param1)
|
|
static Matcher<java.lang.String> |
containsString(java.lang.String substring)
|
|
static
|
describedAs(java.lang.String param1,
Matcher<T> param2,
java.lang.Object... param3)
|
|
static
|
either(Matcher<? super LHS> matcher)
This is useful for fluently combining matchers where either may pass, for example: |
|
static
|
empty()
Matches an empty collection. |
|
static
|
emptyArray()
Matches an empty array. |
|
static
|
emptyIterable()
Matches an empty iterable. |
|
static Matcher<java.lang.String> |
endsWith(java.lang.String substring)
|
|
static
|
equalTo(T operand)
Is the value equal to another value, as tested by the Object.equals(java.lang.Object) invokedMethod? |
|
static Matcher<java.lang.String> |
equalToIgnoringCase(java.lang.String string)
|
|
static Matcher<java.lang.String> |
equalToIgnoringWhiteSpace(java.lang.String string)
|
|
static Matcher<java.util.EventObject> |
eventFrom(java.lang.Class<? extends java.util.EventObject> eventClass,
java.lang.Object source)
Constructs an IsEventFrom Matcher that returns true for any object derived from eventClass announced by source. |
|
static Matcher<java.util.EventObject> |
eventFrom(java.lang.Object source)
Constructs an IsEventFrom Matcher that returns true for any object derived from EventObject announced by source
. |
|
static
|
everyItem(Matcher<U> itemMatcher)
|
|
static
|
greaterThan(T value)
Is value > expected? |
|
static
|
greaterThanOrEqualTo(T value)
Is value >= expected? |
|
static
|
hasEntry(K key,
V value)
|
|
static
|
hasEntry(Matcher<? super K> keyMatcher,
Matcher<? super V> valueMatcher)
|
|
static
|
hasItem(Matcher<? super T> elementMatcher)
|
|
static
|
hasItem(T element)
|
|
static
|
hasItemInArray(Matcher<? super T> elementMatcher)
Evaluates to true if any item in an array satisfies the given matcher. |
|
static
|
hasItemInArray(T element)
This is a shortcut to the frequently used hasItemInArray(equalTo(x)). |
|
static
|
hasItems(Matcher<? super T>... param1)
|
|
static
|
hasItems(T... param1)
|
|
static
|
hasKey(K key)
|
|
static
|
hasKey(Matcher<? super K> keyMatcher)
|
|
static
|
hasProperty(java.lang.String propertyName)
|
|
static
|
hasProperty(java.lang.String propertyName,
Matcher<?> value)
|
|
static
|
hasSize(int size)
This is a shortcut to the frequently used hasSize(equalTo(x)). |
|
static
|
hasSize(Matcher<? super java.lang.Integer> size)
Does collection size satisfy a given matcher? |
|
static
|
hasToString(Matcher<? super java.lang.String> toStringMatcher)
Evaluates whether item.toString() satisfies a given matcher. |
|
static
|
hasToString(java.lang.String expectedToString)
This is a shortcut to the frequently used has_string(equalTo(x)). |
|
static
|
hasValue(Matcher<? super V> valueMatcher)
|
|
static
|
hasValue(V value)
|
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath)
|
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath,
Matcher<? super java.lang.String> valueMatcher)
|
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath,
javax.xml.namespace.NamespaceContext namespaceContext)
|
|
static Matcher<org.w3c.dom.Node> |
hasXPath(java.lang.String xPath,
javax.xml.namespace.NamespaceContext namespaceContext,
Matcher<? super java.lang.String> valueMatcher)
|
|
static
|
instanceOf(java.lang.Class<?> type)
Is the value an instance of a particular type? This version assumes no relationship between the required type and the signature of the method that sets it up, for example in assertThat(anObject, instanceOf(Thing.class)); |
|
static
|
is(java.lang.Class<T> type)
This is a shortcut to the frequently used is(instanceOf(SomeClass.class)). |
|
static
|
is(Matcher<T> matcher)
Decorates another Matcher, retaining the behavior but allowing tests to be slightly more expressive. |
|
static
|
is(T value)
This is a shortcut to the frequently used is(equalTo(x)). |
|
static
|
isIn(java.util.Collection<T> collection)
|
|
static
|
isIn(T[] param1)
|
|
static
|
isOneOf(T... param1)
|
|
static
|
iterableWithSize(int size)
|
|
static
|
iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
|
|
static
|
lessThan(T value)
Is value < expected? |
|
static
|
lessThanOrEqualTo(T value)
Is value <= expected? |
|
static
|
not(Matcher<T> matcher)
Inverts the rule. |
|
static
|
not(T value)
This is a shortcut to the frequently used not(equalTo(x)). |
|
static
|
notNullValue()
Matches if value is not null. |
|
static
|
notNullValue(java.lang.Class<T> type)
Matches if value is not null. |
|
static
|
nullValue()
Matches if value is null. |
|
static
|
nullValue(java.lang.Class<T> type)
Matches if value is null. |
|
static
|
sameInstance(T object)
Creates a new instance of IsSame |
|
static
|
samePropertyValuesAs(T expectedBean)
|
|
static Matcher<java.lang.String> |
startsWith(java.lang.String substring)
|
|
static
|
typeCompatibleWith(java.lang.Class<T> baseType)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Matchers()
Method Detail |
---|
public static <T> Matcher<T> allOf(java.lang.Iterable<Matcher<? super T>> matchers)
public static <T> Matcher<T> allOf(Matcher<? super T>... param1)
public static <T> Matcher<T> allOf(Matcher<T> first, Matcher<? super T> second)
public static <T> Matcher<T> allOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third)
public static <T> Matcher<T> allOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)
public static <T> Matcher<T> allOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)
public static <T> Matcher<T> allOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)
public static <T> AnyOf<T> anyOf(java.lang.Iterable<Matcher<? super T>> matchers)
public static <T> AnyOf<T> anyOf(Matcher<? super T>... param1)
public static <T> AnyOf<T> anyOf(Matcher<T> first, Matcher<? super T> second)
public static <T> AnyOf<T> anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third)
public static <T> AnyOf<T> anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth)
public static <T> AnyOf<T> anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth)
public static <T> AnyOf<T> anyOf(Matcher<T> first, Matcher<? super T> second, Matcher<? super T> third, Matcher<? super T> fourth, Matcher<? super T> fifth, Matcher<? super T> sixth)
public static <LHS> CombinableMatcher<LHS> both(Matcher<? super LHS> matcher)
assertThat(string, both(containsString("a")).and(containsString("b")));
public static <LHS> CombinableMatcher<LHS> either(Matcher<? super LHS> matcher)
assertThat(string, both(containsString("a")).and(containsString("b")));
public static <T> Matcher<T> describedAs(java.lang.String param1, Matcher<T> param2, java.lang.Object... param3)
public static <U> Matcher<java.lang.Iterable<U>> everyItem(Matcher<U> itemMatcher)
itemMatcher
- A matcher to apply to every element in a collection.
public static <T> Matcher<T> is(Matcher<T> matcher)
public static <T> Matcher<? super T> is(T value)
public static <T> Matcher<? super T> is(java.lang.Class<T> type)
public static <T> Matcher<T> anything()
public static <T> Matcher<T> anything(java.lang.String description)
description
- A meaningful string used when describing itself.public static <T> Matcher<java.lang.Iterable<? super T>> hasItem(Matcher<? super T> elementMatcher)
public static <T> Matcher<java.lang.Iterable<? super T>> hasItem(T element)
public static <T> Matcher<java.lang.Iterable<T>> hasItems(Matcher<? super T>... param1)
public static <T> Matcher<java.lang.Iterable<T>> hasItems(T... param1)
public static <T> Matcher<? super T> equalTo(T operand)
Object.equals(java.lang.Object)
invokedMethod?
public static <T> Matcher<T> any(java.lang.Class<T> type)
with(any(Thing.class))
public static <T> Matcher<T> instanceOf(java.lang.Class<?> type)
assertThat(anObject, instanceOf(Thing.class));
public static <T> Matcher<T> not(Matcher<T> matcher)
public static <T> Matcher<? super T> not(T value)
public static <T> Matcher<T> nullValue()
public static <T> Matcher<T> nullValue(java.lang.Class<T> type)
public static <T> Matcher<T> notNullValue()
public static <T> Matcher<T> notNullValue(java.lang.Class<T> type)
public static <T> Matcher<T> sameInstance(T object)
object
- The predicate evaluates to true only when the argument is
this object.public static Matcher<java.lang.String> containsString(java.lang.String substring)
public static Matcher<java.lang.String> startsWith(java.lang.String substring)
public static Matcher<java.lang.String> endsWith(java.lang.String substring)
public static <T> IsArray<T> array(Matcher<? super T>... param1)
public static <T> Matcher<T[]> hasItemInArray(Matcher<? super T> elementMatcher)
public static <T> Matcher<T[]> hasItemInArray(T element)
public static <E> Matcher<E[]> arrayContaining(E... param1)
public static <E> Matcher<E[]> arrayContaining(Matcher<? super E>... param1)
public static <E> Matcher<E[]> arrayContaining(java.util.List<Matcher<? super E>> matchers)
public static <E> Matcher<E[]> arrayContainingInAnyOrder(Matcher<? super E>... param1)
public static <E> Matcher<E[]> arrayContainingInAnyOrder(java.util.Collection<Matcher<? super E>> matchers)
public static <E> Matcher<E[]> arrayContainingInAnyOrder(E... param1)
public static <E> Matcher<E[]> arrayWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
public static <E> Matcher<E[]> arrayWithSize(int size)
public static <E> Matcher<E[]> emptyArray()
public static <E> Matcher<? super java.util.Collection<? extends E>> hasSize(Matcher<? super java.lang.Integer> size)
public static <E> Matcher<? super java.util.Collection<? extends E>> hasSize(int size)
public static <E> Matcher<java.util.Collection<E>> empty()
public static <E> Matcher<java.lang.Iterable<E>> emptyIterable()
public static <E> Matcher<java.lang.Iterable<E>> contains(E... param1)
public static <E> Matcher<java.lang.Iterable<E>> contains(Matcher<E> item)
public static <E> Matcher<java.lang.Iterable<E>> contains(Matcher<? super E>... item)
public static <E> Matcher<java.lang.Iterable<E>> contains(java.util.List<Matcher<? super E>> contents)
public static <E> Matcher<java.lang.Iterable<E>> containsInAnyOrder(Matcher<E> item)
public static <T> Matcher<java.lang.Iterable<T>> containsInAnyOrder(Matcher<? super T>... item)
public static <T> Matcher<java.lang.Iterable<T>> containsInAnyOrder(T... param1)
public static <T> Matcher<java.lang.Iterable<T>> containsInAnyOrder(java.util.Collection<Matcher<? super T>> matchers)
public static <E> Matcher<java.lang.Iterable<E>> iterableWithSize(Matcher<? super java.lang.Integer> sizeMatcher)
public static <E> Matcher<java.lang.Iterable<E>> iterableWithSize(int size)
public static <K,V> Matcher<java.util.Map<? extends K,? extends V>> hasEntry(Matcher<? super K> keyMatcher, Matcher<? super V> valueMatcher)
public static <K,V> Matcher<java.util.Map<? extends K,? extends V>> hasEntry(K key, V value)
public static <K> Matcher<java.util.Map<? super K,?>> hasKey(K key)
public static <K> Matcher<java.util.Map<? super K,?>> hasKey(Matcher<? super K> keyMatcher)
public static <V> Matcher<? super java.util.Map<?,V>> hasValue(V value)
public static <V> Matcher<? super java.util.Map<?,V>> hasValue(Matcher<? super V> valueMatcher)
public static <T> Matcher<T> isIn(java.util.Collection<T> collection)
public static <T> Matcher<T> isIn(T[] param1)
public static <T> Matcher<T> isOneOf(T... param1)
public static Matcher<java.lang.Double> closeTo(double operand, double error)
public static <T extends java.lang.Comparable<T>> Matcher<? super T> comparesEqualTo(T value)
public static <T extends java.lang.Comparable<T>> Matcher<? super T> greaterThan(T value)
public static <T extends java.lang.Comparable<T>> Matcher<? super T> greaterThanOrEqualTo(T value)
public static <T extends java.lang.Comparable<T>> Matcher<? super T> lessThan(T value)
public static <T extends java.lang.Comparable<T>> Matcher<? super T> lessThanOrEqualTo(T value)
public static Matcher<java.lang.String> equalToIgnoringCase(java.lang.String string)
public static Matcher<java.lang.String> equalToIgnoringWhiteSpace(java.lang.String string)
public static <T> Matcher<T> hasToString(Matcher<? super java.lang.String> toStringMatcher)
public static <T> Matcher<T> hasToString(java.lang.String expectedToString)
public static <T> Matcher<java.lang.Class<?>> typeCompatibleWith(java.lang.Class<T> baseType)
public static Matcher<java.util.EventObject> eventFrom(java.lang.Class<? extends java.util.EventObject> eventClass, java.lang.Object source)
public static Matcher<java.util.EventObject> eventFrom(java.lang.Object source)
EventObject
announced by source
.
public static <T> Matcher<T> hasProperty(java.lang.String propertyName)
public static <T> Matcher<T> hasProperty(java.lang.String propertyName, Matcher<?> value)
public static <T> Matcher<T> samePropertyValuesAs(T expectedBean)
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, Matcher<? super java.lang.String> valueMatcher)
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, Matcher<? super java.lang.String> valueMatcher)
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath)
public static Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |