Skip to content

Commit 093bc47

Browse files
1 parent 436eeb4 commit 093bc47

File tree

1 file changed

+83
-83
lines changed

1 file changed

+83
-83
lines changed

src/main/resources/META-INF/rewrite/examples.yml

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -308,40 +308,40 @@ examples:
308308
- description: ''
309309
sources:
310310
- before: |
311-
import static org.testng.Assert.fail;
312-
311+
import static org.assertj.core.api.Assertions.assertThat;
313312
class Test {
314313
void test() {
315-
fail("foo");
316-
fail("foo", new IllegalStateException());
317-
fail();
314+
assertThat("test").isEqualTo("");
318315
}
319316
}
320317
after: |
321-
import static org.assertj.core.api.Assertions.fail;
322-
318+
import static org.assertj.core.api.Assertions.assertThat;
323319
class Test {
324320
void test() {
325-
fail("foo");
326-
fail("foo", new IllegalStateException());
327-
fail();
321+
assertThat("test").isEmpty();
328322
}
329323
}
330324
language: java
331325
- description: ''
332326
sources:
333327
- before: |
334-
import static org.assertj.core.api.Assertions.assertThat;
328+
import static org.testng.Assert.fail;
329+
335330
class Test {
336331
void test() {
337-
assertThat("test").isEqualTo("");
332+
fail("foo");
333+
fail("foo", new IllegalStateException());
334+
fail();
338335
}
339336
}
340337
after: |
341-
import static org.assertj.core.api.Assertions.assertThat;
338+
import static org.assertj.core.api.Assertions.fail;
339+
342340
class Test {
343341
void test() {
344-
assertThat("test").isEmpty();
342+
fail("foo");
343+
fail("foo", new IllegalStateException());
344+
fail();
345345
}
346346
}
347347
language: java
@@ -3635,6 +3635,61 @@ examples:
36353635
type: specs.openrewrite.org/v1beta/example
36363636
recipeName: org.openrewrite.java.testing.mockito.Mockito1to3Migration
36373637
examples:
3638+
- description: ''
3639+
sources:
3640+
- before: |
3641+
package mockito.example;
3642+
3643+
import java.util.List;
3644+
import java.util.Map;
3645+
import java.util.Set;
3646+
3647+
import static org.mockito.ArgumentMatchers.anyListOf;
3648+
import static org.mockito.ArgumentMatchers.anySetOf;
3649+
import static org.mockito.ArgumentMatchers.anyMapOf;
3650+
import static org.mockito.Mockito.mock;
3651+
import static org.mockito.Mockito.when;
3652+
3653+
public class MockitoVarargMatcherTest {
3654+
public static class Foo {
3655+
public boolean addList(List<String> strings) { return true; }
3656+
public boolean addSet(Set<String> strings) { return true; }
3657+
public boolean addMap(Map<String, String> stringStringMap) { return true; }
3658+
}
3659+
public void usesVarargMatcher() {
3660+
Foo mockFoo = mock(Foo.class);
3661+
when(mockFoo.addList(anyListOf(String.class))).thenReturn(true);
3662+
when(mockFoo.addSet(anySetOf(String.class))).thenReturn(true);
3663+
when(mockFoo.addMap(anyMapOf(String.class, String.class))).thenReturn(true);
3664+
}
3665+
}
3666+
after: |
3667+
package mockito.example;
3668+
3669+
import java.util.List;
3670+
import java.util.Map;
3671+
import java.util.Set;
3672+
3673+
import static org.mockito.ArgumentMatchers.anyList;
3674+
import static org.mockito.ArgumentMatchers.anySet;
3675+
import static org.mockito.ArgumentMatchers.anyMap;
3676+
import static org.mockito.Mockito.mock;
3677+
import static org.mockito.Mockito.when;
3678+
3679+
public class MockitoVarargMatcherTest {
3680+
public static class Foo {
3681+
public boolean addList(List<String> strings) { return true; }
3682+
public boolean addSet(Set<String> strings) { return true; }
3683+
public boolean addMap(Map<String, String> stringStringMap) { return true; }
3684+
}
3685+
public void usesVarargMatcher() {
3686+
Foo mockFoo = mock(Foo.class);
3687+
when(mockFoo.addList(anyList())).thenReturn(true);
3688+
when(mockFoo.addSet(anySet())).thenReturn(true);
3689+
when(mockFoo.addMap(anyMap())).thenReturn(true);
3690+
}
3691+
}
3692+
language: java
36383693
- description: ''
36393694
sources:
36403695
- before: |
@@ -3770,61 +3825,6 @@ examples:
37703825
</project>
37713826
path: pom.xml
37723827
language: xml
3773-
- description: ''
3774-
sources:
3775-
- before: |
3776-
package mockito.example;
3777-
3778-
import java.util.List;
3779-
import java.util.Map;
3780-
import java.util.Set;
3781-
3782-
import static org.mockito.ArgumentMatchers.anyListOf;
3783-
import static org.mockito.ArgumentMatchers.anySetOf;
3784-
import static org.mockito.ArgumentMatchers.anyMapOf;
3785-
import static org.mockito.Mockito.mock;
3786-
import static org.mockito.Mockito.when;
3787-
3788-
public class MockitoVarargMatcherTest {
3789-
public static class Foo {
3790-
public boolean addList(List<String> strings) { return true; }
3791-
public boolean addSet(Set<String> strings) { return true; }
3792-
public boolean addMap(Map<String, String> stringStringMap) { return true; }
3793-
}
3794-
public void usesVarargMatcher() {
3795-
Foo mockFoo = mock(Foo.class);
3796-
when(mockFoo.addList(anyListOf(String.class))).thenReturn(true);
3797-
when(mockFoo.addSet(anySetOf(String.class))).thenReturn(true);
3798-
when(mockFoo.addMap(anyMapOf(String.class, String.class))).thenReturn(true);
3799-
}
3800-
}
3801-
after: |
3802-
package mockito.example;
3803-
3804-
import java.util.List;
3805-
import java.util.Map;
3806-
import java.util.Set;
3807-
3808-
import static org.mockito.ArgumentMatchers.anyList;
3809-
import static org.mockito.ArgumentMatchers.anySet;
3810-
import static org.mockito.ArgumentMatchers.anyMap;
3811-
import static org.mockito.Mockito.mock;
3812-
import static org.mockito.Mockito.when;
3813-
3814-
public class MockitoVarargMatcherTest {
3815-
public static class Foo {
3816-
public boolean addList(List<String> strings) { return true; }
3817-
public boolean addSet(Set<String> strings) { return true; }
3818-
public boolean addMap(Map<String, String> stringStringMap) { return true; }
3819-
}
3820-
public void usesVarargMatcher() {
3821-
Foo mockFoo = mock(Foo.class);
3822-
when(mockFoo.addList(anyList())).thenReturn(true);
3823-
when(mockFoo.addSet(anySet())).thenReturn(true);
3824-
when(mockFoo.addMap(anyMap())).thenReturn(true);
3825-
}
3826-
}
3827-
language: java
38283828
---
38293829
type: specs.openrewrite.org/v1beta/example
38303830
recipeName: org.openrewrite.java.testing.mockito.Mockito1to4Migration
@@ -4403,23 +4403,17 @@ examples:
44034403
44044404
class Test {
44054405
void test() {
4406-
String actual = "hello";
4407-
assertThat(actual).isEqualTo("hello");
4408-
assertThat(actual).isNotEqualTo("world");
4409-
assertThat(actual).isNotNull();
4410-
assertThat(actual).contains("ell");
4406+
Exception e = new IllegalArgumentException("Invalid argument provided");
4407+
assertThat(e).hasMessageThat().contains("Invalid");
44114408
}
44124409
}
44134410
after: |
44144411
import static org.assertj.core.api.Assertions.assertThat;
44154412
44164413
class Test {
44174414
void test() {
4418-
String actual = "hello";
4419-
assertThat(actual).isEqualTo("hello");
4420-
assertThat(actual).isNotEqualTo("world");
4421-
assertThat(actual).isNotNull();
4422-
assertThat(actual).contains("ell");
4415+
Exception e = new IllegalArgumentException("Invalid argument provided");
4416+
assertThat(e).hasMessageContaining("Invalid");
44234417
}
44244418
}
44254419
language: java
@@ -4430,17 +4424,23 @@ examples:
44304424
44314425
class Test {
44324426
void test() {
4433-
Exception e = new IllegalArgumentException("Invalid argument provided");
4434-
assertThat(e).hasMessageThat().contains("Invalid");
4427+
String actual = "hello";
4428+
assertThat(actual).isEqualTo("hello");
4429+
assertThat(actual).isNotEqualTo("world");
4430+
assertThat(actual).isNotNull();
4431+
assertThat(actual).contains("ell");
44354432
}
44364433
}
44374434
after: |
44384435
import static org.assertj.core.api.Assertions.assertThat;
44394436
44404437
class Test {
44414438
void test() {
4442-
Exception e = new IllegalArgumentException("Invalid argument provided");
4443-
assertThat(e).hasMessageContaining("Invalid");
4439+
String actual = "hello";
4440+
assertThat(actual).isEqualTo("hello");
4441+
assertThat(actual).isNotEqualTo("world");
4442+
assertThat(actual).isNotNull();
4443+
assertThat(actual).contains("ell");
44444444
}
44454445
}
44464446
language: java

0 commit comments

Comments
 (0)