Groovy Documentation

## grails.test
[Java] Class MockClosureProxy

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          groovy.lang.Closure
              grails.test.AbstractClosureProxy
                  grails.test.MockClosureProxy

    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.

Authors:
  Peter Ledbrook

Field Summary

Fields inherited from class groovy.lang.Closure
OWNER_FIRST, DELEGATE_FIRST, OWNER_ONLY, DELEGATE_ONLY, TO_SELF, DONE, SKIP

Constructor Summary
`MockClosureProxy(groovy.lang.Closure target, java.lang.String methodName, java.lang.Object expectation)` Constructor.

Method Summary
`protected groovy.lang.Closure` | `createWrapper(groovy.lang.Closure c)` Creates a new `MockClosureProxy` wrapping the given closure.
`protected void` | `doAfterCall(Object[] args)` Empty implementation.
`protected void` | `doBeforeCall(Object[] args)` Checks whether the target "method" is expected or not, on the basis that this closure is mocking a method with the name `methodName`.

Methods inherited from class AbstractClosureProxy
asWritable, call, createWrapper, curry, doAfterCall, doBeforeCall, equals, getDelegate, getDirective, getMaximumNumberOfParameters, getParameterTypes, getProperty, getResolveStrategy, hashCode, isCase, setDelegate, setDirective, setProperty, setResolveStrategy

Methods inherited from class groovy.lang.Closure

groovy.lang.Closure#run(), groovy.lang.Closure#setProperty(java.lang.String, java.lang.Object), groovy.lang.Closure#getProperty(java.lang.String), groovy.lang.Closure#clone(), groovy.lang.Closure#getParameterTypes(), groovy.lang.Closure#setDelegate(java.lang.Object), groovy.lang.Closure#getOwner(), groovy.lang.Closure#getDelegate(), groovy.lang.Closure#call(), groovy.lang.Closure#call(java.lang.Object), groovy.lang.Closure#call([Ljava.lang.Object;), groovy.lang.Closure#getMaximumNumberOfParameters(), groovy.lang.Closure#setResolveStrategy(int), groovy.lang.Closure#isCase(java.lang.Object), groovy.lang.Closure#getDirective(), groovy.lang.Closure#asWritable(), groovy.lang.Closure#getResolveStrategy(), groovy.lang.Closure#getThisObject(), groovy.lang.Closure#curry([Ljava.lang.Object;), groovy.lang.Closure#setDirective(int), groovy.lang.Closure#rcurry([Ljava.lang.Object;), groovy.lang.Closure#ncurry(int, [Ljava.lang.Object;), groovy.lang.Closure#getMetaClass(), groovy.lang.Closure#setMetaClass(groovy.lang.MetaClass), groovy.lang.Closure#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.Closure#wait(), groovy.lang.Closure#wait(long), groovy.lang.Closure#wait(long, int), groovy.lang.Closure#equals(java.lang.Object), groovy.lang.Closure#toString(), groovy.lang.Closure#hashCode(), groovy.lang.Closure#getClass(), groovy.lang.Closure#notify(), groovy.lang.Closure#notifyAll()

Methods inherited from class groovy.lang.GroovyObjectSupport

groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll()

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Constructor Detail

### MockClosureProxy

    public MockClosureProxy(groovy.lang.Closure target, java.lang.String methodName, java.lang.Object expectation)

  Constructor.
  Parameters:
    target
    methodName
    expectation

Method Detail

### createWrapper

    @Override
    protected groovy.lang.Closure createWrapper(groovy.lang.Closure c)

  Creates a new `MockClosureProxy` wrapping the given closure.
  Parameters:
    `c` - The closure to wrap.
  Returns:
    the new proxy.

### doAfterCall

    @Override
    protected void doAfterCall(Object[] args)

  Empty implementation.
  Parameters:
    `args` - The arguments to the target closure.

### doBeforeCall

    @Override
    protected void doBeforeCall(Object[] args)

  Checks whether the target "method" is expected or not, on the basis that this closure is mocking a method with the name `methodName`.
  Parameters:
    `args` - The arguments to the "method" (actually the argumetns to the target closure invocation).

Groovy Documentation