Package grails.test

Class 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
    • Field Summary

      • Fields inherited from class groovy.lang.Closure

        DELEGATE_FIRST, DELEGATE_ONLY, DONE, IDENTITY, maximumNumberOfParameters, OWNER_FIRST, OWNER_ONLY, parameterTypes, SKIP, TO_SELF
    • 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 new MockClosureProxy wrapping the given closure.
      protected void doAfterCall​(java.lang.Object[] args)
      Empty implementation.
      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 name methodName.
      • 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
      • Methods inherited from class groovy.lang.GroovyObjectSupport

        getMetaClass, setMetaClass
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface groovy.lang.GroovyObject

        invokeMethod
    • Constructor Detail

      • MockClosureProxy

        public MockClosureProxy​(groovy.lang.Closure<?> target,
                                java.lang.String methodName,
                                java.lang.Object expectation)
        Constructor.
        Parameters:
        target -
        methodName -
        expectation -
    • 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 name 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​(java.lang.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.