Interface DoNotMockEnforcer

All Superinterfaces:
DoNotMockEnforcerWithType

public interface DoNotMockEnforcer extends DoNotMockEnforcerWithType
Enforcer that is applied to every type in the type hierarchy of the class-to-be-mocked.
  • Method Details

    • checkTypeForDoNotMockViolation

      String checkTypeForDoNotMockViolation(Class<?> type)
      Check whether this type is allowed to be mocked. Return null 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

      default String checkTypeForDoNotMockViolation(MockCreationSettings<?> creationSettings)
      Check whether this type is allowed to be mocked. Return null 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 interface DoNotMockEnforcerWithType
      Parameters:
      creationSettings - The mock creation settings
      Returns:
      Optional message if this type can not be mocked, or null otherwise
      Since:
      5.9.0