private void notMockNextCallIfRequired() { final Class<?> type = Whitebox.getType(interceptionObject); if (isNextCallShouldNotBeMocked(type)) { MockRepository.putAdditionalState(MockGateway.DONT_MOCK_NEXT_CALL, true); } }
MockRepository.putAdditionalState("VerificationMode", POWERMOCKITO_CORE.wrapInMockitoSpecificVerificationMode( mock, mode)); if (invocationControl == null) {
/** * Sometimes it is useful to allow replay and verify on non-mocks. For * example when using partial mocking in some tests and no mocking in other * test-methods, but using the same setUp and tearDown. */ public static synchronized void niceReplayAndVerify() { MockRepository.putAdditionalState(NICE_REPLAY_AND_VERIFY_KEY, true); }
@Override public void notifyBeforeTestMethod(Object testInstance, Method testMethod, Object[] arguments) { MockRepository.putAdditionalState(Keys.CURRENT_TEST_INSTANCE, testInstance); MockRepository.putAdditionalState(Keys.CURRENT_TEST_METHOD, testMethod); MockRepository.putAdditionalState(Keys.CURRENT_TEST_METHOD_ARGUMENTS, arguments); for (final PowerMockTestListener testListener : powerMockTestListeners) { try { testListener.beforeTestMethod(testInstance, testMethod, arguments); } catch (Exception e) { throw new RuntimeException(String.format(ERROR_MESSAGE_TEMPLATE, "beforeTestMethod", testListener), e); } } }
@Override public Object call() throws Exception { final Class<?> type = Whitebox.getType(delegator); final boolean isFinalSystemClass = type.getName().startsWith("java.") && Modifier.isFinal(type.getModifiers()); if (!isFinalSystemClass) { MockRepository.putAdditionalState(MockGateway.DONT_MOCK_NEXT_CALL, true); } try { return method.invoke(delegator, arguments); } catch (InvocationTargetException e) { SafeExceptionRethrower.safeRethrow(e.getCause()); } return null; } };
MockRepository.putAdditionalState(NICE_REPLAY_AND_VERIFY_KEY, false); if (t instanceof RuntimeException) { throw (RuntimeException) t;
MockRepository.putAdditionalState(NICE_REPLAY_AND_VERIFY_KEY, false); if (t instanceof RuntimeException) { throw (RuntimeException) t;