Top Description Fields Constructors Methods
org.hamcrest.integration

public Class EasyMock2Adapter

extends Object
implements IArgumentMatcher
Class Inheritance
All Implemented Interfaces
org.easymock.IArgumentMatcher
Imports
org.easymock.IArgumentMatcher, .EasyMock, org.hamcrest.Matcher, .StringDescription

An adapter allowing a Hamcrest org.hamcrest.Matcher to act as an EasyMock org.easymock.IArgumentMatcher.
Author
Joe Walnes

Field Summary

Modifier and TypeField and Description
private final Matcher<?>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IArgumentMatcher
adapt(Matcher<?> matcher)

Convenience factory method that will adapt a Hamcrest org.hamcrest.Matcher to act as an EasyMock org.easymock.IArgumentMatcher and report it to EasyMock so it can be kept track of.

public void
appendTo(StringBuffer
the buffer to which the string representation is appended.
buffer
)

Implements org.easymock.IArgumentMatcher.appendTo.

Appends a string representation of this matcher to the given buffer.
public boolean
matches(Object
the argument
argument
)

Implements org.easymock.IArgumentMatcher.matches.

Returns whether this matcher accepts the given argument.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hamcrestMatcherback to summary
private final Matcher<?> hamcrestMatcher

Constructor Detail

EasyMock2Adapterback to summary
public EasyMock2Adapter(Matcher<?> matcher)

Method Detail

adaptback to summary
public static IArgumentMatcher adapt(Matcher<?> matcher)

Convenience factory method that will adapt a Hamcrest org.hamcrest.Matcher to act as an EasyMock org.easymock.IArgumentMatcher and report it to EasyMock so it can be kept track of.

appendToback to summary
public void appendTo(StringBuffer buffer)

Implements org.easymock.IArgumentMatcher.appendTo.

Doc from org.easymock.IArgumentMatcher.appendTo.

Appends a string representation of this matcher to the given buffer. In case of failure, the printed message will show this string to allow to know which matcher was used for the failing call.

Parameters
buffer:StringBuffer

the buffer to which the string representation is appended.

Annotations
@Override
matchesback to summary
public boolean matches(Object argument)

Implements org.easymock.IArgumentMatcher.matches.

Doc from org.easymock.IArgumentMatcher.matches.

Returns whether this matcher accepts the given argument.

Like Object.equals(), it should be aware that the argument passed might be null and of any type. So you will usually start the method with an instanceof and/or null check.

The method should never assert if the argument doesn't match. It should only return false. EasyMock will take care of asserting if the call is really unexpected.

Parameters
argument:Object

the argument

Returns:boolean

whether this matcher accepts the given argument.

Annotations
@Override