T - type of the expected argument@NotThreadSafe public abstract class ArgumentMatcher<T> extends Object implements org.easymock.IArgumentMatcher
This argument matcher already verifies null-ability and type: If the argument is null or
of the wrong type the match fails. null is not a valid value, if null is expected
use EasyMock.isNull(Class).
| Constructor and Description |
|---|
ArgumentMatcher(String name)
Creates an argument matcher.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendTo(StringBuffer buffer) |
T |
match()
Registers this argument matcher to EasyMock.
|
static <T> T |
match(org.easymock.IArgumentMatcher matcher)
Registers an
IArgumentMatcher to EasyMock. |
boolean |
matches(Object arg) |
protected boolean |
verify(Matchable<?>... properties)
Verifies whether the properties match the expected values.
|
abstract boolean |
verifyMatch(T argument)
Verifies the argument matches.
|
public void appendTo(StringBuffer buffer)
appendTo in interface org.easymock.IArgumentMatcherpublic boolean matches(Object arg)
matches in interface org.easymock.IArgumentMatcherpublic abstract boolean verifyMatch(@Nonnull T argument)
It is recommended to use verify(Matchable...) in the implementation of this method
since it adds more description to the error in case the argument doesn't match.
argument - argumenttrue if argument matches expectations, false otherwise@SafeVarargs protected final boolean verify(@Nonnull Matchable<?>... properties)
properties - properties to verifytrue if the property's value matches the expected, false otherwisepublic T match()
Example:
ArgumentMatcher<MyArgumentType> customArgumentMatcher = new ArgumentMatcher<MyArgumentType>() {
...
};
// For methods returning a value
EasyMock.expect(mock.someMethod(myArgumentMatcher.match())).andReturn(...);
// For void return methods
mock.someMethod(myArgumentMatcher.match());
public static <T> T match(@Nonnull org.easymock.IArgumentMatcher matcher)
IArgumentMatcher to EasyMock.
The preferred way (type-safe) is to extend ArgumentMatcher instead of directly
implementing IArgumentMatcher, and then use match().
Example:
IArgumentMatcher customArgumentMatcher = new IArgumentMatcher() {
...
};
// For methods returning a value
EasyMock.expect(mock.someMethod(ArgumentMatcher.match(customArgumentMatcher))).andReturn(...);
// For void return methods
mock.someMethod(ArgumentMatcher.match(customArgumentMatcher));
T - type of the argumentmatcher - matcher to registerCopyright © 2015. All rights reserved.