Class AbstractMockChecker<T extends Annotation>

    • Field Detail

      • MOCKING_METHOD

        public static final AbstractMockChecker.TypeExtractor<com.sun.source.tree.MethodInvocationTree> MOCKING_METHOD
        A TypeExtractor for method invocations that create a mock using Mockito.mock, Mockito.spy, or EasyMock.create[...]Mock, extracting the type being mocked.
    • Method Detail

      • forbidder

        protected AbstractMockChecker.MockForbidder forbidder()
        Produce a MockForbidder to use when looking for disallowed mocks, in addition to the built-in checks for Annotations of type T.

        This method will be called at most once for each instance of AbstractMockChecker, but of course the returned object's forbidReason method may be called many times.

        The default implementation forbids nothing.

      • extractFirstArg

        public static AbstractMockChecker.TypeExtractor<com.sun.source.tree.MethodInvocationTree> extractFirstArg​(Matcher<com.sun.source.tree.MethodInvocationTree> m)
        Produces an extractor which, if the tree matches, extracts the type of the first argument to the method invocation.
      • extractClassArg

        public static AbstractMockChecker.TypeExtractor<com.sun.source.tree.MethodInvocationTree> extractClassArg​(Matcher<com.sun.source.tree.MethodInvocationTree> m)
        Produces an extractor which, if the tree matches, extracts the type of the first argument whose type is Class (preserving its <T> type parameter, if it has one}.
        Parameters:
        m - the matcher to use. It is an error for this matcher to succeed on any Tree that does not include at least one argument of type Class; if such a matcher is provided, the behavior of the returned Extractor is undefined.
      • fieldAnnotatedWithOneOf

        public static AbstractMockChecker.TypeExtractor<com.sun.source.tree.VariableTree> fieldAnnotatedWithOneOf​(Stream<String> annotationClasses)
        Creates a TypeExtractor that extracts the type of a class field if that field is annotated with any one of the given annotations.