Search in sources :

Example 6 with MockitoMethodInvocationControl

use of org.powermock.api.mockito.invocation.MockitoMethodInvocationControl in project powermock by powermock.

the class PowerMockitoStubberImpl method when.

@Override
public <T> T when(final T instanceMock) {
    final MockitoMethodInvocationControl invocationControl = (MockitoMethodInvocationControl) MockRepository.getInstanceMethodInvocationControl(instanceMock);
    final T returnValue;
    if (invocationControl == null) {
        returnValue = stubber.when(instanceMock);
    } else {
        final Object mock = invocationControl.getMockHandlerAdaptor().getMock();
        stubber.when(mock);
        returnValue = instanceMock;
    }
    return returnValue;
}
Also used : MockitoMethodInvocationControl(org.powermock.api.mockito.invocation.MockitoMethodInvocationControl)

Aggregations

MockitoMethodInvocationControl (org.powermock.api.mockito.invocation.MockitoMethodInvocationControl)6 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 InvocationContainerImpl (org.mockito.internal.stubbing.InvocationContainerImpl)1 Location (org.mockito.invocation.Location)1 Stubbing (org.mockito.stubbing.Stubbing)1 MockitoNewInvocationControl (org.powermock.api.mockito.internal.invocation.MockitoNewInvocationControl)1 MockHandlerAdaptor (org.powermock.api.mockito.invocation.MockHandlerAdaptor)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1