Skip to content

Commit caf35b2

Browse files
authored
Remove all deprecated APIs (#2418)
All of these APIs have been marked as deprecated and have been present in Mockito for quite a while. To cleanup our API surface and reduce technical debt, let's remove these long-deprecated methods/classes. An overview of now-deleted classes/methods: - org.mockito.Matchers which was an alias for org.mockito.ArgumentMatchers - org.mockito.ArgumentMatchers#{anyObject,anyVararg} both which were aliases for org.mockito.ArgumentMatchers#any - org.mockito.ArgumentMatchers#any*Of, which were aliases for the same method name without the Of and the generic parameters (which were ignored) - org.mockito.ArgumentMatchers#{is}{Not}Null(Class) which took a class which was ignored. Aliases for the same methods without the parameter - org.mockito.MockedStatic#verify which had the parameter types reversed - org.mockito.Mockito#verifyZeroInteractions an alias of verifyNoMoreInteractions - org.mockito.Mockito#debug framework integration API that we later refactored - org.mockito.configuration.AnnotationEngine which was leaking internal APIs and instead users should use org.mockito.plugins.AnnotationEngine - org.mockito.exceptions.verification.TooLittleActualInvocations fixed the grammar from "Little" to "Few" - Numerous internal APIs that we never officially supported and can now be removed - org.mockito.plugins.InstantiatorProvider which was leaking internal APIs and instead users should use InstantiatorProvider2 (we should probably rename back to remove the number in a future major release) - org.mockito.runners a package that hosted several old JUnit runners which were no longer supported. Users should instead use org.mockito.junit.MockitoJUnitRunner which is our official JUnit4 runner. Since these APIs are removed, this change effectively defines Mockito 4.
1 parent 916e61e commit caf35b2

109 files changed

Lines changed: 158 additions & 2317 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

settings.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ plugins {
22
id("com.gradle.enterprise").version("3.3.4")
33
}
44

5-
include("deprecatedPluginsTest",
6-
"inline",
5+
include("inline",
76
"proxy",
87
"extTest",
98
"groovyTest",

src/main/java/org/mockito/AdditionalMatchers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
import org.mockito.internal.matchers.LessThan;
1717

1818
/**
19-
* See {@link Matchers} for general info about matchers.
19+
* See {@link ArgumentMatchers} for general info about matchers.
2020
* <p>
2121
* AdditionalMatchers provides rarely used matchers, kept only for somewhat compatibility with EasyMock.
2222
* 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.
2424
* <p>
2525
* Example of using logical and(), not(), or() matchers:
2626
*

src/main/java/org/mockito/Answers.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,6 @@ public enum Answers implements Answer<Object> {
8585
this.implementation = implementation;
8686
}
8787

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-
9788
@Override
9889
public Object answer(InvocationOnMock invocation) throws Throwable {
9990
return implementation.answer(invocation);

src/main/java/org/mockito/ArgumentMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* </ul>
4545
*
4646
* <p>
47-
* Implementations of this interface can be used with {@link Matchers#argThat} method.
47+
* Implementations of this interface can be used with {@link ArgumentMatchers#argThat} method.
4848
* Use <code>toString()</code> method for description of the matcher
4949
* - it is printed in verification errors.
5050
*
@@ -84,7 +84,7 @@
8484
* </code></pre>
8585
*
8686
* <p>
87-
* Read more about other matchers in javadoc for {@link Matchers} class.
87+
* Read more about other matchers in javadoc for {@link ArgumentMatchers} class.
8888
* <h2>2.1.0 migration guide</h2>
8989
*
9090
* All existing custom implementations of <code>ArgumentMatcher</code> will no longer compile.

0 commit comments

Comments
 (0)