org.hamcrest
Class Matchers

java.lang.Object
  extended by org.hamcrest.Matchers

public class Matchers
extends java.lang.Object


Constructor Summary
Matchers()
           
 
Method Summary
static
<T> org.hamcrest.Matcher<T>
allOf(java.lang.Iterable<org.hamcrest.Matcher<? super T>> matchers)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
allOf(org.hamcrest.Matcher<? super T>... matchers)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
allOf(org.hamcrest.Matcher<? super T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth, org.hamcrest.Matcher<? super T> sixth)
          Evaluates to true only if ALL of the passed in matchers evaluate to true.
static
<T> org.hamcrest.Matcher<T>
any(java.lang.Class<T> type)
          Is the value an instance of a particular type?
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(java.lang.Iterable<org.hamcrest.Matcher<? super T>> matchers)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(org.hamcrest.Matcher<? super T>... matchers)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static
<T> org.hamcrest.core.AnyOf<T>
anyOf(org.hamcrest.Matcher<T> first, org.hamcrest.Matcher<? super T> second, org.hamcrest.Matcher<? super T> third, org.hamcrest.Matcher<? super T> fourth, org.hamcrest.Matcher<? super T> fifth, org.hamcrest.Matcher<? super T> sixth)
          Evaluates to true if ANY of the passed in matchers evaluate to true.
static org.hamcrest.Matcher<java.lang.Object> anything()
          This matcher always evaluates to true.
static org.hamcrest.Matcher<java.lang.Object> anything(java.lang.String description)
          This matcher always evaluates to true.
static
<T> IsArray<T>
array(org.hamcrest.Matcher<? super T>... elementMatchers)
          Evaluates to true only if each matcher[i] is satisfied by array[i].
static
<E> org.hamcrest.Matcher<E[]>
arrayContaining(E... items)
           
static
<E> org.hamcrest.Matcher<E[]>
arrayContaining(java.util.List<org.hamcrest.Matcher<? super E>> matchers)
           
static
<E> org.hamcrest.Matcher<E[]>
arrayContaining(org.hamcrest.Matcher<? super E>... matchers)
           
static
<E> org.hamcrest.Matcher<E[]>
arrayContainingInAnyOrder(java.util.Collection<org.hamcrest.Matcher<? super E>> matchers)
           
static
<E> org.hamcrest.Matcher<E[]>
arrayContainingInAnyOrder(E... items)
           
static
<E> org.hamcrest.Matcher<E[]>
arrayContainingInAnyOrder(org.hamcrest.Matcher<? super E>... matchers)
           
static
<E> org.hamcrest.Matcher<E[]>
arrayWithSize(int size)
          This is a shortcut to the frequently used arrayWithSize(equalTo(x)).
static
<E> org.hamcrest.Matcher<E[]>
arrayWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher)
          Does array size satisfy a given matcher?
static
<LHS> org.hamcrest.core.CombinableMatcher<LHS>
both(org.hamcrest.Matcher<? super LHS> matcher)
          This is useful for fluently combining matchers that must both pass.
static org.hamcrest.Matcher<java.lang.Double> closeTo(double operand, double error)
           
static
<T extends java.lang.Comparable<T>>
org.hamcrest.Matcher<T>
comparesEqualTo(T value)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>>
contains(E... items)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>>
contains(java.util.List<org.hamcrest.Matcher<? super E>> contents)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>>
contains(org.hamcrest.Matcher<? super E>... item)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>>
contains(org.hamcrest.Matcher<? super E> item)
           
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>>
containsInAnyOrder(java.util.Collection<org.hamcrest.Matcher<? super T>> matchers)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>>
containsInAnyOrder(org.hamcrest.Matcher<? super E> item)
           
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>>
containsInAnyOrder(org.hamcrest.Matcher<? super T>... item)
           
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>>
containsInAnyOrder(T... items)
           
static org.hamcrest.Matcher<java.lang.String> containsString(java.lang.String substring)
           
static
<T> org.hamcrest.Matcher<T>
describedAs(java.lang.String description, org.hamcrest.Matcher<T> matcher, java.lang.Object... values)
          Wraps an existing matcher and overrides the description when it fails.
