Package org.mockito.internal.handler
Class MockHandlerImpl<T>
- java.lang.Object
-
- org.mockito.internal.handler.MockHandlerImpl<T>
-
- Type Parameters:
T
- type of mock object to handle
- All Implemented Interfaces:
java.io.Serializable
,MockHandler<T>
public class MockHandlerImpl<T> extends java.lang.Object implements MockHandler<T>
Invocation handler set on mock objects.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) InvocationContainerImpl
invocationContainer
(package private) MatchersBinder
matchersBinder
private MockCreationSettings<T>
mockSettings
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description MockHandlerImpl(MockCreationSettings<T> mockSettings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InvocationContainer
getInvocationContainer()
Returns the object that holds all invocations on the mock object, including stubbings with declared answers.MockCreationSettings<T>
getMockSettings()
Read-only settings the mock object was created with.java.lang.Object
handle(Invocation invocation)
Takes an invocation object and handles it.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
invocationContainer
InvocationContainerImpl invocationContainer
-
matchersBinder
MatchersBinder matchersBinder
-
mockSettings
private final MockCreationSettings<T> mockSettings
-
-
Constructor Detail
-
MockHandlerImpl
public MockHandlerImpl(MockCreationSettings<T> mockSettings)
-
-
Method Detail
-
handle
public java.lang.Object handle(Invocation invocation) throws java.lang.Throwable
Description copied from interface:MockHandler
Takes an invocation object and handles it.The default implementation provided by Mockito handles invocations by recording method calls on mocks for further verification, captures the stubbing information when mock is stubbed, returns the stubbed values for invocations that have been stubbed, and much more.
- Specified by:
handle
in interfaceMockHandler<T>
- Parameters:
invocation
- The invocation to handle- Returns:
- Result
- Throws:
java.lang.Throwable
- Throwable
-
getMockSettings
public MockCreationSettings<T> getMockSettings()
Description copied from interface:MockHandler
Read-only settings the mock object was created with. SeeMockito.mock(Class, MockSettings)
- Specified by:
getMockSettings
in interfaceMockHandler<T>
- Returns:
- read-only settings of the mock
-
getInvocationContainer
public InvocationContainer getInvocationContainer()
Description copied from interface:MockHandler
Returns the object that holds all invocations on the mock object, including stubbings with declared answers. Do not provide your own implementation. Returned object is an internal implementation, hidden beneath a public marker interface.Please do not provide your own implementation of
InvocationContainer
interface at this point. If you have a use case that requires your own implementation ofInvocationContainer
please reach out to us. You can open a ticket in our issue tracker to start a discussion.- Specified by:
getInvocationContainer
in interfaceMockHandler<T>
- Returns:
- container of invocations, stubbings, and answers of the mock. The container is not part of the public API, please do not cast it or provide custom implementations.
-
-