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[]constructorArgsprotected Answer<java.lang.Object>defaultAnswerprotected java.util.Set<java.lang.Class<?>>extraInterfacesprotected java.lang.reflect.TypegenericTypeToMockprotected java.util.List<InvocationListener>invocationListenersprotected java.lang.StringmockMakerprotected MockNamemockNameprotected MockTypemockTypeprotected java.lang.Stringnameprivate java.lang.ObjectouterClassInstanceprotected SerializableModeserializableModeprivate static longserialVersionUIDprotected java.lang.ObjectspiedInstanceprotected Strictnessstrictnessprotected booleanstripAnnotationsprotected java.util.List<StubbingLookupListener>stubbingLookupListenersprotected booleanstubOnlyprotected java.lang.Class<T>typeToMockprivate booleanuseConstructorprotected 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.lang.reflect.TypegetGenericTypeToMock()The generic type of the mock, if any.java.util.List<InvocationListener>getInvocationListeners()InvocationListenerinstances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...).java.lang.StringgetMockMaker()Returns theMockMakerwhich shall be used to create the mock.MockNamegetMockName()the name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String).MockTypegetMockType()Returns theMockTypefor the mock being created.java.lang.StringgetName()java.lang.ObjectgetOuterClassInstance()Used when mocking non-static inner classes in conjunction withMockCreationSettings.isUsingConstructor()SerializableModegetSerializableMode()java.lang.ObjectgetSpiedInstance()the spied instance - needed for spies.StrictnessgetStrictness()Sets strictness level for the mock, e.g.java.util.List<StubbingLookupListener>getStubbingLookupListeners()ReturnsStubbingLookupListenerinstances attached to this mock viaMockSettings.stubbingLookupListeners(StubbingLookupListener...).java.lang.Class<T>getTypeToMock()Mocked type.java.util.List<VerificationStartedListener>getVerificationStartedListeners()VerificationStartedListenerinstances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)booleanisLenient()booleanisSerializable()if the mock is serializable, seeMockSettings.serializable().booleanisStripAnnotations()Whether the mock should not make a best effort to preserve annotations.booleanisStubOnly()Whether the mock is only for stubbing, i.e.booleanisUsingConstructor()Informs whether the mock instance should be created via constructorCreationSettings<T>setExtraInterfaces(java.util.Set<java.lang.Class<?>> extraInterfaces)CreationSettings<T>setGenericTypeToMock(java.lang.reflect.Type genericTypeToMock)CreationSettings<T>setMockName(MockName mockName)voidsetMockType(MockType mockType)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
-
genericTypeToMock
protected transient java.lang.reflect.Type genericTypeToMock
-
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
-
strictness
protected Strictness strictness
-
mockMaker
protected java.lang.String mockMaker
-
mockType
protected MockType mockType
-
-
Constructor Detail
-
CreationSettings
public CreationSettings()
-
CreationSettings
public CreationSettings(CreationSettings copy)
-
-
Method Detail
-
getTypeToMock
public java.lang.Class<T> getTypeToMock()
Description copied from interface:MockCreationSettingsMocked type. An interface or class the mock should implement / extend.- Specified by:
getTypeToMockin interfaceMockCreationSettings<T>
-
setTypeToMock
public CreationSettings<T> setTypeToMock(java.lang.Class<T> typeToMock)
-
setGenericTypeToMock
public CreationSettings<T> setGenericTypeToMock(java.lang.reflect.Type genericTypeToMock)
-
getExtraInterfaces
public java.util.Set<java.lang.Class<?>> getExtraInterfaces()
Description copied from interface:MockCreationSettingsthe extra interfaces the mock object should implement.- Specified by:
getExtraInterfacesin 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:MockCreationSettingsthe spied instance - needed for spies.- Specified by:
getSpiedInstancein interfaceMockCreationSettings<T>
-
getDefaultAnswer
public Answer<java.lang.Object> getDefaultAnswer()
Description copied from interface:MockCreationSettingsthe default answer for this mock, seeMockSettings.defaultAnswer(org.mockito.stubbing.Answer).- Specified by:
getDefaultAnswerin interfaceMockCreationSettings<T>
-
getMockName
public MockName getMockName()
Description copied from interface:MockCreationSettingsthe name of this mock, as printed on verification errors; seeMockSettings.name(java.lang.String).- Specified by:
getMockNamein interfaceMockCreationSettings<T>
-
setMockName
public CreationSettings<T> setMockName(MockName mockName)
-
isSerializable
public boolean isSerializable()
Description copied from interface:MockCreationSettingsif the mock is serializable, seeMockSettings.serializable().- Specified by:
isSerializablein interfaceMockCreationSettings<T>
-
setSerializableMode
public CreationSettings<T> setSerializableMode(SerializableMode serializableMode)
-
getSerializableMode
public SerializableMode getSerializableMode()
- Specified by:
getSerializableModein interfaceMockCreationSettings<T>- Returns:
- the serializable mode of this mock
-
getInvocationListeners
public java.util.List<InvocationListener> getInvocationListeners()
Description copied from interface:MockCreationSettingsInvocationListenerinstances attached to this mock, seeMockSettings.invocationListeners(InvocationListener...).- Specified by:
getInvocationListenersin interfaceMockCreationSettings<T>
-
getVerificationStartedListeners
public java.util.List<VerificationStartedListener> getVerificationStartedListeners()
Description copied from interface:MockCreationSettingsVerificationStartedListenerinstances attached to this mock, seeMockSettings.verificationStartedListeners(VerificationStartedListener...)- Specified by:
getVerificationStartedListenersin interfaceMockCreationSettings<T>
-
getStubbingLookupListeners
public java.util.List<StubbingLookupListener> getStubbingLookupListeners()
Description copied from interface:MockCreationSettingsReturnsStubbingLookupListenerinstances 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:
getStubbingLookupListenersin interfaceMockCreationSettings<T>
-
isUsingConstructor
public boolean isUsingConstructor()
Description copied from interface:MockCreationSettingsInforms whether the mock instance should be created via constructor- Specified by:
isUsingConstructorin interfaceMockCreationSettings<T>
-
isStripAnnotations
public boolean isStripAnnotations()
Description copied from interface:MockCreationSettingsWhether the mock should not make a best effort to preserve annotations.- Specified by:
isStripAnnotationsin interfaceMockCreationSettings<T>
-
getConstructorArgs
public java.lang.Object[] getConstructorArgs()
Description copied from interface:MockCreationSettingsUsed 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:
getConstructorArgsin 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:MockCreationSettingsUsed when mocking non-static inner classes in conjunction withMockCreationSettings.isUsingConstructor()- Specified by:
getOuterClassInstancein 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:MockCreationSettingsWhether the mock is only for stubbing, i.e. does not remember parameters on its invocation and therefore cannot be used for verification- Specified by:
isStubOnlyin interfaceMockCreationSettings<T>
-
isLenient
public boolean isLenient()
- Specified by:
isLenientin interfaceMockCreationSettings<T>
-
getStrictness
public Strictness getStrictness()
Description copied from interface:MockCreationSettingsSets strictness level for the mock, e.g. havingStrictness.STRICT_STUBScharacteristic. For more information about using mocks with custom strictness, seeMockSettings.strictness(Strictness).- Specified by:
getStrictnessin interfaceMockCreationSettings<T>
-
getMockMaker
public java.lang.String getMockMaker()
Description copied from interface:MockCreationSettingsReturns theMockMakerwhich shall be used to create the mock. When the return value isnull, the default shall be used.- Specified by:
getMockMakerin interfaceMockCreationSettings<T>- See Also:
MockSettings.mockMaker(String)
-
getGenericTypeToMock
public java.lang.reflect.Type getGenericTypeToMock()
Description copied from interface:MockCreationSettingsThe generic type of the mock, if any.- Specified by:
getGenericTypeToMockin interfaceMockCreationSettings<T>
-
getMockType
public MockType getMockType()
Description copied from interface:MockCreationSettingsReturns theMockTypefor the mock being created.- Specified by:
getMockTypein interfaceMockCreationSettings<T>- See Also:
MockType
-
setMockType
public void setMockType(MockType mockType)
-
-