static
<LHS> org.hamcrest.core.CombinableMatcher<LHS>
either(org.hamcrest.Matcher<? super LHS> matcher)
          This is useful for fluently combining matchers where either may pass, for example: assertThat(string, both(containsString("a")).and(containsString("b")));
static
<E> org.hamcrest.Matcher<java.util.Collection<E>>
empty()
          Matches an empty collection.
static
<E> org.hamcrest.Matcher<E[]>
emptyArray()
          Matches an empty array.
static
<E> org.hamcrest.Matcher<java.lang.Iterable<E>>
emptyIterable()
          Matches an empty iterable.
static org.hamcrest.Matcher<java.lang.String> endsWith(java.lang.String substring)
           
static
<T> org.hamcrest.Matcher<T>
equalTo(T operand)
          Is the value equal to another value, as tested by the Object.equals(java.lang.Object) invokedMethod?
static org.hamcrest.Matcher<java.lang.String> equalToIgnoringCase(java.lang.String string)
           
static org.hamcrest.Matcher<java.lang.String> equalToIgnoringWhiteSpace(java.lang.String string)
           
static org.hamcrest.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 org.hamcrest.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
<U> org.hamcrest.Matcher<java.lang.Iterable<U>>
everyItem(org.hamcrest.Matcher<U> itemMatcher)
           
static
<T extends java.lang.Comparable<T>>
org.hamcrest.Matcher<T>
greaterThan(T value)
          Is value > expected?
static
<T extends java.lang.Comparable<T>>
org.hamcrest.Matcher<T>
greaterThanOrEqualTo(T value)
          Is value >= expected?
static
<K,V> org.hamcrest.Matcher<java.util.Map<? extends K,? extends V>>
hasEntry(K key, V value)
           
static
<K,V> org.hamcrest.Matcher<java.util.Map<? extends K,? extends V>>
hasEntry(org.hamcrest.Matcher<? super K> keyMatcher, org.hamcrest.Matcher<? super V> valueMatcher)
           
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? super T>>
hasItem(org.hamcrest.Matcher<? super T> elementMatcher)
           
static
<T> org.hamcrest.Matcher<java.lang.Iterable<? super T>>
hasItem(T element)
           
static
<T> org.hamcrest.Matcher<T[]>
hasItemInArray(org.hamcrest.Matcher<? super T> elementMatcher)
          Evaluates to true if any item in an array satisfies the given matcher.
static
<T> org.hamcrest.Matcher<T[]>
hasItemInArray(T element)
          This is a shortcut to the frequently used hasItemInArray(equalTo(x)).
static
<T> org.hamcrest.Matcher<java.lang.Iterable<T>>
hasItems(org.hamcrest.Matcher<? super T>... elementMatchers)
           
static
<T> org.hamcrest.Matcher<java.lang.Iterable<T>>
hasItems(T... elements)
           
static
<K> org.hamcrest.Matcher<java.util.Map<? extends K,?>>
hasKey(K key)
           
static
<K> org.hamcrest.Matcher<java.util.Map<? extends K,?>>
hasKey(org.hamcrest.Matcher<? super K> keyMatcher)
           
static
<T> org.hamcrest.Matcher<T>
hasProperty(java.lang.String propertyName)
           
static
<T> org.hamcrest.Matcher<T>
hasProperty(java.lang.String propertyName, org.hamcrest.Matcher<?> value)
           
static
<E> org.hamcrest.Matcher<java.util.Collection<? extends E>>
hasSize(int size)
          This is a shortcut to the frequently used hasSize(equalTo(x)).
static
<E> org.hamcrest.Matcher<java.util.Collection<? extends E>>
hasSize(org.hamcrest.Matcher<? super java.lang.Integer> size)
          Does collection size satisfy a given matcher?
static
<T> org.hamcrest.Matcher<T>
hasToString(org.hamcrest.Matcher<? super java.lang.String> toStringMatcher)
          Evaluates whether item.toString() satisfies a given matcher.
static
<T> org.hamcrest.Matcher<T>
hasToString(java.lang.String expectedToString)
          This is a shortcut to the frequently used has_string(equalTo(x)).
static
<V> org.hamcrest.Matcher<java.util.Map<?,? extends V>>
hasValue(org.hamcrest.Matcher<? super V> valueMatcher)
           
static
<V> org.hamcrest.Matcher<java.util.Map<?,? extends V>>
hasValue(V value)
           
