Package grails.test
Class MockClosureProxy
- java.lang.Object
-
- groovy.lang.GroovyObjectSupport
-
- groovy.lang.Closure
-
- grails.test.AbstractClosureProxy
-
- grails.test.MockClosureProxy
-
- All Implemented Interfaces:
groovy.lang.GroovyCallable,groovy.lang.GroovyObject,java.io.Serializable,java.lang.Cloneable,java.lang.Runnable,java.util.concurrent.Callable
public class MockClosureProxy extends AbstractClosureProxy
This closure proxy stores an expectation and checks it before each call to the target closure. It is used by the Grails mocking framework.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MockClosureProxy(groovy.lang.Closure<?> target, java.lang.String methodName, java.lang.Object expectation)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected groovy.lang.Closure<?>createWrapper(groovy.lang.Closure<?> c)Creates a newMockClosureProxywrapping the given closure.protected voiddoAfterCall(java.lang.Object[] args)Empty implementation.protected voiddoBeforeCall(java.lang.Object[] args)Checks whether the target "method" is expected or not, on the basis that this closure is mocking a method with the namemethodName.-
Methods inherited from class grails.test.AbstractClosureProxy
asWritable, call, curry, equals, getDelegate, getDirective, getMaximumNumberOfParameters, getParameterTypes, getProperty, getResolveStrategy, hashCode, isCase, setDelegate, setDirective, setProperty, setResolveStrategy
-
Methods inherited from class groovy.lang.Closure
andThen, andThenSelf, andThenSelf, call, call, clone, compose, composeSelf, composeSelf, curry, dehydrate, getOwner, getThisObject, leftShift, leftShift, memoize, memoizeAtLeast, memoizeAtMost, memoizeBetween, ncurry, ncurry, rcurry, rcurry, rehydrate, rightShift, run, throwRuntimeException, trampoline, trampoline
-
-
-
-
Method Detail
-
doBeforeCall
protected void doBeforeCall(java.lang.Object[] args)
Checks whether the target "method" is expected or not, on the basis that this closure is mocking a method with the namemethodName.- Specified by:
doBeforeCallin classAbstractClosureProxy- Parameters:
args- The arguments to the "method" (actually the argumetns to the target closure invocation).
-
doAfterCall
protected void doAfterCall(java.lang.Object[] args)
Empty implementation.- Specified by:
doAfterCallin classAbstractClosureProxy- Parameters:
args- The arguments to the target closure.
-
createWrapper
protected groovy.lang.Closure<?> createWrapper(groovy.lang.Closure<?> c)
Creates a newMockClosureProxywrapping the given closure.- Specified by:
createWrapperin classAbstractClosureProxy- Parameters:
c- The closure to wrap.- Returns:
- the new proxy.
-
-