private static boolean isNiceReplayAndVerifyMode() { final Boolean mode = (Boolean) MockRepository.getAdditionalState(NICE_REPLAY_AND_VERIFY_KEY); return mode != null && mode; } }
@Override public void notifyAfterTestMethod(boolean successful) { final Object test = MockRepository.getAdditionalState(Keys.CURRENT_TEST_INSTANCE); final Method testMethod = MockRepository.getAdditionalState(Keys.CURRENT_TEST_METHOD); final Object[] testArguments = MockRepository.getAdditionalState(Keys.CURRENT_TEST_METHOD_ARGUMENTS); final TestMethodResult testResult = new TestMethodResultImpl((successful ? Result.SUCCESSFUL : Result.FAILED)); notifyAfterTestMethod(test, testMethod, testArguments, testResult); } }
@Override public synchronized Object verify(Object... mocks) { final VerificationMode verificationMode; Object mode = MockRepository.getAdditionalState("VerificationMode"); if (mode != null) { if (mode instanceof VerificationMode) { verificationMode = (VerificationMode) mode; } else { throw new IllegalStateException("Internal error. VerificationMode in MockRepository was not of type " + VerificationMode.class.getName() + "."); } } else { verificationMode = times(1); } Mockito.verify(substitute, verificationMode); return null; }
private static boolean shouldMockThisCall() { Object shouldSkipMockingOfNextCall = MockRepository.getAdditionalState(DONT_MOCK_NEXT_CALL); final boolean shouldMockThisCall = shouldSkipMockingOfNextCall == null; MockRepository.removeAdditionalState(DONT_MOCK_NEXT_CALL); return shouldMockThisCall; }