@@ -0,0 +1,1771 @@
+package com.cyrusinnovation.mockitogroovysupport;%0A%0Aimport org.mockito.cglib.proxy.*;%0Aimport org.mockito.exceptions.base.*;%0Aimport org.mockito.internal.*;%0Aimport org.mockito.internal.creation.*;%0Aimport org.mockito.internal.creation.jmock.*;%0Aimport org.mockito.invocation.*;%0Aimport org.mockito.mock.*;%0A%0A/**%0A * Variant of Mockito's built-in CglibMockMaker, except that it uses a Groovy-friendly%0A * version of MethodInterceptorFilter.%0A */%0Apublic class GroovyCglibMockMaker %7B%0A%0A    public %3CT%3E T createMock(MockCreationSettings%3CT%3E settings, MockHandler handler) %7B%0A        InternalMockHandler mockitoHandler = cast(handler);%0A        return ClassImposterizer.INSTANCE.imposterise(%0A                new MethodInterceptorFilter(mockitoHandler, settings), settings.getTypeToMock(), settings.getExtraInterfaces());%0A    %7D%0A%0A    private InternalMockHandler cast(MockHandler handler) %7B%0A        if (!(handler instanceof InternalMockHandler)) %7B%0A            throw new MockitoException(%22At the moment you cannot provide own implementations of MockHandler.%22 +%0A                    %22%5CnPlease see the javadocs for the MockMaker interface.%22);%0A        %7D%0A        return (InternalMockHandler) handler;%0A    %7D%0A%0A    public void resetMock(Object mock, MockHandler newHandler, MockCreationSettings settings) %7B%0A        ((Factory) mock).setCallback(0, new MethodInterceptorFilter(cast(newHandler), settings));%0A    %7D%0A%0A    public MockHandler getHandler(Object mock) %7B%0A        if (!(mock instanceof Factory)) %7B%0A            return null;%0A        %7D%0A        Factory factory = (Factory) mock;%0A        Callback callback = factory.getCallback(0);%0A        if (!(callback instanceof MethodInterceptorFilter)) %7B%0A            return null;%0A        %7D%0A        return ((MethodInterceptorFilter) callback).getHandler();%0A    %7D%0A%7D%0A

Implement GroovyCglibMockMaker as an exact copy of Mockito's default CglibMockMaker.