@Override public void when(Class<?> classMock) { MockitoMethodInvocationControl invocationControl = (MockitoMethodInvocationControl) MockRepository .getStaticMethodInvocationControl(classMock); addAnswersForStubbing(invocationControl); }
private static void verifyNoMoreInteractions(Class<?>... types) { for (Class<?> type : types) { final MockitoMethodInvocationControl invocationHandler = (MockitoMethodInvocationControl) MockRepository .getStaticMethodInvocationControl(type); if (invocationHandler != null) { invocationHandler.verifyNoMoreInteractions(); } MockitoNewInvocationControl<?> newInvocationControl = (MockitoNewInvocationControl<?>) MockRepository.getNewInstanceControl(type); if (newInvocationControl != null) { newInvocationControl.verifyNoMoreInteractions(); } } } }
@Override public void when(Class<?> classMock) { MockitoMethodInvocationControl invocationControl = (MockitoMethodInvocationControl) MockRepository.getStaticMethodInvocationControl(classMock); final Object mock = invocationControl.getMockHandlerAdaptor().getMock(); stubber.when(mock); }
private void init() { if (object instanceof Class<?>) { objectType = (Class<?>) object; methodInvocationControl = MockRepository.getStaticMethodInvocationControl(objectType); } else { final Class<?> type = object.getClass(); UnproxiedType unproxiedType = WhiteboxImpl.getUnproxiedType(type); objectType = unproxiedType.getOriginalType(); methodInvocationControl = MockRepository.getInstanceMethodInvocationControl(object); } method = findMethodToInvoke(methodName, sig, objectType); }
private static void verifyNoMoreInteractions(Class<?>... types) { for (Class<?> type : types) { final MockitoMethodInvocationControl invocationHandler = (MockitoMethodInvocationControl) MockRepository .getStaticMethodInvocationControl(type); if (invocationHandler != null) { invocationHandler.verifyNoMoreInteractions(); } MockitoNewInvocationControl<?> newInvocationControl = (MockitoNewInvocationControl<?>) MockRepository.getNewInstanceControl(type); if (newInvocationControl != null) { newInvocationControl.verifyNoMoreInteractions(); } } } }
private static synchronized void replay(Class<?>... types) { for (Class<?> type : types) { final MethodInvocationControl invocationHandler = MockRepository.getStaticMethodInvocationControl(type); if (invocationHandler != null) { invocationHandler.replay(); } NewInvocationControl<?> newInvocationControl = MockRepository.getNewInstanceControl(type); if (newInvocationControl != null) { newInvocationControl.replay(); } } }
/** * Reset a list of class mocks. */ public static synchronized void reset(Class<?>... classMocks) { for (Class<?> type : classMocks) { final MethodInvocationControl invocationHandler = MockRepository.getStaticMethodInvocationControl(type); if (invocationHandler != null) { invocationHandler.reset(); } NewInvocationControl<?> newInvocationControl = MockRepository.getNewInstanceControl(type); if (newInvocationControl != null) { try { newInvocationControl.reset(); } catch (AssertionError e) { NewInvocationControlAssertionError.throwAssertionErrorForNewSubstitutionFailure(e, type); } } } }
/** * Note: doesn't clear PowerMock state. */ private static synchronized void verifyClass(Class<?>... types) { for (Class<?> type : types) { final MethodInvocationControl invocationHandler = MockRepository.getStaticMethodInvocationControl(type); if (invocationHandler != null) { invocationHandler.verify(); } NewInvocationControl<?> newInvocationControl = MockRepository.getNewInstanceControl(type); if (newInvocationControl != null) { try { newInvocationControl.verify(); } catch (AssertionError e) { NewInvocationControlAssertionError.throwAssertionErrorForNewSubstitutionFailure(e, type); } } } }