MockClosureProxy (Grails 6.0.0)

Package: grails.test

## [Java] Class MockClosureProxy

- 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
    Modifiers | Name | Description
    --- | --- | ---
    `java.lang.Object` | `expectation` |
    `java.lang.String` | `methodName` |
    `private static long` | `serialVersionUID` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class AbstractClosureProxy` | `target`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `MockClosureProxy (groovy.lang.Closure<?> target, java.lang.String methodName, java.lang.Object expectation)` Constructor.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and 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`.

  - ### Inherited Methods Summary

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

- - ### Field Detail

    - #### java.lang.Object expectation

    - #### java.lang.String methodName

    - #### private static final long serialVersionUID

  - ### Constructor Detail

    - #### public MockClosureProxy(groovy.lang.Closure<?> target, java.lang.String methodName, java.lang.Object expectation)

      Constructor.

      Parameters:
        target
        methodName
        expectation

  - ### Method Detail

    - #### @java.lang.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.

    - #### @java.lang.Override protected void doAfterCall(java.lang.Object[] args)

      Empty implementation.

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

    - #### @java.lang.Override 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`.

      Parameters:
        `args` - The arguments to the "method" (actually the argumetns to the target closure invocation).