use of org.mockito.internal.progress.MockingProgress in project mockito by mockito.
the class MockitoCore method verify.
public <T> T verify(T mock, VerificationMode mode) {
if (mock == null) {
throw nullPassedToVerify();
}
MockingDetails mockingDetails = mockingDetails(mock);
if (!mockingDetails.isMock()) {
throw notAMockPassedToVerify(mock.getClass());
}
assertNotStubOnlyMock(mock);
MockHandler handler = mockingDetails.getMockHandler();
mock = (T) VerificationStartedNotifier.notifyVerificationStarted(handler.getMockSettings().getVerificationStartedListeners(), mockingDetails);
MockingProgress mockingProgress = mockingProgress();
VerificationMode actualMode = mockingProgress.maybeVerifyLazily(mode);
mockingProgress.verificationStarted(new MockAwareVerificationMode(mock, actualMode, mockingProgress.verificationListeners()));
return mock;
}
use of org.mockito.internal.progress.MockingProgress in project mockito by mockito.
the class MockitoCore method when.
public <T> OngoingStubbing<T> when(T methodCall) {
MockingProgress mockingProgress = mockingProgress();
mockingProgress.stubbingStarted();
@SuppressWarnings("unchecked") OngoingStubbing<T> stubbing = (OngoingStubbing<T>) mockingProgress.pullOngoingStubbing();
if (stubbing == null) {
mockingProgress.reset();
throw missingMethodInvocation();
}
return stubbing;
}
use of org.mockito.internal.progress.MockingProgress in project mockito by mockito.
the class MockitoCore method clearInvocations.
public <T> void clearInvocations(T... mocks) {
MockingProgress mockingProgress = mockingProgress();
mockingProgress.validateState();
mockingProgress.reset();
mockingProgress.resetOngoingStubbing();
for (T m : mocks) {
getInvocationContainer(m).clearInvocations();
}
}
use of org.mockito.internal.progress.MockingProgress in project mockito by mockito.
the class MockedStaticImpl method clearInvocations.
@Override
public void clearInvocations() {
assertNotClosed();
MockingProgress mockingProgress = mockingProgress();
mockingProgress.validateState();
mockingProgress.reset();
mockingProgress.resetOngoingStubbing();
getInvocationContainer(control.getType()).clearInvocations();
}
use of org.mockito.internal.progress.MockingProgress in project mockito by mockito.
the class MockedStaticImpl method verify.
@Override
public void verify(Verification verification, VerificationMode mode) {
assertNotClosed();
MockingDetails mockingDetails = Mockito.mockingDetails(control.getType());
MockHandler handler = mockingDetails.getMockHandler();
VerificationStartedNotifier.notifyVerificationStarted(handler.getMockSettings().getVerificationStartedListeners(), mockingDetails);
MockingProgress mockingProgress = mockingProgress();
VerificationMode actualMode = mockingProgress.maybeVerifyLazily(mode);
mockingProgress.verificationStarted(new MockAwareVerificationMode(control.getType(), actualMode, mockingProgress.verificationListeners()));
try {
verification.apply();
} catch (MockitoException | MockitoAssertionError e) {
throw e;
} catch (Throwable t) {
throw new MockitoException(join("An unexpected error occurred while verifying a static stub", "", "To correctly verify a stub, invoke a single static method of " + control.getType().getName() + " in the provided lambda.", "For example, if a method 'sample' was defined, provide a lambda or anonymous class containing the code", "", "() -> " + control.getType().getSimpleName() + ".sample()", "or", control.getType().getSimpleName() + "::sample"), t);
}
}
Aggregations