mockito / mockito
Showing 17 of 109 files from the diff.
Other files ignored by Codecov

@@ -36,11 +36,6 @@
Loading
36 36
        return wanted;
37 37
    }
38 38
39 -
    @Override
40 -
    public InvocationMatcher getWanted() {
41 -
        return wanted;
42 -
    }
43 -
44 39
    private void assertWantedIsVerifiable() {
45 40
        if (wanted == null) {
46 41
            return;

@@ -21,8 +21,7 @@
Loading
21 21
/**
22 22
 * See {@link MockitoAnnotations}
23 23
 */
24 -
public class InjectingAnnotationEngine
25 -
        implements AnnotationEngine, org.mockito.configuration.AnnotationEngine {
24 +
public class InjectingAnnotationEngine implements AnnotationEngine {
26 25
    private final AnnotationEngine delegate = new IndependentAnnotationEngine();
27 26
    private final AnnotationEngine spyAnnotationEngine = new SpyAnnotationEngine();
28 27

@@ -85,15 +85,6 @@
Loading
85 85
        this.implementation = implementation;
86 86
    }
87 87
88 -
    /**
89 -
     * @deprecated as of 2.1.0 Use the enum-constant directly, instead of this getter. This method will be removed in a future release<br>
90 -
     * E.g. instead of <code>Answers.CALLS_REAL_METHODS.get()</code> use <code>Answers.CALLS_REAL_METHODS</code> .
91 -
     */
92 -
    @Deprecated
93 -
    public Answer<Object> get() {
94 -
        return this;
95 -
    }
96 -
97 88
    @Override
98 89
    public Object answer(InvocationOnMock invocation) throws Throwable {
99 90
        return implementation.answer(invocation);

@@ -6,10 +6,8 @@
Loading
6 6
7 7
import org.mockito.exceptions.misusing.PotentialStubbingProblem;
8 8
import org.mockito.exceptions.misusing.UnnecessaryStubbingException;
9 -
import org.mockito.internal.InternalMockHandler;
10 9
import org.mockito.internal.MockitoCore;
11 10
import org.mockito.internal.creation.MockSettingsImpl;
12 -
import org.mockito.internal.debugging.MockitoDebuggerImpl;
13 11
import org.mockito.internal.framework.DefaultMockitoFramework;
14 12
import org.mockito.internal.session.DefaultMockitoSessionBuilder;
15 13
import org.mockito.internal.verification.VerificationModeFactory;
@@ -29,9 +27,11 @@
Loading
29 27
import org.mockito.session.MockitoSessionBuilder;
30 28
import org.mockito.session.MockitoSessionLogger;
31 29
import org.mockito.stubbing.Answer;
30 +
import org.mockito.stubbing.Answer1;
32 31
import org.mockito.stubbing.LenientStubber;
33 32
import org.mockito.stubbing.OngoingStubbing;
34 33
import org.mockito.stubbing.Stubber;
34 +
import org.mockito.stubbing.VoidAnswer1;
35 35
import org.mockito.verification.*;
36 36
37 37
import java.util.function.Function;
@@ -284,10 +284,10 @@
Loading
284 284
 * </code></pre>
285 285
 *
286 286
 * <p>
287 -
 * Matcher methods like <code>anyObject()</code>, <code>eq()</code> <b>do not</b> return matchers.
287 +
 * Matcher methods like <code>any()</code>, <code>eq()</code> <b>do not</b> return matchers.
288 288
 * Internally, they record a matcher on a stack and return a dummy value (usually null).
289 289
 * This implementation is due to static type safety imposed by the java compiler.
290 -
 * The consequence is that you cannot use <code>anyObject()</code>, <code>eq()</code> methods outside of verified/stubbed method.
290 +
 * The consequence is that you cannot use <code>any()</code>, <code>eq()</code> methods outside of verified/stubbed method.
291 291
 *
292 292
 *
293 293
 *
@@ -401,9 +401,6 @@
Loading
401 401
 * //verify that method was never called on a mock
402 402
 * verify(mockOne, never()).add("two");
403 403
 *
404 -
 * //verify that other mocks were not interacted
405 -
 * verifyZeroInteractions(mockTwo, mockThree);
406 -
 *
407 404
 * </code></pre>
408 405
 *
409 406
 *
@@ -1242,7 +1239,7 @@
Loading
1242 1239
 * as Java 8 lambdas. Even in Java 7 and lower these custom answers based on a typed interface can reduce boilerplate.
1243 1240
 * In particular, this approach will make it easier to test functions which use callbacks.
1244 1241
 *
1245 -
 * The methods {@link AdditionalAnswers#answer(Answer1) answer} and {@link AdditionalAnswers#answerVoid(VoidAnswer1) answerVoid}
1242 +
 * The methods {@link AdditionalAnswers#answer(Answer1)}} and {@link AdditionalAnswers#answerVoid(VoidAnswer1)}
1246 1243
 * can be used to create the answer. They rely on the related answer interfaces in {@link org.mockito.stubbing} that
1247 1244
 * support answers up to 5 parameters.
1248 1245
 *
@@ -1436,16 +1433,11 @@
Loading
1436 1433
 *      Provides access to invocation container object which has no methods (marker interface).
1437 1434
 *      Container is needed to hide the internal implementation and avoid leaking it to the public API.
1438 1435
 *     </li>
1439 -
 *     <li>Changed {@link Stubbing} -
1436 +
 *     <li>Changed {@link org.mockito.stubbing.Stubbing} -
1440 1437
 *      it now extends {@link Answer} interface.
1441 1438
 *      It is backwards compatible because Stubbing interface is not extensible (see {@link NotExtensible}).
1442 1439
 *      The change should be seamless to our users.
1443 1440
 *     </li>
1444 -
 *     <li>Deprecated {@link InternalMockHandler} -
1445 -
 *       In order to accommodate API changes we needed to deprecate this interface.
1446 -
 *       The interface was always documented as internal, we don't have evidence it was used by the community.
1447 -
 *       The deprecation should be completely seamless for our users.
1448 -
 *     </li>
1449 1441
 *     <li>{@link NotExtensible} -
1450 1442
 *       Public annotation that indicates to the user that she should not provide custom implementations of given type.
1451 1443
 *       Helps framework integrators and our users understand how to use Mockito API safely.
@@ -1505,9 +1497,9 @@
Loading
1505 1497
 *       Deprecated <code>org.mockito.plugins.InstantiatorProvider</code> as it was leaking internal API. it was
1506 1498
 *       replaced by <code>org.mockito.plugins.InstantiatorProvider2 (Since 2.15.4)</code></a></h3>
1507 1499
 *
1508 -
 * <p>{@link org.mockito.plugins.InstantiatorProvider} returned an internal API. Hence it was deprecated and replaced
1509 -
 * by {@link org.mockito.plugins.InstantiatorProvider2}. Old {@link org.mockito.plugins.InstantiatorProvider
1510 -
 * instantiator providers} will continue to work, but it is recommended to switch to the new API.</p>
1500 +
 * <p>org.mockito.plugins.InstantiatorProvider returned an internal API. Hence it was deprecated and replaced
1501 +
 * by {@link org.mockito.plugins.InstantiatorProvider2}. org.mockito.plugins.InstantiatorProvider
1502 +
 * has now been removed.</p>
1511 1503
 *
1512 1504
 * <h3 id="45">45. <a class="meaningful_link" href="#junit5_mockito" name="junit5_mockito">New JUnit Jupiter (JUnit5+) extension</a></h3>
1513 1505
 *
@@ -2531,18 +2523,6 @@
Loading
2531 2523
        MOCKITO_CORE.verifyNoMoreInteractions(mocks);
2532 2524
    }
2533 2525
2534 -
    /**
2535 -
     * Verifies that no interactions happened on given mocks beyond the previously verified interactions.<br/>
2536 -
     * This method has the same behavior as {@link #verifyNoMoreInteractions(Object...)}.
2537 -
     *
2538 -
     * @param mocks to be verified
2539 -
     * @deprecated Since 3.0.1. Please migrate your code to {@link #verifyNoInteractions(Object...)}
2540 -
     */
2541 -
    @Deprecated
2542 -
    public static void verifyZeroInteractions(Object... mocks) {
2543 -
        MOCKITO_CORE.verifyNoMoreInteractions(mocks);
2544 -
    }
2545 -
2546 2526
    /**
2547 2527
     * Verifies that no interactions happened on given mocks.
2548 2528
     * <pre class="code"><code class="java">
@@ -2980,8 +2960,7 @@
Loading
2980 2960
     *
2981 2961
     * <p>
2982 2962
     * If you want to verify there were NO interactions with the mock
2983 -
     * check out {@link Mockito#verifyZeroInteractions(Object...)}
2984 -
     * or {@link Mockito#verifyNoMoreInteractions(Object...)}
2963 +
     * check out {@link Mockito#verifyNoMoreInteractions(Object...)}
2985 2964
     * <p>
2986 2965
     * See examples in javadoc for {@link Mockito} class
2987 2966
     *
@@ -3273,15 +3252,6 @@
Loading
3273 3252
        return times(1).description(description);
3274 3253
    }
3275 3254
3276 -
    /**
3277 -
     * @deprecated - please use {@link MockingDetails#printInvocations()} instead.
3278 -
     * An instance of {@code MockingDetails} can be retrieved via {@link #mockingDetails(Object)}.
3279 -
     */
3280 -
    @Deprecated
3281 -
    static MockitoDebugger debug() {
3282 -
        return new MockitoDebuggerImpl();
3283 -
    }
3284 -
3285 3255
    /**
3286 3256
     * For advanced users or framework integrators. See {@link MockitoFramework} class.
3287 3257
     *

@@ -6,9 +6,7 @@
Loading
6 6
7 7
import java.util.HashMap;
8 8
import java.util.Map;
9 -
import org.mockito.internal.creation.instance.InstantiatorProvider2Adapter;
10 9
import org.mockito.plugins.AnnotationEngine;
11 -
import org.mockito.plugins.InstantiatorProvider;
12 10
import org.mockito.plugins.InstantiatorProvider2;
13 11
import org.mockito.plugins.MemberAccessor;
14 12
import org.mockito.plugins.MockMaker;
@@ -53,18 +51,8 @@
Loading
53 51
54 52
    @Override
55 53
    public <T> T getDefaultPlugin(Class<T> pluginType) {
56 -
        if (pluginType == InstantiatorProvider.class) {
57 -
            // the implementation class is not configured via map so that we can reduce duplication
58 -
            // (ensure that we are adapting the currently configured default implementation for
59 -
            // InstantiatorProvider2)
60 -
            String className = DEFAULT_PLUGINS.get(InstantiatorProvider2.class.getName());
61 -
            return pluginType.cast(
62 -
                    new InstantiatorProvider2Adapter(
63 -
                            create(InstantiatorProvider2.class, className)));
64 -
        } else {
65 -
            String className = DEFAULT_PLUGINS.get(pluginType.getName());
66 -
            return create(pluginType, className);
67 -
        }
54 +
        String className = DEFAULT_PLUGINS.get(pluginType.getName());
55 +
        return create(pluginType, className);
68 56
    }
69 57
70 58
    String getDefaultPluginClass(String classOrAlias) {

@@ -31,8 +31,7 @@
Loading
31 31
 * @see MockitoAnnotations
32 32
 */
33 33
@SuppressWarnings("unchecked")
34 -
public class IndependentAnnotationEngine
35 -
        implements AnnotationEngine, org.mockito.configuration.AnnotationEngine {
34 +
public class IndependentAnnotationEngine implements AnnotationEngine {
36 35
    private final Map<Class<? extends Annotation>, FieldAnnotationProcessor<?>>
37 36
            annotationProcessorMap = new HashMap<>();
38 37

@@ -243,11 +243,11 @@
Loading
243 243
                        "",
244 244
                        "This exception may occur if matchers are combined with raw values:",
245 245
                        "    //incorrect:",
246 -
                        "    someMethod(anyObject(), \"raw String\");",
246 +
                        "    someMethod(any(), \"raw String\");",
247 247
                        "When using matchers, all arguments have to be provided by matchers.",
248 248
                        "For example:",
249 249
                        "    //correct:",
250 -
                        "    someMethod(anyObject(), eq(\"String by matcher\"));",
250 +
                        "    someMethod(any(), eq(\"String by matcher\"));",
251 251
                        "",
252 252
                        "For more info see javadoc for Matchers class.",
253 253
                        ""));
@@ -626,7 +626,7 @@
Loading
626 626
                        "You cannot use argument matchers outside of verification or stubbing.",
627 627
                        "Examples of correct usage of argument matchers:",
628 628
                        "    when(mock.get(anyInt())).thenReturn(null);",
629 -
                        "    doThrow(new RuntimeException()).when(mock).someVoidMethod(anyObject());",
629 +
                        "    doThrow(new RuntimeException()).when(mock).someVoidMethod(any());",
630 630
                        "    verify(mock).someMethod(contains(\"foo\"))",
631 631
                        "",
632 632
                        "This message may appear after an NullPointerException if the last matcher is returning an object ",

@@ -16,11 +16,11 @@
Loading
16 16
import org.mockito.internal.matchers.LessThan;
17 17
18 18
/**
19 -
 * See {@link Matchers} for general info about matchers.
19 +
 * See {@link ArgumentMatchers} for general info about matchers.
20 20
 * <p>
21 21
 * AdditionalMatchers provides rarely used matchers, kept only for somewhat compatibility with EasyMock.
22 22
 * Use additional matchers very judiciously because they may impact readability of a test.
23 -
 * It is recommended to use matchers from {@link Matchers} and keep stubbing and verification simple.
23 +
 * It is recommended to use matchers from {@link ArgumentMatchers} and keep stubbing and verification simple.
24 24
 * <p>
25 25
 * Example of using logical and(), not(), or() matchers:
26 26
 *

@@ -46,8 +46,7 @@
Loading
46 46
 * <p>This engine will fail, if the field is also annotated with incompatible Mockito annotations.
47 47
 */
48 48
@SuppressWarnings({"unchecked"})
49 -
public class SpyAnnotationEngine
50 -
        implements AnnotationEngine, org.mockito.configuration.AnnotationEngine {
49 +
public class SpyAnnotationEngine implements AnnotationEngine {
51 50
52 51
    @Override
53 52
    public AutoCloseable process(Class<?> context, Object testInstance) {

@@ -5,9 +5,7 @@
Loading
5 5
package org.mockito.internal.configuration.plugins;
6 6
7 7
import java.util.List;
8 -
import org.mockito.internal.creation.instance.InstantiatorProviderAdapter;
9 8
import org.mockito.plugins.AnnotationEngine;
10 -
import org.mockito.plugins.InstantiatorProvider;
11 9
import org.mockito.plugins.InstantiatorProvider2;
12 10
import org.mockito.plugins.MemberAccessor;
13 11
import org.mockito.plugins.MockMaker;
@@ -47,14 +45,8 @@
Loading
47 45
            new PluginLoader(pluginSwitch).loadPlugins(MockResolver.class);
48 46
49 47
    PluginRegistry() {
50 -
        Object impl =
51 -
                new PluginLoader(pluginSwitch)
52 -
                        .loadPlugin(InstantiatorProvider2.class, InstantiatorProvider.class);
53 -
        if (impl instanceof InstantiatorProvider) {
54 -
            instantiatorProvider = new InstantiatorProviderAdapter((InstantiatorProvider) impl);
55 -
        } else {
56 -
            instantiatorProvider = (InstantiatorProvider2) impl;
57 -
        }
48 +
        instantiatorProvider =
49 +
                new PluginLoader(pluginSwitch).loadPlugin(InstantiatorProvider2.class);
58 50
    }
59 51
60 52
    /**

@@ -254,14 +254,6 @@
Loading
254 254
         */
255 255
        T should(InOrder inOrder, VerificationMode mode);
256 256
257 -
        /**
258 -
         * @see #verifyZeroInteractions(Object...)
259 -
         * @since 2.1.0
260 -
         * @deprecated Since 3.0.1. Please migrate your code to {@link #shouldHaveNoInteractions()}
261 -
         */
262 -
        @Deprecated
263 -
        void shouldHaveZeroInteractions();
264 -
265 257
        /**
266 258
         * @see #verifyNoMoreInteractions(Object...)
267 259
         * @since 2.1.0
@@ -315,14 +307,6 @@
Loading
315 307
            return inOrder.verify(mock, mode);
316 308
        }
317 309
318 -
        /**
319 -
         * @see #verifyZeroInteractions(Object...)
320 -
         * @since 2.1.0
321 -
         */
322 -
        public void shouldHaveZeroInteractions() {
323 -
            verifyZeroInteractions(mock);
324 -
        }
325 -
326 310
        /**
327 311
         * @see #verifyNoMoreInteractions(Object...)
328 312
         * @since 2.1.0
@@ -357,17 +341,6 @@
Loading
357 341
         */
358 342
        BDDStubber will(Answer<?> answer);
359 343
360 -
        /**
361 -
         * See original {@link Stubber#doNothing()}.
362 -
         *
363 -
         * This method will be removed in version 4.0.0
364 -
         *
365 -
         * @since 1.8.0
366 -
         * @deprecated as of 2.1.0 please use {@link #willDoNothing()} instead
367 -
         */
368 -
        @Deprecated
369 -
        BDDStubber willNothing();
370 -
371 344
        /**
372 345
         * See original {@link Stubber#doNothing()}
373 346
         * @since 1.10.20
@@ -441,14 +414,6 @@
Loading
441 414
            return new BDDStubberImpl(mockitoStubber.doAnswer(answer));
442 415
        }
443 416
444 -
        /**
445 -
         * @deprecated please use {@link #willDoNothing()} instead
446 -
         */
447 -
        @Deprecated
448 -
        public BDDStubber willNothing() {
449 -
            return willDoNothing();
450 -
        }
451 -
452 417
        public BDDStubber willDoNothing() {
453 418
            return new BDDStubberImpl(mockitoStubber.doNothing());
454 419
        }

@@ -4,10 +4,12 @@
Loading
4 4
 */
5 5
package org.mockito.exceptions.verification;
6 6
7 +
import org.mockito.exceptions.base.MockitoAssertionError;
8 +
7 9
/**
8 10
 * @since 2.27.5
9 11
 */
10 -
public class TooFewActualInvocations extends TooLittleActualInvocations {
12 +
public class TooFewActualInvocations extends MockitoAssertionError {
11 13
12 14
    private static final long serialVersionUID = 1L;
13 15

@@ -4,7 +4,6 @@
Loading
4 4
 */
5 5
package org.mockito.configuration;
6 6
7 -
import org.mockito.internal.configuration.InjectingAnnotationEngine;
8 7
import org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValues;
9 8
import org.mockito.stubbing.Answer;
10 9
@@ -22,13 +21,6 @@
Loading
22 21
        return new ReturnsEmptyValues();
23 22
    }
24 23
25 -
    /* (non-Javadoc)
26 -
     * @see org.mockito.IMockitoConfiguration#getAnnotationEngine()
27 -
     */
28 -
    public AnnotationEngine getAnnotationEngine() {
29 -
        return new InjectingAnnotationEngine();
30 -
    }
31 -
32 24
    /* (non-Javadoc)
33 25
     * @see org.mockito.configuration.IMockitoConfiguration#cleansStackTrace()
34 26
     */

@@ -38,14 +38,6 @@
Loading
38 38
        verify(verification, times(1));
39 39
    }
40 40
41 -
    /**
42 -
     * See {@link Mockito#verify(Object, VerificationMode)}.
43 -
     *
44 -
     * @deprecated Please use {@link MockedStatic#verify(Verification, VerificationMode) instead
45 -
     */
46 -
    @Deprecated
47 -
    void verify(VerificationMode mode, Verification verification);
48 -
49 41
    /**
50 42
     * See {@link Mockito#verify(Object, VerificationMode)}.
51 43
     */

@@ -90,10 +90,10 @@
Loading
90 90
 * </code></pre>
91 91
 *
92 92
 * <p>
93 -
 * Matcher methods like <code>anyObject()</code>, <code>eq()</code> <b>do not</b> return matchers.
93 +
 * Matcher methods like <code>any()</code>, <code>eq()</code> <b>do not</b> return matchers.
94 94
 * Internally, they record a matcher on a stack and return a dummy value (usually null).
95 95
 * This implementation is due to static type safety imposed by java compiler.
96 -
 * The consequence is that you cannot use <code>anyObject()</code>, <code>eq()</code> methods outside of verified/stubbed method.
96 +
 * The consequence is that you cannot use <code>any()</code>, <code>eq()</code> methods outside of verified/stubbed method.
97 97
 * </p>
98 98
 *
99 99
 * <h1>Additional matchers</h1>
@@ -121,8 +121,6 @@
Loading
121 121
     *
122 122
     * <p>
123 123
     * See examples in javadoc for {@link ArgumentMatchers} class
124 -
     *
125 -
     * This is an alias of: {@link #anyObject()}
126 124
     * </p>
127 125
     *
128 126
     * <p>
@@ -136,35 +134,11 @@
Loading
136 134
     * @return <code>null</code>.
137 135
     *
138 136
     * @see #any(Class)
139 -
     * @see #anyObject()
140 -
     * @see #anyVararg()
141 137
     * @see #anyChar()
142 138
     * @see #anyInt()
143 139
     * @see #anyBoolean()
144 -
     * @see #anyCollectionOf(Class)
145 140
     */
146 141
    public static <T> T any() {
147 -
        return anyObject();
148 -
    }
149 -
150 -
    /**
151 -
     * Matches anything, including <code>null</code>.
152 -
     *
153 -
     * <p>
154 -
     * This is an alias of: {@link #any()}.
155 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
156 -
     * </p>
157 -
     *
158 -
     * @return <code>null</code>.
159 -
     * @see #any()
160 -
     * @see #any(Class)
161 -
     * @see #notNull()
162 -
     * @see #notNull(Class)
163 -
     * @deprecated This will be removed in Mockito 4.0 This method is only used for generic
164 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
165 -
     */
166 -
    @Deprecated
167 -
    public static <T> T anyObject() {
168 142
        reportMatcher(Any.ANY);
169 143
        return null;
170 144
    }
@@ -190,7 +164,7 @@
Loading
190 164
     * <ul>
191 165
     *     <li>For primitive types use {@link #anyChar()} family.</li>
192 166
     *     <li>Since Mockito 2.1.0 this method will perform a type check thus <code>null</code> values are not authorized.</li>
193 -
     *     <li>Since mockito 2.1.0 {@link #any()} and {@link #anyObject()} are not anymore aliases of this method.</li>
167 +
     *     <li>Since mockito 2.1.0 {@link #any()} is no longer an alias of this method.</li>
194 168
     * </ul>
195 169
     * </p>
196 170
     *
@@ -198,13 +172,9 @@
Loading
198 172
     * @param type the class of the accepted type.
199 173
     * @return <code>null</code>.
200 174
     * @see #any()
201 -
     * @see #anyObject()
202 -
     * @see #anyVararg()
203 175
     * @see #isA(Class)
204 176
     * @see #notNull()
205 -
     * @see #notNull(Class)
206 177
     * @see #isNull()
207 -
     * @see #isNull(Class)
208 178
     */
209 179
    public static <T> T any(Class<T> type) {
210 180
        reportMatcher(new InstanceOf.VarArgAware(type, "<any " + type.getCanonicalName() + ">"));
@@ -226,43 +196,6 @@
Loading
226 196
        return defaultValue(type);
227 197
    }
228 198
229 -
    /**
230 -
     * Any vararg, meaning any number and values of arguments.
231 -
     *
232 -
     * <p>
233 -
     * Example:
234 -
     * <pre class="code"><code class="java">
235 -
     * //verification:
236 -
     * mock.foo(1, 2);
237 -
     * mock.foo(1, 2, 3, 4);
238 -
     *
239 -
     * verify(mock, times(2)).foo(anyVararg());
240 -
     *
241 -
     * //stubbing:
242 -
     * when(mock.foo(anyVararg()).thenReturn(100);
243 -
     *
244 -
     * //prints 100
245 -
     * System.out.println(mock.foo(1, 2));
246 -
     * //also prints 100
247 -
     * System.out.println(mock.foo(1, 2, 3, 4));
248 -
     * </code></pre>
249 -
     * </p>
250 -
     *
251 -
     * <p>
252 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
253 -
     * </p>
254 -
     *
255 -
     * @return <code>null</code>.
256 -
     * @see #any()
257 -
     * @see #any(Class)
258 -
     * @deprecated as of 2.1.0 use {@link #any()}
259 -
     */
260 -
    @Deprecated
261 -
    public static <T> T anyVararg() {
262 -
        Object ignored = any();
263 -
        return null;
264 -
    }
265 -
266 199
    /**
267 200
     * Any <code>boolean</code> or <strong>non-null</strong> <code>Boolean</code>
268 201
     *
@@ -279,7 +212,6 @@
Loading
279 212
     *
280 213
     * @return <code>false</code>.
281 214
     * @see #isNull()
282 -
     * @see #isNull(Class)
283 215
     */
284 216
    public static boolean anyBoolean() {
285 217
        reportMatcher(new InstanceOf(Boolean.class, "<any boolean>"));
@@ -302,7 +234,6 @@
Loading
302 234
     *
303 235
     * @return <code>0</code>.
304 236
     * @see #isNull()
305 -
     * @see #isNull(Class)
306 237
     */
307 238
    public static byte anyByte() {
308 239
        reportMatcher(new InstanceOf(Byte.class, "<any byte>"));
@@ -325,7 +256,6 @@
Loading
325 256
     *
326 257
     * @return <code>0</code>.
327 258
     * @see #isNull()
328 -
     * @see #isNull(Class)
329 259
     */
330 260
    public static char anyChar() {
331 261
        reportMatcher(new InstanceOf(Character.class, "<any char>"));
@@ -348,7 +278,6 @@
Loading
348 278
     *
349 279
     * @return <code>0</code>.
350 280
     * @see #isNull()
351 -
     * @see #isNull(Class)
352 281
     */
353 282
    public static int anyInt() {
354 283
        reportMatcher(new InstanceOf(Integer.class, "<any integer>"));
@@ -371,7 +300,6 @@
Loading
371 300
     *
372 301
     * @return <code>0</code>.
373 302
     * @see #isNull()
374 -
     * @see #isNull(Class)
375 303
     */
376 304
    public static long anyLong() {
377 305
        reportMatcher(new InstanceOf(Long.class, "<any long>"));
@@ -394,7 +322,6 @@
Loading
394 322
     *
395 323
     * @return <code>0</code>.
396 324
     * @see #isNull()
397 -
     * @see #isNull(Class)
398 325
     */
399 326
    public static float anyFloat() {
400 327
        reportMatcher(new InstanceOf(Float.class, "<any float>"));
@@ -417,7 +344,6 @@
Loading
417 344
     *
418 345
     * @return <code>0</code>.
419 346
     * @see #isNull()
420 -
     * @see #isNull(Class)
421 347
     */
422 348
    public static double anyDouble() {
423 349
        reportMatcher(new InstanceOf(Double.class, "<any double>"));
@@ -440,7 +366,6 @@
Loading
440 366
     *
441 367
     * @return <code>0</code>.
442 368
     * @see #isNull()
443 -
     * @see #isNull(Class)
444 369
     */
445 370
    public static short anyShort() {
446 371
        reportMatcher(new InstanceOf(Short.class, "<any short>"));
@@ -463,7 +388,6 @@
Loading
463 388
     *
464 389
     * @return empty String ("")
465 390
     * @see #isNull()
466 -
     * @see #isNull(Class)
467 391
     */
468 392
    public static String anyString() {
469 393
        reportMatcher(new InstanceOf(String.class, "<any string>"));
@@ -485,50 +409,13 @@
Loading
485 409
     * </p>
486 410
     *
487 411
     * @return empty List.
488 -
     * @see #anyListOf(Class)
489 412
     * @see #isNull()
490 -
     * @see #isNull(Class)
491 413
     */
492 414
    public static <T> List<T> anyList() {
493 415
        reportMatcher(new InstanceOf(List.class, "<any List>"));
494 416
        return new ArrayList<T>(0);
495 417
    }
496 418
497 -
    /**
498 -
     * Any <strong>non-null</strong> <code>List</code>.
499 -
     *
500 -
     * Generic friendly alias to {@link ArgumentMatchers#anyList()}. It's an alternative to
501 -
     * <code>&#064;SuppressWarnings("unchecked")</code> to keep code clean of compiler warnings.
502 -
     *
503 -
     * <p>
504 -
     * This method doesn't do type checks of the list content with the given type parameter, it is only there
505 -
     * to avoid casting in the code.
506 -
     * </p>
507 -
     *
508 -
     * <p>
509 -
     * Since Mockito 2.1.0, only allow non-null <code>List</code>.
510 -
     * As this is a nullable reference, the suggested API to <strong>match</strong> <code>null</code> wrapper
511 -
     * would be {@link #isNull()}. We felt this change would make test harnesses much safer than they were with Mockito
512 -
     * 1.x.
513 -
     * </p>
514 -
     *
515 -
     * <p>
516 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
517 -
     * </p>
518 -
     *
519 -
     * @param clazz Type owned by the list to avoid casting
520 -
     * @return empty List.
521 -
     * @see #anyList()
522 -
     * @see #isNull()
523 -
     * @see #isNull(Class)
524 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
525 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
526 -
     */
527 -
    @Deprecated
528 -
    public static <T> List<T> anyListOf(Class<T> clazz) {
529 -
        return anyList();
530 -
    }
531 -
532 419
    /**
533 420
     * Any <strong>non-null</strong> <code>Set</code>.
534 421
     *
@@ -544,52 +431,13 @@
Loading
544 431
     * </p>
545 432
     *
546 433
     * @return empty Set
547 -
     * @see #anySetOf(Class)
548 434
     * @see #isNull()
549 -
     * @see #isNull(Class)
550 435
     */
551 436
    public static <T> Set<T> anySet() {
552 437
        reportMatcher(new InstanceOf(Set.class, "<any set>"));
553 438
        return new HashSet<T>(0);
554 439
    }
555 440
556 -
    /**
557 -
     * Any <strong>non-null</strong> <code>Set</code>.
558 -
     *
559 -
     * <p>
560 -
     * Generic friendly alias to {@link ArgumentMatchers#anySet()}.
561 -
     * It's an alternative to <code>&#064;SuppressWarnings("unchecked")</code> to keep code clean of compiler warnings.
562 -
     * </p>
563 -
     *
564 -
     * <p>
565 -
     * This method doesn't do type checks of the set content with the given type parameter, it is only there
566 -
     * to avoid casting in the code.
567 -
     * </p>
568 -
     *
569 -
     * <p>
570 -
     * Since Mockito 2.1.0, only allow non-null <code>Set</code>.
571 -
     * As this is a nullable reference, the suggested API to <strong>match</strong> <code>null</code> wrapper
572 -
     * would be {@link #isNull()}. We felt this change would make test harnesses much safer than they were with Mockito
573 -
     * 1.x.
574 -
     * </p>
575 -
     *
576 -
     * <p>
577 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
578 -
     * </p>
579 -
     *
580 -
     * @param clazz Type owned by the Set to avoid casting
581 -
     * @return empty Set
582 -
     * @see #anySet()
583 -
     * @see #isNull()
584 -
     * @see #isNull(Class)
585 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
586 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
587 -
     */
588 -
    @Deprecated
589 -
    public static <T> Set<T> anySetOf(Class<T> clazz) {
590 -
        return anySet();
591 -
    }
592 -
593 441
    /**
594 442
     * Any <strong>non-null</strong> <code>Map</code>.
595 443
     *
@@ -605,53 +453,13 @@
Loading
605 453
     * </p>
606 454
     *
607 455
     * @return empty Map.
608 -
     * @see #anyMapOf(Class, Class)
609 456
     * @see #isNull()
610 -
     * @see #isNull(Class)
611 457
     */
612 458
    public static <K, V> Map<K, V> anyMap() {
613 459
        reportMatcher(new InstanceOf(Map.class, "<any map>"));
614 460
        return new HashMap<K, V>(0);
615 461
    }
616 462
617 -
    /**
618 -
     * Any <strong>non-null</strong> <code>Map</code>.
619 -
     *
620 -
     * <p>
621 -
     * Generic friendly alias to {@link ArgumentMatchers#anyMap()}.
622 -
     * It's an alternative to <code>&#064;SuppressWarnings("unchecked")</code> to keep code clean of compiler warnings.
623 -
     * </p>
624 -
     *
625 -
     * <p>
626 -
     * This method doesn't do type checks of the map content with the given type parameter, it is only there
627 -
     * to avoid casting in the code.
628 -
     * </p>
629 -
     *
630 -
     * <p>
631 -
     * Since Mockito 2.1.0, only allow non-null <code>Map</code>.
632 -
     * As this is a nullable reference, the suggested API to <strong>match</strong> <code>null</code> wrapper
633 -
     * would be {@link #isNull()}. We felt this change would make test harnesses much safer than they were with Mockito
634 -
     * 1.x.
635 -
     * </p>
636 -
     *
637 -
     * <p>
638 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
639 -
     * </p>
640 -
     *
641 -
     * @param keyClazz   Type of the map key to avoid casting
642 -
     * @param valueClazz Type of the value to avoid casting
643 -
     * @return empty Map.
644 -
     * @see #anyMap()
645 -
     * @see #isNull()
646 -
     * @see #isNull(Class)
647 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
648 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
649 -
     */
650 -
    @Deprecated
651 -
    public static <K, V> Map<K, V> anyMapOf(Class<K> keyClazz, Class<V> valueClazz) {
652 -
        return anyMap();
653 -
    }
654 -
655 463
    /**
656 464
     * Any <strong>non-null</strong> <code>Collection</code>.
657 465
     *
@@ -667,52 +475,13 @@
Loading
667 475
     * </p>
668 476
     *
669 477
     * @return empty Collection.
670 -
     * @see #anyCollectionOf(Class)
671 478
     * @see #isNull()
672 -
     * @see #isNull(Class)
673 479
     */
674 480
    public static <T> Collection<T> anyCollection() {
675 481
        reportMatcher(new InstanceOf(Collection.class, "<any collection>"));
676 482
        return new ArrayList<T>(0);
677 483
    }
678 484
679 -
    /**
680 -
     * Any <strong>non-null</strong> <code>Collection</code>.
681 -
     *
682 -
     * <p>
683 -
     * Generic friendly alias to {@link ArgumentMatchers#anyCollection()}.
684 -
     * It's an alternative to <code>&#064;SuppressWarnings("unchecked")</code> to keep code clean of compiler warnings.
685 -
     * </p>
686 -
     *
687 -
     * <p>
688 -
     * This method doesn't do type checks of the collection content with the given type parameter, it is only there
689 -
     * to avoid casting in the code.
690 -
     * </p>
691 -
     *
692 -
     * <p>
693 -
     * Since Mockito 2.1.0, only allow non-null <code>Collection</code>.
694 -
     * As this is a nullable reference, the suggested API to <strong>match</strong> <code>null</code>
695 -
     * would be {@link #isNull()}. We felt this change would make test harnesses much safer than they were with Mockito
696 -
     * 1.x.
697 -
     * </p>
698 -
     *
699 -
     * <p>
700 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
701 -
     * </p>
702 -
     *
703 -
     * @param clazz Type owned by the collection to avoid casting
704 -
     * @return empty Collection.
705 -
     * @see #anyCollection()
706 -
     * @see #isNull()
707 -
     * @see #isNull(Class)
708 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
709 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
710 -
     */
711 -
    @Deprecated
712 -
    public static <T> Collection<T> anyCollectionOf(Class<T> clazz) {
713 -
        return anyCollection();
714 -
    }
715 -
716 485
    /**
717 486
     * Any <strong>non-null</strong> <code>Iterable</code>.
718 487
     *
@@ -728,9 +497,7 @@
Loading
728 497
     * </p>
729 498
     *
730 499
     * @return empty Iterable.
731 -
     * @see #anyIterableOf(Class)
732 500
     * @see #isNull()
733 -
     * @see #isNull(Class)
734 501
     * @since 2.1.0
735 502
     */
736 503
    public static <T> Iterable<T> anyIterable() {
@@ -738,44 +505,6 @@
Loading
738 505
        return new ArrayList<T>(0);
739 506
    }
740 507
741 -
    /**
742 -
     * Any <strong>non-null</strong> <code>Iterable</code>.
743 -
     *
744 -
     * <p>
745 -
     * Generic friendly alias to {@link ArgumentMatchers#anyIterable()}.
746 -
     * It's an alternative to <code>&#064;SuppressWarnings("unchecked")</code> to keep code clean of compiler warnings.
747 -
     * </p>
748 -
     *
749 -
     * <p>
750 -
     * This method doesn't do type checks of the iterable content with the given type parameter, it is only there
751 -
     * to avoid casting in the code.
752 -
     * </p>
753 -
     *
754 -
     * <p>
755 -
     * Since Mockito 2.1.0, only allow non-null <code>String</code>.
756 -
     * As strings are nullable reference, the suggested API to <strong>match</strong> <code>null</code> wrapper
757 -
     * would be {@link #isNull()}. We felt this change would make test harnesses much safer than they were with Mockito
758 -
     * 1.x.
759 -
     * </p>
760 -
     *
761 -
     * <p>
762 -
     * See examples in javadoc for {@link ArgumentMatchers} class.
763 -
     * </p>
764 -
     *
765 -
     * @param clazz Type owned by the collection to avoid casting
766 -
     * @return empty Iterable.
767 -
     * @see #anyIterable()
768 -
     * @see #isNull()
769 -
     * @see #isNull(Class)
770 -
     * @since 2.1.0
771 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
772 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
773 -
     */
774 -
    @Deprecated
775 -
    public static <T> Iterable<T> anyIterableOf(Class<T> clazz) {
776 -
        return anyIterable();
777 -
    }
778 -
779 508
    /**
780 509
     * <code>boolean</code> argument that is equal to the given value.
781 510
     *
@@ -966,39 +695,13 @@
Loading
966 695
     * </p>
967 696
     *
968 697
     * @return <code>null</code>.
969 -
     * @see #isNull(Class)
970 698
     * @see #isNotNull()
971 -
     * @see #isNotNull(Class)
972 699
     */
973 700
    public static <T> T isNull() {
974 701
        reportMatcher(Null.NULL);
975 702
        return null;
976 703
    }
977 704
978 -
    /**
979 -
     * <code>null</code> argument.
980 -
     *
981 -
     * <p>
982 -
     * The class argument is provided to avoid casting.
983 -
     * </p>
984 -
     *
985 -
     * <p>
986 -
     * See examples in javadoc for {@link ArgumentMatchers} class
987 -
     * </p>
988 -
     *
989 -
     * @param clazz Type to avoid casting
990 -
     * @return <code>null</code>.
991 -
     * @see #isNull()
992 -
     * @see #isNotNull()
993 -
     * @see #isNotNull(Class)
994 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
995 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
996 -
     */
997 -
    @Deprecated
998 -
    public static <T> T isNull(Class<T> clazz) {
999 -
        return isNull();
1000 -
    }
1001 -
1002 705
    /**
1003 706
     * Not <code>null</code> argument.
1004 707
     *
@@ -1017,32 +720,6 @@
Loading
1017 720
        return null;
1018 721
    }
1019 722
1020 -
    /**
1021 -
     * Not <code>null</code> argument, not necessary of the given class.
1022 -
     *
1023 -
     * <p>
1024 -
     * The class argument is provided to avoid casting.
1025 -
     *
1026 -
     * Alias to {@link ArgumentMatchers#isNotNull(Class)}
1027 -
     * <p>
1028 -
     *
1029 -
     * <p>
1030 -
     * See examples in javadoc for {@link ArgumentMatchers} class
1031 -
     * </p>
1032 -
     *
1033 -
     * @param clazz Type to avoid casting
1034 -
     * @return <code>null</code>.
1035 -
     * @see #isNotNull()
1036 -
     * @see #isNull()
1037 -
     * @see #isNull(Class)
1038 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
1039 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
1040 -
     */
1041 -
    @Deprecated
1042 -
    public static <T> T notNull(Class<T> clazz) {
1043 -
        return notNull();
1044 -
    }
1045 -
1046 723
    /**
1047 724
     * Not <code>null</code> argument.
1048 725
     *
@@ -1055,36 +732,12 @@
Loading
1055 732
     * </p>
1056 733
     *
1057 734
     * @return <code>null</code>.
1058 -
     * @see #isNotNull(Class)
1059 735
     * @see #isNull()
1060 -
     * @see #isNull(Class)
1061 736
     */
1062 737
    public static <T> T isNotNull() {
1063 738
        return notNull();
1064 739
    }
1065 740
1066 -
    /**
1067 -
     * Not <code>null</code> argument, not necessary of the given class.
1068 -
     *
1069 -
     * <p>
1070 -
     * The class argument is provided to avoid casting.
1071 -
     * Alias to {@link ArgumentMatchers#notNull(Class)}
1072 -
     * </p>
1073 -
     *
1074 -
     * <p>
1075 -
     * See examples in javadoc for {@link ArgumentMatchers} class
1076 -
     * </p>
1077 -
     *
1078 -
     * @param clazz Type to avoid casting
1079 -
     * @return <code>null</code>.
1080 -
     * @deprecated With Java 8 this method will be removed in Mockito 4.0. This method is only used for generic
1081 -
     * friendliness to avoid casting, this is not anymore needed in Java 8.
1082 -
     */
1083 -
    @Deprecated
1084 -
    public static <T> T isNotNull(Class<T> clazz) {
1085 -
        return notNull(clazz);
1086 -
    }
1087 -
1088 741
    /**
1089 742
     * Argument that is either <code>null</code> or of the given type.
1090 743
     *

@@ -61,11 +61,6 @@
Loading
61 61
        return stubbing;
62 62
    }
63 63
64 -
    @Override
65 -
    public void verify(VerificationMode mode, Verification verification) {
66 -
        verify(verification, mode);
67 -
    }
68 -
69 64
    @Override
70 65
    public void verify(Verification verification, VerificationMode mode) {
71 66
        assertNotClosed();

@@ -6,7 +6,6 @@
Loading
6 6
7 7
import java.io.Serializable;
8 8
9 -
import org.mockito.configuration.AnnotationEngine;
10 9
import org.mockito.configuration.DefaultMockitoConfiguration;
11 10
import org.mockito.configuration.IMockitoConfiguration;
12 11
import org.mockito.internal.configuration.plugins.Plugins;
@@ -47,16 +46,8 @@
Loading
47 46
        new GlobalConfiguration();
48 47
    }
49 48
50 -
    public AnnotationEngine getAnnotationEngine() {
51 -
        return GLOBAL_CONFIGURATION.get().getAnnotationEngine();
52 -
    }
53 -
54 49
    public org.mockito.plugins.AnnotationEngine tryGetPluginAnnotationEngine() {
55 -
        IMockitoConfiguration configuration = GLOBAL_CONFIGURATION.get();
56 -
        if (configuration.getClass() == DefaultMockitoConfiguration.class) {
57 -
            return Plugins.getAnnotationEngine();
58 -
        }
59 -
        return configuration.getAnnotationEngine();
50 +
        return Plugins.getAnnotationEngine();
60 51
    }
61 52
62 53
    @Override
Files Complexity Coverage
src/main/java/org/mockito 87.68% 86.43%
subprojects 79.07% 84.62%
Project Totals (318 files) 87.57% 86.41%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading