## grails.test
Class MockClosureProxy

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

All Implemented Interfaces:
  groovy.lang.GroovyObject, Serializable, Cloneable, Runnable

    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.

Author:
  Peter Ledbrook
See Also:
  Serialized Form

Field Summary
`(package private) Object` `expectation`
`(package private) String` `methodName`

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

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

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 `this.methodName`.

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
`call, call, clone, getOwner, getThisObject, run, throwRuntimeException`

Methods inherited from class groovy.lang.GroovyObjectSupport
`getMetaClass, invokeMethod, setMetaClass`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### methodName

    String methodName

### expectation

    Object expectation

Constructor Detail

### MockClosureProxy

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

Method Detail

### doBeforeCall

    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 `this.methodName`.

  Specified by:
    `doBeforeCall` in class `AbstractClosureProxy`
  Parameters:
    `args` - The arguments to the "method" (actually the argumetns to the target closure invocation).

### doAfterCall

    protected void doAfterCall(Object[] args)

  Empty implementation.

  Specified by:
    `doAfterCall` in class `AbstractClosureProxy`
  Parameters:
    `args` - The arguments to the target closure.

### createWrapper

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

  Creates a new `MockClosureProxy` wrapping the given closure.

  Specified by:
    `createWrapper` in class `AbstractClosureProxy`
  Parameters:
    `c` - The closure to wrap.
  Returns:
    the new proxy.

Copyright (c) 2005-2009 The Grails project