blob: 5d2def392c1b3fc4fe0e95650cc8d54ff99f0ab5 [file] [log] [blame]
package groovy.mock.interceptor
/**
Intercepting calls to the collaborating object and notify the expectation object.
@author Dierk Koenig
*/
class MockInterceptor implements Interceptor {
def expectation = null
Object beforeInvoke(Object object, String methodName, Object[] arguments) {
if (!expectation) throw new IllegalStateException("Property 'expectation' must be set before use.")
return expectation.match(methodName).call(arguments)
}
Object afterInvoke(Object object, String methodName, Object[] arguments, Object result) {
return null // never used
}
boolean doInvoke() {
return false // future versions may allow collaborator method calls depending on state
}
}