static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath)
           
static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, org.hamcrest.Matcher<? super java.lang.String> valueMatcher)
           
static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext)
           
static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, org.hamcrest.Matcher<? super java.lang.String> valueMatcher)
           
static
<T> org.hamcrest.Matcher<T>
instanceOf(java.lang.Class<?> type)
          Is the value an instance of a particular type?
static
<T> org.hamcrest.Matcher<T>
is(java.lang.Class<T> type)
          Deprecated. use isA(Class type) instead.
static
<T> org.hamcrest.Matcher<T>
is(org.hamcrest.Matcher<T> matcher)
          Decorates another Matcher, retaining the behavior but allowing tests to be slightly more expressive.
static
<T> org.hamcrest.Matcher<T>
is(T value)
          This is a shortcut to the frequently used is(equalTo(x)).
static
<T> org.hamcrest.Matcher<T>
isA(java.lang.Class<T> type)
           
static
<T> org.hamcrest.Matcher<T>
isIn(java.util.Collection<T> collection)
           
static
<T> org.hamcrest.Matcher<T>
isIn(T[] param1)
           
static
<T> org.hamcrest.Matcher<T>
isOneOf(T... elements)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<E>>
iterableWithSize(int size)
           
static
<E> org.hamcrest.Matcher<java.lang.Iterable<E>>
iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher)
           
static
<T extends java.lang.Comparable<T>>
org.hamcrest.Matcher<T>
lessThan(T value)
          Is value < expected?
static
<T extends java.lang.Comparable<T>>
org.hamcrest.Matcher<T>
lessThanOrEqualTo(T value)
          Is value <= expected?
static
<T> org.hamcrest.Matcher<T>
not(org.hamcrest.Matcher<T> matcher)
          Inverts the rule.
static
<T> org.hamcrest.Matcher<T>
not(T value)
          This is a shortcut to the frequently used not(equalTo(x)).
static org.hamcrest.Matcher<java.lang.Object> notNullValue()
          Matches if value is not null.
static
<T> org.hamcrest.Matcher<T>
notNullValue(java.lang.Class<T> type)
          Matches if value is not null.
static org.hamcrest.Matcher<java.lang.Object> nullValue()
          Matches if value is null.
static
<T> org.hamcrest.Matcher<T>
nullValue(java.lang.Class<T> type)
          Matches if value is null.
static
<T> org.hamcrest.Matcher<T>
sameInstance(T object)
          Creates a new instance of IsSame
static
<T> org.hamcrest.Matcher<T>
samePropertyValuesAs(T expectedBean)
           
static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String substring)
           
static
<T> org.hamcrest.Matcher<java.lang.Class<?>>
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

Matchers

public Matchers()
Method Detail

allOf

public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T>... matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first,
                                                org.hamcrest.Matcher<? super T> second)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first,
                                                org.hamcrest.Matcher<? super T> second,
                                                org.hamcrest.Matcher<? super T> third)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first,
                                                org.hamcrest.Matcher<? super T> second,
                                                org.hamcrest.Matcher<? super T> third,
                                                org.hamcrest.Matcher<? super T> fourth)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first,
                                                org.hamcrest.Matcher<? super T> second,
                                                org.hamcrest.Matcher<? super T> third,
                                                org.hamcrest.Matcher<? super T> fourth,
                                                org.hamcrest.Matcher<? super T> fifth)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> org.hamcrest.Matcher<T> allOf(org.hamcrest.Matcher<? super T> first,
                                                org.hamcrest.Matcher<? super T> second,
                                                org.hamcrest.Matcher<? super T> third,
                                                org.hamcrest.Matcher<? super T> fourth,
                                                org.hamcrest.Matcher<? super T> fifth,
                                                org.hamcrest.Matcher<? super T> sixth)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


allOf

