Class CreationSettings<T>
java.lang.Object
org.mockito.internal.creation.settings.CreationSettings<T>
- All Implemented Interfaces:
Serializable
,MockCreationSettings<T>
- Direct Known Subclasses:
MockSettingsImpl
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Object[]
protected Type
protected List
<InvocationListener> protected String
protected MockName
protected MockType
protected String
private Object
protected SerializableMode
private static final long
protected Object
protected Strictness
protected boolean
protected List
<StubbingLookupListener> protected boolean
private boolean
protected List
<VerificationStartedListener> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionObject[]
Used when arguments should be passed to the mocked object's constructor, regardless of whether these arguments are supplied directly, or whether they include the outer instance.the default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer)
.the extra interfaces the mock object should implement.The generic type of the mock, if any.InvocationListener
instances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...)
.Returns theMockMaker
which shall be used to create the mock.the name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String)
.Returns theMockType
for the mock being created.getName()
Used when mocking non-static inner classes in conjunction withMockCreationSettings.isUsingConstructor()
the spied instance - needed for spies.Sets strictness level for the mock, e.g.ReturnsStubbingLookupListener
instances attached to this mock viaMockSettings.stubbingLookupListeners(StubbingLookupListener...)
.Mocked type.VerificationStartedListener
instances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)
boolean
boolean
if the mock is serializable, seeMockSettings.serializable()
.boolean
Whether the mock should not make a best effort to preserve annotations.boolean
Whether the mock is only for stubbing, i.e.boolean
Informs whether the mock instance should be created via constructorsetExtraInterfaces
(Set<Class<?>> extraInterfaces) setGenericTypeToMock
(Type genericTypeToMock) setMockName
(MockName mockName) void
setMockType
(MockType mockType) setSerializableMode
(SerializableMode serializableMode) setTypeToMock
(Class<T> typeToMock)
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
typeToMock
-
genericTypeToMock
-
extraInterfaces
-
name
-
spiedInstance
-
defaultAnswer
-
mockName
-
serializableMode
-
invocationListeners
-
stubbingLookupListeners
-
verificationStartedListeners
-
stubOnly
protected boolean stubOnly -
stripAnnotations
protected boolean stripAnnotations -
useConstructor
private boolean useConstructor -
outerClassInstance
-
constructorArgs
-
strictness
-
mockMaker
-
mockType
-
-
Constructor Details
-
CreationSettings
public CreationSettings() -
CreationSettings
-
-
Method Details
-
getTypeToMock
Description copied from interface:MockCreationSettings
Mocked type. An interface or class the mock should implement / extend.- Specified by:
getTypeToMock
in interfaceMockCreationSettings<T>
-
setTypeToMock
-
setGenericTypeToMock
-
getExtraInterfaces
Description copied from interface:MockCreationSettings
the extra interfaces the mock object should implement.- Specified by:
getExtraInterfaces
in interfaceMockCreationSettings<T>
-
setExtraInterfaces
-
getName
-
getSpiedInstance
Description copied from interface:MockCreationSettings
the spied instance - needed for spies.- Specified by:
getSpiedInstance
in interfaceMockCreationSettings<T>
-
getDefaultAnswer
Description copied from interface:MockCreationSettings
the default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer)
.- Specified by:
getDefaultAnswer
in interfaceMockCreationSettings<T>
-
getMockName
Description copied from interface:MockCreationSettings
the name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String)
.- Specified by:
getMockName
in interfaceMockCreationSettings<T>
-
setMockName
-
isSerializable
public boolean isSerializable()Description copied from interface:MockCreationSettings
if the mock is serializable, seeMockSettings.serializable()
.- Specified by:
isSerializable
in interfaceMockCreationSettings<T>
-
setSerializableMode
-
getSerializableMode
- Specified by:
getSerializableMode
in interfaceMockCreationSettings<T>
- Returns:
- the serializable mode of this mock
-
getInvocationListeners
Description copied from interface:MockCreationSettings
InvocationListener
instances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...)
.- Specified by:
getInvocationListeners
in interfaceMockCreationSettings<T>
-
getVerificationStartedListeners
Description copied from interface:MockCreationSettings
VerificationStartedListener
instances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)
- Specified by:
getVerificationStartedListeners
in interfaceMockCreationSettings<T>
-
getStubbingLookupListeners
Description copied from interface:MockCreationSettings
ReturnsStubbingLookupListener
instances attached to this mock viaMockSettings.stubbingLookupListeners(StubbingLookupListener...)
. The resulting list is mutable, you can add/remove listeners even after the mock was created.For more details see
StubbingLookupListener
.- Specified by:
getStubbingLookupListeners
in interfaceMockCreationSettings<T>
-
isUsingConstructor
public boolean isUsingConstructor()Description copied from interface:MockCreationSettings
Informs whether the mock instance should be created via constructor- Specified by:
isUsingConstructor
in interfaceMockCreationSettings<T>
-
isStripAnnotations
public boolean isStripAnnotations()Description copied from interface:MockCreationSettings
Whether the mock should not make a best effort to preserve annotations.- Specified by:
isStripAnnotations
in interfaceMockCreationSettings<T>
-
getConstructorArgs
Description copied from interface:MockCreationSettings
Used when arguments should be passed to the mocked object's constructor, regardless of whether these arguments are supplied directly, or whether they include the outer instance.- Specified by:
getConstructorArgs
in interfaceMockCreationSettings<T>
- Returns:
- An array of arguments that are passed to the mocked object's constructor. If
MockCreationSettings.getOuterClassInstance()
is available, it is prepended to the passed arguments.
-
getOuterClassInstance
Description copied from interface:MockCreationSettings
Used when mocking non-static inner classes in conjunction withMockCreationSettings.isUsingConstructor()
- Specified by:
getOuterClassInstance
in interfaceMockCreationSettings<T>
- Returns:
- the outer class instance used for creation of the mock object via the constructor.
-
isStubOnly
public boolean isStubOnly()Description copied from interface:MockCreationSettings
Whether the mock is only for stubbing, i.e. does not remember parameters on its invocation and therefore cannot be used for verification- Specified by:
isStubOnly
in interfaceMockCreationSettings<T>
-
isLenient
public boolean isLenient()- Specified by:
isLenient
in interfaceMockCreationSettings<T>
-
getStrictness
Description copied from interface:MockCreationSettings
Sets strictness level for the mock, e.g. havingStrictness.STRICT_STUBS
characteristic. For more information about using mocks with custom strictness, seeMockSettings.strictness(Strictness)
.- Specified by:
getStrictness
in interfaceMockCreationSettings<T>
-
getMockMaker
Description copied from interface:MockCreationSettings
Returns theMockMaker
which shall be used to create the mock. When the return value isnull
, the default shall be used.- Specified by:
getMockMaker
in interfaceMockCreationSettings<T>
- See Also:
-
getGenericTypeToMock
Description copied from interface:MockCreationSettings
The generic type of the mock, if any.- Specified by:
getGenericTypeToMock
in interfaceMockCreationSettings<T>
-
getMockType
Description copied from interface:MockCreationSettings
Returns theMockType
for the mock being created.- Specified by:
getMockType
in interfaceMockCreationSettings<T>
- See Also:
-
setMockType
-