Package | Description |
---|---|
org.hamcrest.beans |
Matchers of Java Bean properties and their values.
|
org.hamcrest.collection |
Matchers of arrays and collections.
|
org.hamcrest.core |
Fundamental matchers of objects and values, and composite matchers.
|
org.hamcrest.number |
Matchers that perform numeric comparisons.
|
org.hamcrest.object |
Matchers that inspect objects and classes.
|
org.hamcrest.text |
Matchers that perform text comparisons.
|
org.hamcrest.xml |
Matchers of XML documents.
|
Modifier and Type | Method and Description |
---|---|
static <T> Matcher<T> |
HasProperty.hasProperty(String propertyName) |
static <T> Matcher<T> |
HasPropertyWithValue.hasProperty(String propertyName,
Matcher<?> value) |
static <T> Matcher<T> |
SamePropertyValuesAs.samePropertyValuesAs(T expectedBean) |
Modifier and Type | Method and Description |
---|---|
static <T> IsArray<T> |
IsArray.array(Matcher<? super T>... elementMatchers)
Evaluates to true only if each matcher[i] is satisfied by array[i].
|
static <E> Matcher<E[]> |
IsArrayContainingInOrder.arrayContaining(E... items) |
static <E> Matcher<E[]> |
IsArrayContainingInOrder.arrayContaining(List<Matcher<? super E>> matchers) |
static <E> Matcher<E[]> |
IsArrayContainingInOrder.arrayContaining(Matcher<? super E>... matchers) |
static <E> Matcher<E[]> |
IsArrayContainingInAnyOrder.arrayContainingInAnyOrder(Collection<Matcher<? super E>> matchers) |
static <E> Matcher<E[]> |
IsArrayContainingInAnyOrder.arrayContainingInAnyOrder(E... items) |
static <E> Matcher<E[]> |
IsArrayContainingInAnyOrder.arrayContainingInAnyOrder(Matcher<? super E>... matchers) |
static <E> Matcher<E[]> |
IsArrayWithSize.arrayWithSize(int size)
This is a shortcut to the frequently used arrayWithSize(equalTo(x)).
|
static <E> Matcher<E[]> |
IsArrayWithSize.arrayWithSize(Matcher<? super Integer> sizeMatcher)
Does array size satisfy a given matcher?
|
static <E> Matcher<Iterable<E>> |
IsIterableContainingInOrder.contains(E... items) |
static <E> Matcher<Iterable<E>> |
IsIterableContainingInOrder.contains(List<Matcher<? super E>> contents) |
static <E> Matcher<Iterable<E>> |
IsIterableContainingInOrder.contains(Matcher<? super E>... items) |
static <E> Matcher<Iterable<E>> |
IsIterableContainingInOrder.contains(Matcher<E> item) |
static <T> Matcher<Iterable<T>> |
IsIterableContainingInAnyOrder.containsInAnyOrder(Collection<Matcher<? super T>> matchers) |
static <T> Matcher<Iterable<T>> |
IsIterableContainingInAnyOrder.containsInAnyOrder(Matcher<? super T>... matchers) |
static <E> Matcher<Iterable<E>> |
IsIterableContainingInAnyOrder.containsInAnyOrder(Matcher<E> item) |
static <T> Matcher<Iterable<T>> |
IsIterableContainingInAnyOrder.containsInAnyOrder(T... items) |
static <E> Matcher<Collection<E>> |
IsEmptyCollection.empty()
Matches an empty collection.
|
static <E> Matcher<E[]> |
IsArrayWithSize.emptyArray()
Matches an empty array.
|
static <E> Matcher<Iterable<E>> |
IsEmptyIterable.emptyIterable()
Matches an empty iterable.
|
static <K,V> Matcher<Map<? extends K,? extends V>> |
IsMapContaining.hasEntry(K key,
V value) |
static <K,V> Matcher<Map<? extends K,? extends V>> |
IsMapContaining.hasEntry(Matcher<? super K> keyMatcher,
Matcher<? super V> valueMatcher) |
static <T> Matcher<T[]> |
IsArrayContaining.hasItemInArray(Matcher<? super T> elementMatcher)
Evaluates to true if any item in an array satisfies the given matcher.
|
static <T> Matcher<T[]> |
IsArrayContaining.hasItemInArray(T element)
This is a shortcut to the frequently used hasItemInArray(equalTo(x)).
|
static <K> Matcher<Map<? super K,?>> |
IsMapContainingKey.hasKey(K key) |
static <K> Matcher<Map<? super K,?>> |
IsMapContainingKey.hasKey(Matcher<? super K> keyMatcher) |
static <E> Matcher<? super Collection<? extends E>> |
IsCollectionWithSize.hasSize(int size)
This is a shortcut to the frequently used hasSize(equalTo(x)).
|
static <E> Matcher<? super Collection<? extends E>> |
IsCollectionWithSize.hasSize(Matcher<? super Integer> size)
Does collection size satisfy a given matcher?
|
static <V> Matcher<? super Map<?,V>> |
IsMapContainingValue.hasValue(Matcher<? super V> valueMatcher) |
static <V> Matcher<? super Map<?,V>> |
IsMapContainingValue.hasValue(V value) |
static <T> Matcher<T> |
IsIn.isIn(Collection<T> collection) |
static <T> Matcher<T> |
IsIn.isIn(T[] elements) |
static <T> Matcher<T> |
IsIn.isOneOf(T... elements) |
static <E> Matcher<Iterable<E>> |
IsIterableWithSize.iterableWithSize(int size) |
static <E> Matcher<Iterable<E>> |
IsIterableWithSize.iterableWithSize(Matcher<? super Integer> sizeMatcher) |
Modifier and Type | Method and Description |
---|---|
static <T> Matcher<T> |
AllOf.allOf(Iterable<Matcher<? super T>> matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
AllOf.allOf(Matcher<? super T>... matchers)
Evaluates to true only if ALL of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
AllOf.allOf(Matcher<T> first,
Matcher<? super T> second)
Evaluates to true only if ALL of the passed in matchers evaluate to true.
|
static <T> Matcher<T> |
AllOf.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 <T> Matcher<T> |
AllOf.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 <T> Matcher<T> |
AllOf.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 <T> Matcher<T> |
AllOf.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 <T> Matcher<T> |
IsInstanceOf.any(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 <T> AnyOf<T> |
AnyOf.anyOf(Iterable<Matcher<? super T>> matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.
|
static <T> AnyOf<T> |
AnyOf.anyOf(Matcher<? super T>... matchers)
Evaluates to true if ANY of the passed in matchers evaluate to true.
|
static <T> AnyOf<T> |
AnyOf.anyOf(Matcher<T> first,
Matcher<? super T> second)
Evaluates to true if ANY of the passed in matchers evaluate to true.
|
static <T> AnyOf<T> |
AnyOf.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 <T> AnyOf<T> |
AnyOf.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 <T> AnyOf<T> |
AnyOf.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 <T> AnyOf<T> |
AnyOf.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 <T> Matcher<T> |
IsAnything.anything()
This matcher always evaluates to true.
|
static <T> Matcher<T> |
IsAnything.anything(String description)
This matcher always evaluates to true.
|
static <LHS> CombinableMatcher<LHS> |
CombinableMatcher.both(Matcher<? super LHS> matcher)
This is useful for fluently combining matchers that must both pass.
|
static Matcher<String> |
StringContains.containsString(String substring) |
static <T> Matcher<T> |
DescribedAs.describedAs(String description,
Matcher<T> matcher,
Object... values)
Wraps an existing matcher and overrides the description when it fails.
|
static <LHS> CombinableMatcher<LHS> |
CombinableMatcher.either(Matcher<? super LHS> matcher)
This is useful for fluently combining matchers where either may pass, for example:
|
static Matcher<String> |
StringEndsWith.endsWith(String substring) |
static <T> Matcher<? super T> |
IsEqual.equalTo(T operand)
Is the value equal to another value, as tested by the
Object.equals(java.lang.Object) invokedMethod? |
static <U> Matcher<Iterable<U>> |
Every.everyItem(Matcher<U> itemMatcher) |
static <T> Matcher<Iterable<? super T>> |
IsCollectionContaining.hasItem(Matcher<? super T> elementMatcher) |
static <T> Matcher<Iterable<? super T>> |
IsCollectionContaining.hasItem(T element) |
static <T> Matcher<Iterable<T>> |
IsCollectionContaining.hasItems(Matcher<? super T>... elementMatchers) |
static <T> Matcher<Iterable<T>> |
IsCollectionContaining.hasItems(T... elements) |
static <T> Matcher<T> |
IsInstanceOf.instanceOf(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 <T> Matcher<? super T> |
Is.is(Class<T> type)
This is a shortcut to the frequently used is(instanceOf(SomeClass.class)).
|
static <T> Matcher<T> |
Is.is(Matcher<T> matcher)
Decorates another Matcher, retaining the behavior but allowing tests
to be slightly more expressive.
|
static <T> Matcher<? super T> |
Is.is(T value)
This is a shortcut to the frequently used is(equalTo(x)).
|
static <T> Matcher<T> |
IsNot.not(Matcher<T> matcher)
Inverts the rule.
|
static <T> Matcher<? super T> |
IsNot.not(T value)
This is a shortcut to the frequently used not(equalTo(x)).
|
static <T> Matcher<T> |
IsNull.notNullValue()
Matches if value is not null.
|
static <T> Matcher<T> |
IsNull.notNullValue(Class<T> type)
Matches if value is not null.
|
static <T> Matcher<T> |
IsNull.nullValue()
Matches if value is null.
|
static <T> Matcher<T> |
IsNull.nullValue(Class<T> type)
Matches if value is null.
|
static <T> Matcher<T> |
IsSame.sameInstance(T object)
Creates a new instance of IsSame
|
static Matcher<String> |
StringStartsWith.startsWith(String substring) |
Modifier and Type | Method and Description |
---|---|
static Matcher<Double> |
IsCloseTo.closeTo(double operand,
double error) |
static <T extends Comparable<T>> |
OrderingComparison.comparesEqualTo(T value)
Is value = expected?
|
static <T extends Comparable<T>> |
OrderingComparison.greaterThan(T value)
Is value > expected?
|
static <T extends Comparable<T>> |
OrderingComparison.greaterThanOrEqualTo(T value)
Is value >= expected?
|
static <T extends Comparable<T>> |
OrderingComparison.lessThan(T value)
Is value < expected?
|
static <T extends Comparable<T>> |
OrderingComparison.lessThanOrEqualTo(T value)
Is value <= expected?
|
Modifier and Type | Method and Description |
---|---|
static Matcher<EventObject> |
IsEventFrom.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> |
IsEventFrom.eventFrom(Object source)
Constructs an IsEventFrom Matcher that returns true for any object
derived from
EventObject announced by source
. |
static <T> Matcher<T> |
HasToString.hasToString(Matcher<? super String> toStringMatcher)
Evaluates whether item.toString() satisfies a given matcher.
|
static <T> Matcher<T> |
HasToString.hasToString(String expectedToString)
This is a shortcut to the frequently used has_string(equalTo(x)).
|
static <T> Matcher<Class<?>> |
IsCompatibleType.typeCompatibleWith(Class<T> baseType) |
Modifier and Type | Method and Description |
---|---|
static Matcher<String> |
IsEqualIgnoringCase.equalToIgnoringCase(String string) |
static Matcher<String> |
IsEqualIgnoringWhiteSpace.equalToIgnoringWhiteSpace(String string) |
static Matcher<String> |
IsEmptyString.isEmptyOrNullString()
Matches if value is null or zero-length string.
|
static Matcher<String> |
IsEmptyString.isEmptyString()
Matches if value is null or zero-length string.
|
static Matcher<String> |
StringContainsInOrder.stringContainsInOrder(Iterable<String> substrings) |
Modifier and Type | Method and Description |
---|---|
static Matcher<Node> |
HasXPath.hasXPath(String xPath) |
static Matcher<Node> |
HasXPath.hasXPath(String xPath,
Matcher<? super String> valueMatcher) |
static Matcher<Node> |
HasXPath.hasXPath(String xPath,
NamespaceContext namespaceContext) |
static Matcher<Node> |
HasXPath.hasXPath(String xPath,
NamespaceContext namespaceContext,
Matcher<? super String> valueMatcher) |
Copyright © 2016. All rights reserved.