public static <T> org.hamcrest.Matcher<T> allOf(java.lang.Iterable<org.hamcrest.Matcher<? super T>> matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first,
                                                   org.hamcrest.Matcher<? super T> second,
                                                   org.hamcrest.Matcher<? super T> third,
                                                   org.hamcrest.Matcher<? super T> fourth)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first,
                                                   org.hamcrest.Matcher<? super T> second)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first,
                                                   org.hamcrest.Matcher<? super T> second,
                                                   org.hamcrest.Matcher<? super T> third)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<? super T>... matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first,
                                                   org.hamcrest.Matcher<? super T> second,
                                                   org.hamcrest.Matcher<? super T> third,
                                                   org.hamcrest.Matcher<? super T> fourth,
                                                   org.hamcrest.Matcher<? super T> fifth)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(org.hamcrest.Matcher<T> first,
                                                   org.hamcrest.Matcher<? super T> second,
                                                   org.hamcrest.Matcher<? super T> third,
                                                   org.hamcrest.Matcher<? super T> fourth,
                                                   org.hamcrest.Matcher<? super T> fifth,
                                                   org.hamcrest.Matcher<? super T> sixth)
Evaluates to true if ANY of the passed in matchers evaluate to true.


anyOf

public static <T> org.hamcrest.core.AnyOf<T> anyOf(java.lang.Iterable<org.hamcrest.Matcher<? super T>> matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.


both

public static <LHS> org.hamcrest.core.CombinableMatcher<LHS> both(org.hamcrest.Matcher<? super LHS> matcher)
This is useful for fluently combining matchers that must both pass. For example:
 assertThat(string, both(containsString("a")).and(containsString("b")));
 


either

public static <LHS> org.hamcrest.core.CombinableMatcher<LHS> either(org.hamcrest.Matcher<? super LHS> matcher)
This is useful for fluently combining matchers where either may pass, for example:
 assertThat(string, both(containsString("a")).and(containsString("b")));
 


describedAs

public static <T> org.hamcrest.Matcher<T> describedAs(java.lang.String description,
                                                      org.hamcrest.Matcher<T> matcher,
                                                      java.lang.Object... values)
Wraps an existing matcher and overrides the description when it fails.


everyItem

public static <U> org.hamcrest.Matcher<java.lang.Iterable<U>> everyItem(org.hamcrest.Matcher<U> itemMatcher)
Parameters:
itemMatcher - A matcher to apply to every element in a collection.
Returns:
Evaluates to TRUE for a collection in which every item matches itemMatcher

is

public static <T> org.hamcrest.Matcher<T> is(org.hamcrest.Matcher<T> matcher)
Decorates another Matcher, retaining the behavior but allowing tests to be slightly more expressive. For example: assertThat(cheese, equalTo(smelly)) vs. assertThat(cheese, is(equalTo(smelly)))


is

public static <T> org.hamcrest.Matcher<T> is(T value)
This is a shortcut to the frequently used is(equalTo(x)). For example: assertThat(cheese, is(equalTo(smelly))) vs. assertThat(cheese, is(smelly))


is

public static <T> org.hamcrest.Matcher<T> is(java.lang.Class<T> type)
Deprecated. use isA(Class type) instead.

This is a shortcut to the frequently used is(instanceOf(SomeClass.class)). For example: assertThat(cheese, is(instanceOf(Cheddar.class))) vs. assertThat(cheese, is(Cheddar.class))


isA

public static <T> org.hamcrest.Matcher<T> isA(java.lang.Class<T> type)

anything

public static org.hamcrest.Matcher<java.lang.Object> anything()
This matcher always evaluates to true.


anything

public static org.hamcrest.Matcher<java.lang.Object> anything(java.lang.String description)
This matcher always evaluates to true.

Parameters:
description - A meaningful string used when describing itself.

hasItem

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>> hasItem(T element)

hasItem

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? super T>> hasItem(org.hamcrest.Matcher<? super T> elementMatcher)

hasItems

public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(org.hamcrest.Matcher<? super T>... elementMatchers)

hasItems

public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(T... elements)

equalTo

public static <T> org.hamcrest.Matcher<T> equalTo(T operand)
Is the value equal to another value, as tested by the Object.equals(java.lang.Object) invokedMethod?


any

public static <T> org.hamcrest.Matcher<T> 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))


instanceOf

public static <T> org.hamcrest.Matcher<T> 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));


not

public static <T> org.hamcrest.Matcher<T> not(org.hamcrest.Matcher<T> matcher)
Inverts the rule.


not

public static <T> org.hamcrest.Matcher<T> not(T value)
This is a shortcut to the frequently used not(equalTo(x)). For example: assertThat(cheese, is(not(equalTo(smelly)))) vs. assertThat(cheese, is(not(smelly)))


