Design Partners
Mockito 3.x migration from 1.x
** org.openrewrite.java.testing.mockito.Mockito1to3Migration** Upgrade Mockito from 1.x to 3.x.

Tags

  • testing
  • mockito

Source

  • groupId: org.openrewrite.recipe
  • artifactId: rewrite-testing-frameworks
  • version: 1.23.0

Usage

This recipe has no required configuration options and can be activated directly after taking a dependency on org.openrewrite.recipe:rewrite-testing-frameworks:1.23.0 in your build file:
Gradle
Maven
build.gradle
1
plugins {
2
id("org.openrewrite.rewrite") version("5.22.2")
3
}
4
5
rewrite {
6
activeRecipe("org.openrewrite.java.testing.mockito.Mockito1to3Migration")
7
}
8
9
repositories {
10
mavenCentral()
11
}
12
13
dependencies {
14
rewrite("org.openrewrite.recipe:rewrite-testing-frameworks:1.23.0")
15
}
Copied!
pom.xml
1
<project>
2
<build>
3
<plugins>
4
<plugin>
5
<groupId>org.openrewrite.maven</groupId>
6
<artifactId>rewrite-maven-plugin</artifactId>
7
<version>4.25.0</version>
8
<configuration>
9
<activeRecipes>
10
<recipe>org.openrewrite.java.testing.mockito.Mockito1to3Migration</recipe>
11
</activeRecipes>
12
</configuration>
13
<dependencies>
14
<dependency>
15
<groupId>org.openrewrite.recipe</groupId>
16
<artifactId>rewrite-testing-frameworks</artifactId>
17
<version>1.23.0</version>
18
</dependency>
19
</dependencies>
20
</plugin>
21
</plugins>
22
</build>
23
</project>
Copied!
Recipes can also be activated directly from the command line by adding the argument -Drewrite.activeRecipesorg.openrewrite.java.testing.mockito.Mockito1to3Migration

Definition

Recipe List
Yaml Recipe List
    • oldFullyQualifiedTypeName: org.mockito.MockitoAnnotations.Mock
    • newFullyQualifiedTypeName: org.mockito.Mock
    • oldFullyQualifiedTypeName: org.mockito.Matchers
    • newFullyQualifiedTypeName: org.mockito.ArgumentMatchers
    • methodPattern: org.mockito.ArgumentMatchers anyVararg()
    • newMethodName: any
    • methodPattern: org.mockito.ArgumentMatchers anyObject()
    • newMethodName: any
    • methodPattern: org.mockito.ArgumentMatchers anyListOf()
    • newMethodName: anyList
    • methodPattern: org.mockito.ArgumentMatchers anySetOf()
    • newMethodName: anySet
    • methodPattern: org.mockito.ArgumentMatchers anyMapOf()
    • newMethodName: anyMap
    • methodPattern: org.mockito.ArgumentMatchers anyCollectionOf()
    • newMethodName: anyCollection
    • methodPattern: org.mockito.ArgumentMatchers anyIterableOf()
    • newMethodName: anyIterable
    • methodPattern: org.mockito.ArgumentMatchers isNull(java.lang.Class)
    • argumentIndex: 0
    • methodPattern: org.mockito.ArgumentMatchers notNull(java.lang.Class)
    • argumentIndex: 0
    • methodPattern: org.mockito.MockedStatic verify(org.mockito.verification.VerificationMode, org.mockito.MockedStatic.Verification)
    • newParameterNames: [verification, mode]
    • oldParameterNames: [mode, verification]
    • methodPattern: org.mockito.Mockito verifyZeroInteractions(..)
    • newMethodName: verifyNoInteractions
    • methodPattern: org.mockito.invocation.InvocationOnMock getArgumentAt(int, java.lang.Class)
    • newMethodName: getArgument
    • oldFullyQualifiedTypeName: org.mockito.exceptions.verification.TooLittleActualInvocations
    • newFullyQualifiedTypeName: org.mockito.exceptions.verification.TooFewActualInvocations
    • oldFullyQualifiedTypeName: org.mockito.configuration.AnnotationEngine
    • newFullyQualifiedTypeName: org.mockito.plugins.AnnotationEngine
    • oldFullyQualifiedTypeName: org.mockito.plugins.InstantiatorProvider
    • newFullyQualifiedTypeName: org.mockito.plugins.InstantiatorProvider2
    • oldFullyQualifiedTypeName: org.mockito.runners.MockitoJUnitRunner
    • newFullyQualifiedTypeName: org.mockito.junit.MockitoJUnitRunner
    • groupId: org.mockito
    • artifactId: mockito-junit-jupiter
    • version: 3.x
    • onlyIfUsing: org.mockito.junit.jupiter.MockitoExtension
