public class MockitoMethodInvocationControl<T>
extends java.lang.Object
implements org.powermock.core.spi.MethodInvocationControl
MethodInvocationControl interface.| Constructor and Description |
|---|
MockitoMethodInvocationControl(java.lang.Object delegator,
T mockInstance,
java.lang.reflect.Method... methodsToMock)
Creates a new instance with a delegator.
|
| Modifier and Type | Method and Description |
|---|---|
MockHandlerAdaptor<T> |
getMockHandlerAdaptor() |
java.lang.Object |
invoke(java.lang.Object mock,
java.lang.reflect.Method method,
java.lang.Object[] arguments) |
boolean |
isMocked(java.lang.reflect.Method method) |
java.lang.Object |
replay(java.lang.Object... mocks) |
java.lang.Object |
reset(java.lang.Object... mocks) |
void |
verifyNoMoreInteractions() |
public MockitoMethodInvocationControl(java.lang.Object delegator,
T mockInstance,
java.lang.reflect.Method... methodsToMock)
null (if it is then no calls will be forwarded to this
instance). If a delegator exists (i.e. not null) all non-mocked calls
will be delegated to that instance.delegator - If the user spies on an instance the original instance must be
injected here.mockInstance - The actual mock instance. May be null. Even
though the mock instance may not be used it's needed to keep a
reference to this object otherwise it may be garbage collected
in some situations. For example when mocking static methods we
don't return the mock object and thus it will be garbage
collected (and thus the finalize method will be invoked which
will be caught by the proxy and the test will fail because we
haven't setup expectations for this method) because then that
object has no reference. In order to avoid this we keep a
reference to this instance here.methodsToMock - The methods that are mocked for this instance. If
methodsToMock is null or empty, all methods for
the invocationHandler are considered to bepublic boolean isMocked(java.lang.reflect.Method method)
isMocked in interface org.powermock.core.spi.MethodInvocationControlpublic java.lang.Object invoke(java.lang.Object mock,
java.lang.reflect.Method method,
java.lang.Object[] arguments)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwablepublic java.lang.Object replay(java.lang.Object... mocks)
replay in interface org.powermock.core.spi.DefaultBehaviorpublic java.lang.Object reset(java.lang.Object... mocks)
reset in interface org.powermock.core.spi.DefaultBehaviorpublic void verifyNoMoreInteractions()
public MockHandlerAdaptor<T> getMockHandlerAdaptor()