nullValue

public static org.hamcrest.Matcher<java.lang.Object> nullValue()
Matches if value is null.


nullValue

public static <T> org.hamcrest.Matcher<T> nullValue(java.lang.Class<T> type)
Matches if value is null. With type inference.


notNullValue

public static org.hamcrest.Matcher<java.lang.Object> notNullValue()
Matches if value is not null.


notNullValue

public static <T> org.hamcrest.Matcher<T> notNullValue(java.lang.Class<T> type)
Matches if value is not null. With type inference.


sameInstance

public static <T> org.hamcrest.Matcher<T> sameInstance(T object)
Creates a new instance of IsSame

Parameters:
object - The predicate evaluates to true only when the argument is this object.

containsString

public static org.hamcrest.Matcher<java.lang.String> containsString(java.lang.String substring)

startsWith

public static org.hamcrest.Matcher<java.lang.String> startsWith(java.lang.String substring)

endsWith

public static org.hamcrest.Matcher<java.lang.String> endsWith(java.lang.String substring)

array

public static <T> IsArray<T> array(org.hamcrest.Matcher<? super T>... elementMatchers)
Evaluates to true only if each matcher[i] is satisfied by array[i].


hasItemInArray

public static <T> org.hamcrest.Matcher<T[]> hasItemInArray(org.hamcrest.Matcher<? super T> elementMatcher)
Evaluates to true if any item in an array satisfies the given matcher.


hasItemInArray

public static <T> org.hamcrest.Matcher<T[]> hasItemInArray(T element)
This is a shortcut to the frequently used hasItemInArray(equalTo(x)). For example, assertThat(hasItemInArray(equal_to(x))) vs. assertThat(hasItemInArray(x))


arrayContaining

public static <E> org.hamcrest.Matcher<E[]> arrayContaining(E... items)

arrayContaining

public static <E> org.hamcrest.Matcher<E[]> arrayContaining(org.hamcrest.Matcher<? super E>... matchers)

arrayContaining

public static <E> org.hamcrest.Matcher<E[]> arrayContaining(java.util.List<org.hamcrest.Matcher<? super E>> matchers)

arrayContainingInAnyOrder

public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(org.hamcrest.Matcher<? super E>... matchers)

arrayContainingInAnyOrder

public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(java.util.Collection<org.hamcrest.Matcher<? super E>> matchers)

arrayContainingInAnyOrder

public static <E> org.hamcrest.Matcher<E[]> arrayContainingInAnyOrder(E... items)

arrayWithSize

public static <E> org.hamcrest.Matcher<E[]> arrayWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher)
Does array size satisfy a given matcher?


arrayWithSize

public static <E> org.hamcrest.Matcher<E[]> arrayWithSize(int size)
This is a shortcut to the frequently used arrayWithSize(equalTo(x)). For example, assertThat(arrayWithSize(equal_to(x))) vs. assertThat(arrayWithSize(x))


emptyArray

public static <E> org.hamcrest.Matcher<E[]> emptyArray()
Matches an empty array.


hasSize

public static <E> org.hamcrest.Matcher<java.util.Collection<? extends E>> hasSize(org.hamcrest.Matcher<? super java.lang.Integer> size)
Does collection size satisfy a given matcher?


hasSize

public static <E> org.hamcrest.Matcher<java.util.Collection<? extends E>> hasSize(int size)
This is a shortcut to the frequently used hasSize(equalTo(x)). For example, assertThat(hasSize(equal_to(x))) vs. assertThat(hasSize(x))


empty

public static <E> org.hamcrest.Matcher<java.util.Collection<E>> empty()
Matches an empty collection.


emptyIterable

public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> emptyIterable()
Matches an empty iterable.


contains

public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> contains(org.hamcrest.Matcher<? super E> item)

contains

public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> contains(E... items)

contains

public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> contains(org.hamcrest.Matcher<? super E>... item)

contains

public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> contains(java.util.List<org.hamcrest.Matcher<? super E>> contents)

containsInAnyOrder

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>> containsInAnyOrder(org.hamcrest.Matcher<? super T>... item)

containsInAnyOrder

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>> containsInAnyOrder(T... items)

containsInAnyOrder

