T - the type of the entities to be matched.public abstract class IsEqualsToEntity<T>
extends org.hamcrest.TypeSafeMatcher<T>
Matcher that can be used to create new matchers that
compare entities by their attributes.| Modifier and Type | Field and Description |
|---|---|
protected T |
expected
The expected entity.
|
| Constructor and Description |
|---|
IsEqualsToEntity(T entity)
Constructs a new instance of
IsEqualsToEntity. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMatcherDescription(org.hamcrest.Matcher<?> matcher)
Adds as the description of this matcher the
SelfDescribing.describeTo(Description) method of other matcher. |
protected void |
addTemplatedDescription(String attribute,
Object expected)
Adds a new description using the template:
|
protected <R> boolean |
checkAttribute(String attribute,
Function<T,R> getter,
T actual)
Compares the expected and the actual value of an attribute.
|
protected void |
clearDescribeTo()
Cleans the current description.
|
protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> |
containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter,
T... entities)
Utility method that generates a
Matcher that compares several
entities. |
protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> |
containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter,
T... entities)
Utility method that generates a
Matcher that compares several
entities in the same received order. |
void |
describeTo(org.hamcrest.Description description) |
describeMismatch, describeMismatchSafely, matches, matchesSafelyprotected final T expected
public IsEqualsToEntity(T entity)
IsEqualsToEntity.entity - the expected tentity.public void describeTo(org.hamcrest.Description description)
protected void addTemplatedDescription(String attribute, Object expected)
<expected class> entity with value '<expected>' for <attribute>
attribute - the name of the attribute compared.expected - the expected value.protected void addMatcherDescription(org.hamcrest.Matcher<?> matcher)
SelfDescribing.describeTo(Description) method of other matcher.matcher - the matcher whose description will be used.protected void clearDescribeTo()
protected <R> boolean checkAttribute(String attribute, Function<T,R> getter, T actual)
R - type of the value returned by the getter.attribute - the name of the attribute compared.getter - the getter function of the attribute.actual - the actual entity being compared to the expected entity.true if the value of the expected and actual attributes
are equals and false otherwise. If the result is false,
the current description will be updated.@SafeVarargs protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, T... entities)
Matcher that compares several
entities.T - type of the entity.converter - a function to create a matcher for an entity.entities - the entities to be used as the expected values.Matcher that compares several entities.@SafeVarargs protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, T... entities)
Matcher that compares several
entities in the same received order.T - The type of the entity.converter - A function to create a matcher for an entity.entities - The entities to be used as the expected values, in the
order to be compared.Matcher that compares several entities in the same
received order.Copyright © 2015. All rights reserved.