Search in sources :

Example 1 with MockitoMethod

use of org.mockito.internal.invocation.MockitoMethod in project powermock by powermock.

the class MethodInterceptorFilter method intercept.

public Object intercept(Object proxy, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
    if (isEqualsMethod(method)) {
        return proxy == args[0];
    } else if (isHashCodeMethod(method)) {
        return hashCodeForMock(proxy);
    } else if (acrossJVMSerializationFeature.isWriteReplace(method)) {
        return acrossJVMSerializationFeature.writeReplace(proxy);
    }
    MockitoMethodProxy mockitoMethodProxy = createMockitoMethodProxy(methodProxy);
    new CGLIBHacker().setMockitoNamingPolicy(methodProxy);
    MockitoMethod mockitoMethod = createMockitoMethod(method);
    CleanTraceRealMethod realMethod = new CleanTraceRealMethod(mockitoMethodProxy);
    Invocation invocation = new InvocationImpl(proxy, mockitoMethod, args, SequenceNumber.next(), realMethod, new LocationImpl());
    return handler.handle(invocation);
}
Also used : MockitoMethod(org.mockito.internal.invocation.MockitoMethod) Invocation(org.mockito.invocation.Invocation) CleanTraceRealMethod(org.mockito.internal.invocation.realmethod.CleanTraceRealMethod) LocationImpl(org.mockito.internal.debugging.LocationImpl) MockitoMethodProxy(org.mockito.internal.creation.util.MockitoMethodProxy) InvocationImpl(org.mockito.internal.invocation.InvocationImpl)

Aggregations

MockitoMethodProxy (org.mockito.internal.creation.util.MockitoMethodProxy)1 LocationImpl (org.mockito.internal.debugging.LocationImpl)1 InvocationImpl (org.mockito.internal.invocation.InvocationImpl)1 MockitoMethod (org.mockito.internal.invocation.MockitoMethod)1 CleanTraceRealMethod (org.mockito.internal.invocation.realmethod.CleanTraceRealMethod)1 Invocation (org.mockito.invocation.Invocation)1