/** * Returns a MockingDetails instance that enables inspecting a particular object for Mockito related information. * Can be used to find out if given object is a Mockito mock * or to find out if a given mock is a spy or mock. * <p> * In future Mockito versions MockingDetails may grow and provide other useful information about the mock, * e.g. invocations, stubbing info, etc. * * @param toInspect - object to inspect. null input is allowed. * @return A {@link org.mockito.MockingDetails} instance. * @since 1.9.5 */ @CheckReturnValue public static MockingDetails mockingDetails(Object toInspect) { return MOCKITO_CORE.mockingDetails(toInspect); }
/** * Returns a MockingDetails instance that enables inspecting a particular object for Mockito related information. * Can be used to find out if given object is a Mockito mock * or to find out if a given mock is a spy or mock. * <p> * In future Mockito versions MockingDetails may grow and provide other useful information about the mock, * e.g. invocations, stubbing info, etc. * * @param toInspect - object to inspect * @return A {@link org.mockito.MockingDetails} instance. * @since 1.9.5 */ @Incubating public static MockingDetails mockingDetails(Object toInspect) { return MOCKITO_CORE.mockingDetails(toInspect); }
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; }