Package org.mockito.plugins
Interface DoNotMockEnforcer
-
- All Superinterfaces:
DoNotMockEnforcerWithType
- All Known Implementing Classes:
DefaultDoNotMockEnforcer
public interface DoNotMockEnforcer extends DoNotMockEnforcerWithType
Enforcer that is applied to every type in the type hierarchy of the class-to-be-mocked.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DoNotMockEnforcer.Cache
Static cache for types that are known to be mockable and thus may be skipped while traversing the class hierarchy.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
checkTypeForDoNotMockViolation(java.lang.Class<?> type)
Check whether this type is allowed to be mocked.default java.lang.String
checkTypeForDoNotMockViolation(MockCreationSettings<?> creationSettings)
Check whether this type is allowed to be mocked.default java.lang.String
recursiveCheckDoNotMockAnnotationForType(java.lang.Class<?> type)
-
-
-
Method Detail
-
checkTypeForDoNotMockViolation
java.lang.String checkTypeForDoNotMockViolation(java.lang.Class<?> type)
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(MockCreationSettings)
-
checkTypeForDoNotMockViolation
default java.lang.String checkTypeForDoNotMockViolation(MockCreationSettings<?> creationSettings)
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
-
recursiveCheckDoNotMockAnnotationForType
default java.lang.String recursiveCheckDoNotMockAnnotationForType(java.lang.Class<?> type)
-
-