@@ -3986,6 +3986,61 @@ examples:
39863986type : specs.openrewrite.org/v1beta/example
39873987recipeName : org.openrewrite.java.testing.mockito.Mockito1to3Migration
39883988examples :
3989+ - description : ' `MockitoMatchersToArgumentMatchersTest#mockitoAnyListOfToListOf`'
3990+ sources :
3991+ - before : |
3992+ package mockito.example;
3993+
3994+ import java.util.List;
3995+ import java.util.Map;
3996+ import java.util.Set;
3997+
3998+ import static org.mockito.ArgumentMatchers.anyListOf;
3999+ import static org.mockito.ArgumentMatchers.anySetOf;
4000+ import static org.mockito.ArgumentMatchers.anyMapOf;
4001+ import static org.mockito.Mockito.mock;
4002+ import static org.mockito.Mockito.when;
4003+
4004+ public class MockitoVarargMatcherTest {
4005+ public static class Foo {
4006+ public boolean addList(List<String> strings) { return true; }
4007+ public boolean addSet(Set<String> strings) { return true; }
4008+ public boolean addMap(Map<String, String> stringStringMap) { return true; }
4009+ }
4010+ public void usesVarargMatcher() {
4011+ Foo mockFoo = mock(Foo.class);
4012+ when(mockFoo.addList(anyListOf(String.class))).thenReturn(true);
4013+ when(mockFoo.addSet(anySetOf(String.class))).thenReturn(true);
4014+ when(mockFoo.addMap(anyMapOf(String.class, String.class))).thenReturn(true);
4015+ }
4016+ }
4017+ after: |
4018+ package mockito.example;
4019+
4020+ import java.util.List;
4021+ import java.util.Map;
4022+ import java.util.Set;
4023+
4024+ import static org.mockito.ArgumentMatchers.anyList;
4025+ import static org.mockito.ArgumentMatchers.anySet;
4026+ import static org.mockito.ArgumentMatchers.anyMap;
4027+ import static org.mockito.Mockito.mock;
4028+ import static org.mockito.Mockito.when;
4029+
4030+ public class MockitoVarargMatcherTest {
4031+ public static class Foo {
4032+ public boolean addList(List<String> strings) { return true; }
4033+ public boolean addSet(Set<String> strings) { return true; }
4034+ public boolean addMap(Map<String, String> stringStringMap) { return true; }
4035+ }
4036+ public void usesVarargMatcher() {
4037+ Foo mockFoo = mock(Foo.class);
4038+ when(mockFoo.addList(anyList())).thenReturn(true);
4039+ when(mockFoo.addSet(anySet())).thenReturn(true);
4040+ when(mockFoo.addMap(anyMap())).thenReturn(true);
4041+ }
4042+ }
4043+ language: java
39894044 - description : ' `Mockito1to3MigrationTest#migrateSomeMethodsAndDependencies`'
39904045 sources :
39914046 - before : |
@@ -4124,61 +4179,6 @@ examples:
41244179 </project>
41254180 path: pom.xml
41264181 language: xml
4127- - description : ' `MockitoMatchersToArgumentMatchersTest#mockitoAnyListOfToListOf`'
4128- sources :
4129- - before : |
4130- package mockito.example;
4131-
4132- import java.util.List;
4133- import java.util.Map;
4134- import java.util.Set;
4135-
4136- import static org.mockito.ArgumentMatchers.anyListOf;
4137- import static org.mockito.ArgumentMatchers.anySetOf;
4138- import static org.mockito.ArgumentMatchers.anyMapOf;
4139- import static org.mockito.Mockito.mock;
4140- import static org.mockito.Mockito.when;
4141-
4142- public class MockitoVarargMatcherTest {
4143- public static class Foo {
4144- public boolean addList(List<String> strings) { return true; }
4145- public boolean addSet(Set<String> strings) { return true; }
4146- public boolean addMap(Map<String, String> stringStringMap) { return true; }
4147- }
4148- public void usesVarargMatcher() {
4149- Foo mockFoo = mock(Foo.class);
4150- when(mockFoo.addList(anyListOf(String.class))).thenReturn(true);
4151- when(mockFoo.addSet(anySetOf(String.class))).thenReturn(true);
4152- when(mockFoo.addMap(anyMapOf(String.class, String.class))).thenReturn(true);
4153- }
4154- }
4155- after: |
4156- package mockito.example;
4157-
4158- import java.util.List;
4159- import java.util.Map;
4160- import java.util.Set;
4161-
4162- import static org.mockito.ArgumentMatchers.anyList;
4163- import static org.mockito.ArgumentMatchers.anySet;
4164- import static org.mockito.ArgumentMatchers.anyMap;
4165- import static org.mockito.Mockito.mock;
4166- import static org.mockito.Mockito.when;
4167-
4168- public class MockitoVarargMatcherTest {
4169- public static class Foo {
4170- public boolean addList(List<String> strings) { return true; }
4171- public boolean addSet(Set<String> strings) { return true; }
4172- public boolean addMap(Map<String, String> stringStringMap) { return true; }
4173- }
4174- public void usesVarargMatcher() {
4175- Foo mockFoo = mock(Foo.class);
4176- when(mockFoo.addList(anyList())).thenReturn(true);
4177- when(mockFoo.addSet(anySet())).thenReturn(true);
4178- when(mockFoo.addMap(anyMap())).thenReturn(true);
4179- }
4180- }
4181- language: java
41824182 ---
41834183type : specs.openrewrite.org/v1beta/example
41844184recipeName : org.openrewrite.java.testing.mockito.Mockito1to4Migration
@@ -4238,6 +4238,25 @@ examples:
42384238type : specs.openrewrite.org/v1beta/example
42394239recipeName : org.openrewrite.java.testing.mockito.Mockito1to5Migration
42404240examples :
4241+ - description : ' `MockitoInlineToCoreTest#inlineToCore`'
4242+ sources :
4243+ - before : |
4244+ <project>
4245+ <modelVersion>4.0.0</modelVersion>
4246+ <groupId>com.example</groupId>
4247+ <artifactId>demo</artifactId>
4248+ <version>0.0.1-SNAPSHOT</version>
4249+ <dependencies>
4250+ <dependency>
4251+ <groupId>org.mockito</groupId>
4252+ <artifactId>mockito-inline</artifactId>
4253+ <version>3.11.2</version>
4254+ <scope>test</scope>
4255+ </dependency>
4256+ </dependencies>
4257+ </project>
4258+ path: pom.xml
4259+ language: xml
42414260 - description : ' `Mockito1to5MigrationTest#modifyMockitoDependencies`'
42424261 sources :
42434262 - before : |
@@ -4273,25 +4292,6 @@ examples:
42734292 }
42744293 }
42754294 language: java
4276- - description : ' `MockitoInlineToCoreTest#inlineToCore`'
4277- sources :
4278- - before : |
4279- <project>
4280- <modelVersion>4.0.0</modelVersion>
4281- <groupId>com.example</groupId>
4282- <artifactId>demo</artifactId>
4283- <version>0.0.1-SNAPSHOT</version>
4284- <dependencies>
4285- <dependency>
4286- <groupId>org.mockito</groupId>
4287- <artifactId>mockito-inline</artifactId>
4288- <version>3.11.2</version>
4289- <scope>test</scope>
4290- </dependency>
4291- </dependencies>
4292- </project>
4293- path: pom.xml
4294- language: xml
42954295 ---
42964296type : specs.openrewrite.org/v1beta/example
42974297recipeName : org.openrewrite.java.testing.mockito.MockitoBestPractices
@@ -4780,51 +4780,51 @@ examples:
47804780type : specs.openrewrite.org/v1beta/example
47814781recipeName : org.openrewrite.java.testing.truth.MigrateTruthToAssertJ
47824782examples :
4783- - description : ' `MigrateTruthToAssertJTest#basicAssertThatConversion `'
4783+ - description : ' `TruthThrowableAssertionsTest#hasMessageThatContains `'
47844784 sources :
47854785 - before : |
47864786 import static com.google.common.truth.Truth.assertThat;
47874787
47884788 class Test {
47894789 void test() {
4790- String actual = "hello";
4791- assertThat(actual).isEqualTo("hello");
4792- assertThat(actual).isNotEqualTo("world");
4793- assertThat(actual).isNotNull();
4794- assertThat(actual).contains("ell");
4790+ Exception e = new IllegalArgumentException("Invalid argument provided");
4791+ assertThat(e).hasMessageThat().contains("Invalid");
47954792 }
47964793 }
47974794 after: |
47984795 import static org.assertj.core.api.Assertions.assertThat;
47994796
48004797 class Test {
48014798 void test() {
4802- String actual = "hello";
4803- assertThat(actual).isEqualTo("hello");
4804- assertThat(actual).isNotEqualTo("world");
4805- assertThat(actual).isNotNull();
4806- assertThat(actual).contains("ell");
4799+ Exception e = new IllegalArgumentException("Invalid argument provided");
4800+ assertThat(e).hasMessageContaining("Invalid");
48074801 }
48084802 }
48094803 language: java
4810- - description : ' `TruthThrowableAssertionsTest#hasMessageThatContains `'
4804+ - description : ' `MigrateTruthToAssertJTest#basicAssertThatConversion `'
48114805 sources :
48124806 - before : |
48134807 import static com.google.common.truth.Truth.assertThat;
48144808
48154809 class Test {
48164810 void test() {
4817- Exception e = new IllegalArgumentException("Invalid argument provided");
4818- assertThat(e).hasMessageThat().contains("Invalid");
4811+ String actual = "hello";
4812+ assertThat(actual).isEqualTo("hello");
4813+ assertThat(actual).isNotEqualTo("world");
4814+ assertThat(actual).isNotNull();
4815+ assertThat(actual).contains("ell");
48194816 }
48204817 }
48214818 after: |
48224819 import static org.assertj.core.api.Assertions.assertThat;
48234820
48244821 class Test {
48254822 void test() {
4826- Exception e = new IllegalArgumentException("Invalid argument provided");
4827- assertThat(e).hasMessageContaining("Invalid");
4823+ String actual = "hello";
4824+ assertThat(actual).isEqualTo("hello");
4825+ assertThat(actual).isNotEqualTo("world");
4826+ assertThat(actual).isNotNull();
4827+ assertThat(actual).contains("ell");
48284828 }
48294829 }
48304830 language: java
0 commit comments