Interface DoNotMockEnforcer

    • Method Detail

      • checkTypeForDoNotMockViolation

        java.lang.String checkTypeForDoNotMockViolation​(java.lang.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(MockCreationSettings)
      • checkTypeForDoNotMockViolation

        default java.lang.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
      • recursiveCheckDoNotMockAnnotationForType

        default java.lang.String recursiveCheckDoNotMockAnnotationForType​(java.lang.Class<?> type)