T - the type of the entities to be matched.public abstract class IsEqualToEntity<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 |
|---|
IsEqualToEntity(T entity)
Constructs a new instance of
IsEqualToEntity. |
| 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 |
checkArrayAttribute(String attribute,
Function<T,R[]> getter,
T actual)
Compares the expected and the actual value of an array attribute.
|
protected <R> boolean |
checkArrayAttribute(String attribute,
Function<T,R[]> getter,
T actual,
Function<R[],org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
Compares the expected and the actual value of an array attribute.
|
protected <R> boolean |
checkAttribute(String attribute,
Function<T,R> getter,
T actual)
Compares the expected and the actual value of an attribute.
|
protected <R> boolean |
checkAttribute(String attribute,
Function<T,R> getter,
T actual,
Function<R,org.hamcrest.Matcher<R>> matcherFactory) |
protected boolean |
checkIntArrayAttribute(String attribute,
Function<T,int[]> getter,
T actual)
Compares the expected and the actual value of an int array attribute.
|
protected <R> boolean |
checkIterableAttribute(String attribute,
Function<T,Iterable<R>> getter,
T actual,
Function<Iterable<R>,org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
Compares the expected and the actual value of an iterable 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,
Iterable<T> entities)
Utility method that generates a
Matcher that compares several
entities. |
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,
Iterable<T> entities)
Utility method that generates a
Matcher that compares several
entities in the same received order. |
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 IsEqualToEntity(T entity)
IsEqualToEntity.entity - the expected entity.@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.protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInAnyOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, Iterable<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.protected static <T> org.hamcrest.Matcher<Iterable<? extends T>> containsEntityInOrder(Function<T,org.hamcrest.Matcher<? super T>> converter, Iterable<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.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, Function<R,org.hamcrest.Matcher<R>> matcherFactory)
protected <R> boolean checkArrayAttribute(String attribute, Function<T,R[]> getter, T actual, Function<R[],org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
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.matcherFactory - a function that creates a matcher for the expected
array values.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.protected <R> boolean checkIterableAttribute(String attribute, Function<T,Iterable<R>> getter, T actual, Function<Iterable<R>,org.hamcrest.Matcher<Iterable<? extends R>>> matcherFactory)
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.matcherFactory - a function that creates a matcher for the expected
iterable values.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.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.protected <R> boolean checkArrayAttribute(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.protected boolean checkIntArrayAttribute(String attribute, Function<T,int[]> getter, T actual)
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.Copyright © 2018. All rights reserved.