1
---
2
type: specs.openrewrite.org/v1beta/recipe
3
name: org.openrewrite.java.testing.mockito.Mockito1to3Migration
4
displayName: Mockito 3.x migration from 1.x
5
description: Upgrade Mockito from 1.x to 3.x.
6
tags:
7
- testing
8
- mockito
9
recipeList:
10
- org.openrewrite.java.ChangeType:
11
oldFullyQualifiedTypeName: org.mockito.MockitoAnnotations.Mock
12
newFullyQualifiedTypeName: org.mockito.Mock
13
- org.openrewrite.java.ChangeType:
14
oldFullyQualifiedTypeName: org.mockito.Matchers
15
newFullyQualifiedTypeName: org.mockito.ArgumentMatchers
16
- org.openrewrite.java.ChangeMethodName:
17
methodPattern: org.mockito.ArgumentMatchers anyVararg()
18
newMethodName: any
19
- org.openrewrite.java.ChangeMethodName:
20
methodPattern: org.mockito.ArgumentMatchers anyObject()
21
newMethodName: any
22
- org.openrewrite.java.ChangeMethodName:
23
methodPattern: org.mockito.ArgumentMatchers anyListOf()
24
newMethodName: anyList
25
- org.openrewrite.java.ChangeMethodName:
26
methodPattern: org.mockito.ArgumentMatchers anySetOf()
27
newMethodName: anySet
28
- org.openrewrite.java.ChangeMethodName:
29
methodPattern: org.mockito.ArgumentMatchers anyMapOf()
30
newMethodName: anyMap
31
- org.openrewrite.java.ChangeMethodName:
32
methodPattern: org.mockito.ArgumentMatchers anyCollectionOf()
33
newMethodName: anyCollection
34
- org.openrewrite.java.ChangeMethodName:
35
methodPattern: org.mockito.ArgumentMatchers anyIterableOf()
36
newMethodName: anyIterable
37
- org.openrewrite.java.DeleteMethodArgument:
38
methodPattern: org.mockito.ArgumentMatchers isNull(java.lang.Class)
39
argumentIndex: 0
40
- org.openrewrite.java.DeleteMethodArgument:
41
methodPattern: org.mockito.ArgumentMatchers notNull(java.lang.Class)
42
argumentIndex: 0
43
- org.openrewrite.java.ReorderMethodArguments:
44
methodPattern: org.mockito.MockedStatic verify(org.mockito.verification.VerificationMode, org.mockito.MockedStatic.Verification)
45
newParameterNames: [verification, mode]
46
oldParameterNames: [mode, verification]
47
- org.openrewrite.java.ChangeMethodName:
48
methodPattern: org.mockito.Mockito verifyZeroInteractions(..)
49
newMethodName: verifyNoInteractions
50
- org.openrewrite.java.ChangeMethodName:
51
methodPattern: org.mockito.invocation.InvocationOnMock getArgumentAt(int, java.lang.Class)
52
newMethodName: getArgument
53
- org.openrewrite.java.ChangeType:
54
oldFullyQualifiedTypeName: org.mockito.exceptions.verification.TooLittleActualInvocations
55
newFullyQualifiedTypeName: org.mockito.exceptions.verification.TooFewActualInvocations
56
- org.openrewrite.java.ChangeType:
57
oldFullyQualifiedTypeName: org.mockito.configuration.AnnotationEngine
58
newFullyQualifiedTypeName: org.mockito.plugins.AnnotationEngine
59
- org.openrewrite.java.ChangeType:
60
oldFullyQualifiedTypeName: org.mockito.plugins.InstantiatorProvider
61
newFullyQualifiedTypeName: org.mockito.plugins.InstantiatorProvider2
62
- org.openrewrite.java.ChangeType:
63
oldFullyQualifiedTypeName: org.mockito.runners.MockitoJUnitRunner
64
newFullyQualifiedTypeName: org.mockito.junit.MockitoJUnitRunner
65
- org.openrewrite.java.testing.mockito.CleanupMockitoImports
66
- org.openrewrite.java.testing.mockito.MockUtilsToStatic
67
- org.openrewrite.maven.AddDependency:
68
groupId: org.mockito
69
artifactId: mockito-junit-jupiter
70
version: 3.x
71
onlyIfUsing: org.mockito.junit.jupiter.MockitoExtension
72
- org.openrewrite.java.testing.junit5.MockitoJUnitToMockitoExtension
Copied!
Export as PDF
Copy link