public static <T> org.hamcrest.Matcher<java.lang.Iterable<? extends T>> containsInAnyOrder(java.util.Collection<org.hamcrest.Matcher<? super T>> matchers)

containsInAnyOrder

public static <E> org.hamcrest.Matcher<java.lang.Iterable<? extends E>> containsInAnyOrder(org.hamcrest.Matcher<? super E> item)

iterableWithSize

public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(org.hamcrest.Matcher<? super java.lang.Integer> sizeMatcher)

iterableWithSize

public static <E> org.hamcrest.Matcher<java.lang.Iterable<E>> iterableWithSize(int size)

hasEntry

public static <K,V> org.hamcrest.Matcher<java.util.Map<? extends K,? extends V>> hasEntry(org.hamcrest.Matcher<? super K> keyMatcher,
                                                                                          org.hamcrest.Matcher<? super V> valueMatcher)

hasEntry

public static <K,V> org.hamcrest.Matcher<java.util.Map<? extends K,? extends V>> hasEntry(K key,
                                                                                          V value)

hasKey

public static <K> org.hamcrest.Matcher<java.util.Map<? extends K,?>> hasKey(K key)

hasKey

public static <K> org.hamcrest.Matcher<java.util.Map<? extends K,?>> hasKey(org.hamcrest.Matcher<? super K> keyMatcher)

hasValue

public static <V> org.hamcrest.Matcher<java.util.Map<?,? extends V>> hasValue(org.hamcrest.Matcher<? super V> valueMatcher)

hasValue

public static <V> org.hamcrest.Matcher<java.util.Map<?,? extends V>> hasValue(V value)

isIn

public static <T> org.hamcrest.Matcher<T> isIn(java.util.Collection<T> collection)

isIn

public static <T> org.hamcrest.Matcher<T> isIn(T[] param1)

isOneOf

public static <T> org.hamcrest.Matcher<T> isOneOf(T... elements)

closeTo

public static org.hamcrest.Matcher<java.lang.Double> closeTo(double operand,
                                                             double error)

comparesEqualTo

public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> comparesEqualTo(T value)
Returns:
Is value = expected?

greaterThan

public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> greaterThan(T value)
Is value > expected?


greaterThanOrEqualTo

public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> greaterThanOrEqualTo(T value)
Is value >= expected?


lessThan

public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> lessThan(T value)
Is value < expected?


lessThanOrEqualTo

public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<T> lessThanOrEqualTo(T value)
Is value <= expected?


equalToIgnoringCase

public static org.hamcrest.Matcher<java.lang.String> equalToIgnoringCase(java.lang.String string)

equalToIgnoringWhiteSpace

public static org.hamcrest.Matcher<java.lang.String> equalToIgnoringWhiteSpace(java.lang.String string)

hasToString

public static <T> org.hamcrest.Matcher<T> hasToString(org.hamcrest.Matcher<? super java.lang.String> toStringMatcher)
Evaluates whether item.toString() satisfies a given matcher.


hasToString

public static <T> org.hamcrest.Matcher<T> hasToString(java.lang.String expectedToString)
This is a shortcut to the frequently used has_string(equalTo(x)). For example, assertThat(hasToString(equal_to(x))) vs. assertThat(hasToString(x))


typeCompatibleWith

public static <T> org.hamcrest.Matcher<java.lang.Class<?>> typeCompatibleWith(java.lang.Class<T> baseType)

eventFrom

public static org.hamcrest.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.


eventFrom

public static org.hamcrest.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 .


hasProperty

public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName)

hasProperty

public static <T> org.hamcrest.Matcher<T> hasProperty(java.lang.String propertyName,
                                                      org.hamcrest.Matcher<?> value)

samePropertyValuesAs

public static <T> org.hamcrest.Matcher<T> samePropertyValuesAs(T expectedBean)

hasXPath

public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath,
                                                              org.hamcrest.Matcher<? super java.lang.String> valueMatcher)

hasXPath

public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath,
                                                              javax.xml.namespace.NamespaceContext namespaceContext,
                                                              org.hamcrest.Matcher<? super java.lang.String> valueMatcher)

hasXPath

public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath)

hasXPath

public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath,
                                                              javax.xml.namespace.NamespaceContext namespaceContext)


Copyright © 2010. All Rights Reserved.