Package org.mockito.plugins
Interface DoNotMockEnforcer
- All Superinterfaces:
DoNotMockEnforcerWithType
Enforcer that is applied to every type in the type hierarchy of the class-to-be-mocked.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Static cache for types that are known to be mockable and thus may be skipped while traversing the class hierarchy. -
Method Summary
Modifier and TypeMethodDescriptioncheckTypeForDoNotMockViolation
(Class<?> type) Check whether this type is allowed to be mocked.default String
checkTypeForDoNotMockViolation
(MockCreationSettings<?> creationSettings) Check whether this type is allowed to be mocked.
-
Method Details
-
checkTypeForDoNotMockViolation
Check whether this type is allowed to be mocked. Returnnull
if the enforcer allows this type to be mocked. Return a message if there is a reason this type can not be mocked.Note that traversal of the type hierarchy is performed externally to this method. Implementations of it should therefore not perform type traversal themselves.
- Parameters:
type
- The type to check- Returns:
- Optional message if this type can not be mocked, or
null
otherwise - See Also:
-
checkTypeForDoNotMockViolation
Check whether this type is allowed to be mocked. Returnnull
if the enforcer allows this type to be mocked. Return a message if there is a reason this type can not be mocked.The default implementation traverses the class hierarchy of the type to be mocked and checks it against
checkTypeForDoNotMockViolation(Class)
. If any types fails the validation, the traversal is interrupted and the error message is returned.- Specified by:
checkTypeForDoNotMockViolation
in interfaceDoNotMockEnforcerWithType
- Parameters:
creationSettings
- The mock creation settings- Returns:
- Optional message if this type can not be mocked, or
null
otherwise - Since:
- 5.9.0
-