|
15 | 15 | */ |
16 | 16 | package org.openrewrite.java.testing.hamcrest; |
17 | 17 |
|
| 18 | +import org.junit.jupiter.api.Test; |
18 | 19 | import org.junit.jupiter.params.ParameterizedTest; |
19 | 20 | import org.junit.jupiter.params.provider.Arguments; |
20 | 21 | import org.junit.jupiter.params.provider.MethodSource; |
| 22 | +import org.openrewrite.DocumentExample; |
21 | 23 | import org.openrewrite.InMemoryExecutionContext; |
22 | 24 | import org.openrewrite.Issue; |
23 | 25 | import org.openrewrite.config.Environment; |
@@ -45,6 +47,41 @@ public void defaults(RecipeSpec spec) { |
45 | 47 | .activateRecipes("org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ")); |
46 | 48 | } |
47 | 49 |
|
| 50 | + @Test |
| 51 | + @DocumentExample |
| 52 | + void isEqualTo() { |
| 53 | + rewriteRun( |
| 54 | + //language=java |
| 55 | + java(""" |
| 56 | + import org.junit.jupiter.api.Test; |
| 57 | + import static org.hamcrest.MatcherAssert.assertThat; |
| 58 | + import static org.hamcrest.Matchers.is; |
| 59 | + import static org.hamcrest.Matchers.equalTo; |
| 60 | + |
| 61 | + class ATest { |
| 62 | + @Test |
| 63 | + void testEquals() { |
| 64 | + String str1 = "Hello world!"; |
| 65 | + String str2 = "Hello world!"; |
| 66 | + assertThat(str1, is(equalTo(str2))); |
| 67 | + } |
| 68 | + } |
| 69 | + """, """ |
| 70 | + import org.junit.jupiter.api.Test; |
| 71 | + |
| 72 | + import static org.assertj.core.api.Assertions.assertThat; |
| 73 | + |
| 74 | + class ATest { |
| 75 | + @Test |
| 76 | + void testEquals() { |
| 77 | + String str1 = "Hello world!"; |
| 78 | + String str2 = "Hello world!"; |
| 79 | + assertThat(str1).isEqualTo(str2); |
| 80 | + } |
| 81 | + } |
| 82 | + """)); |
| 83 | + } |
| 84 | + |
48 | 85 | private static Stream<Arguments> stringReplacements() { |
49 | 86 | return Stream.of( |
50 | 87 | Arguments.arguments("str1", "blankString", "", "isBlank"), |
|
0 commit comments