Class CreationSettings<T>
- java.lang.Object
-
- org.mockito.internal.creation.settings.CreationSettings<T>
-
- All Implemented Interfaces:
java.io.Serializable
,MockCreationSettings<T>
- Direct Known Subclasses:
MockSettingsImpl
public class CreationSettings<T> extends java.lang.Object implements MockCreationSettings<T>, java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object[]
constructorArgs
protected Answer<java.lang.Object>
defaultAnswer
protected java.util.Set<java.lang.Class<?>>
extraInterfaces
protected java.util.List<InvocationListener>
invocationListeners
protected boolean
lenient
protected MockName
mockName
protected java.lang.String
name
private java.lang.Object
outerClassInstance
protected SerializableMode
serializableMode
private static long
serialVersionUID
protected java.lang.Object
spiedInstance
protected boolean
stripAnnotations
protected java.util.List<StubbingLookupListener>
stubbingLookupListeners
protected boolean
stubOnly
protected java.lang.Class<T>
typeToMock
private boolean
useConstructor
protected java.util.List<VerificationStartedListener>
verificationStartedListeners
-
Constructor Summary
Constructors Constructor Description CreationSettings()
CreationSettings(CreationSettings copy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object[]
getConstructorArgs()
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.Answer<java.lang.Object>
getDefaultAnswer()
the default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer)
.java.util.Set<java.lang.Class<?>>
getExtraInterfaces()
the extra interfaces the mock object should implement.java.util.List<InvocationListener>
getInvocationListeners()
InvocationListener
instances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...)
.MockName
getMockName()
the name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String)
.java.lang.String
getName()
java.lang.Object
getOuterClassInstance()
Used when mocking non-static inner classes in conjunction withMockCreationSettings.isUsingConstructor()
SerializableMode
getSerializableMode()
java.lang.Object
getSpiedInstance()
the spied instance - needed for spies.java.util.List<StubbingLookupListener>
getStubbingLookupListeners()
ReturnsStubbingLookupListener
instances attached to this mock viaMockSettings.stubbingLookupListeners(StubbingLookupListener...)
.java.lang.Class<T>
getTypeToMock()
Mocked type.java.util.List<VerificationStartedListener>
getVerificationStartedListeners()
VerificationStartedListener
instances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)
boolean
isLenient()
Informs if the mock was created with "lenient" strictness, e.g.boolean
isSerializable()
if the mock is serializable, seeMockSettings.serializable()
.boolean
isStripAnnotations()
Whether the mock should not make a best effort to preserve annotations.boolean
isStubOnly()
Whether the mock is only for stubbing, i.e.boolean
isUsingConstructor()
Informs whether the mock instance should be created via constructorCreationSettings<T>
setExtraInterfaces(java.util.Set<java.lang.Class<?>> extraInterfaces)
CreationSettings<T>
setMockName(MockName mockName)
CreationSettings<T>
setSerializableMode(SerializableMode serializableMode)
CreationSettings<T>
setTypeToMock(java.lang.Class<T> typeToMock)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
typeToMock
protected java.lang.Class<T> typeToMock
-
extraInterfaces
protected java.util.Set<java.lang.Class<?>> extraInterfaces
-
name
protected java.lang.String name
-
spiedInstance
protected java.lang.Object spiedInstance
-
defaultAnswer
protected Answer<java.lang.Object> defaultAnswer
-
mockName
protected MockName mockName
-
serializableMode
protected SerializableMode serializableMode
-
invocationListeners
protected java.util.List<InvocationListener> invocationListeners
-
stubbingLookupListeners
protected java.util.List<StubbingLookupListener> stubbingLookupListeners
-
verificationStartedListeners
protected java.util.List<VerificationStartedListener> verificationStartedListeners
-
stubOnly
protected boolean stubOnly
-
stripAnnotations
protected boolean stripAnnotations
-
useConstructor
private boolean useConstructor
-
outerClassInstance
private java.lang.Object outerClassInstance
-
constructorArgs
private java.lang.Object[] constructorArgs
-
lenient
protected boolean lenient
-
-
Constructor Detail
-
CreationSettings
public CreationSettings()
-
CreationSettings
public CreationSettings(CreationSettings copy)
-
-
Method Detail
-
getTypeToMock
public java.lang.Class<T> getTypeToMock()
Description copied from interface:MockCreationSettings
Mocked type. An interface or class the mock should implement / extend.- Specified by:
getTypeToMock
in interfaceMockCreationSettings<T>
-
setTypeToMock
public CreationSettings<T> setTypeToMock(java.lang.Class<T> typeToMock)
-
getExtraInterfaces
public java.util.Set<java.lang.Class<?>> getExtraInterfaces()
Description copied from interface:MockCreationSettings
the extra interfaces the mock object should implement.- Specified by:
getExtraInterfaces
in interfaceMockCreationSettings<T>
-
setExtraInterfaces
public CreationSettings<T> setExtraInterfaces(java.util.Set<java.lang.Class<?>> extraInterfaces)
-
getName
public java.lang.String getName()
-
getSpiedInstance
public java.lang.Object getSpiedInstance()
Description copied from interface:MockCreationSettings
the spied instance - needed for spies.- Specified by:
getSpiedInstance
in interfaceMockCreationSettings<T>
-
getDefaultAnswer
public Answer<java.lang.Object> 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
public MockName 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
public CreationSettings<T> setMockName(MockName mockName)
-
isSerializable
public boolean isSerializable()
Description copied from interface:MockCreationSettings
if the mock is serializable, seeMockSettings.serializable()
.- Specified by:
isSerializable
in interfaceMockCreationSettings<T>
-
setSerializableMode
public CreationSettings<T> setSerializableMode(SerializableMode serializableMode)
-
getSerializableMode
public SerializableMode getSerializableMode()
- Specified by:
getSerializableMode
in interfaceMockCreationSettings<T>
- Returns:
- the serializable mode of this mock
-
getInvocationListeners
public java.util.List<InvocationListener> getInvocationListeners()
Description copied from interface:MockCreationSettings
InvocationListener
instances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...)
.- Specified by:
getInvocationListeners
in interfaceMockCreationSettings<T>
-
getVerificationStartedListeners
public java.util.List<VerificationStartedListener> getVerificationStartedListeners()
Description copied from interface:MockCreationSettings
VerificationStartedListener
instances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)
- Specified by:
getVerificationStartedListeners
in interfaceMockCreationSettings<T>
-
getStubbingLookupListeners
public java.util.List<StubbingLookupListener> 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
public java.lang.Object[] 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
public java.lang.Object 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()
Description copied from interface:MockCreationSettings
Informs if the mock was created with "lenient" strictness, e.g. havingStrictness.LENIENT
characteristic. For more information about using mocks with lenient strictness, seeMockSettings.lenient()
.- Specified by:
isLenient
in interfaceMockCreationSettings<T>
-
-