Skip to content

Commit

Permalink
Migrate AssertJ Fail.fail to Assertions.fail
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Oct 11, 2024
1 parent 6fff817 commit d81cc70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/rewrite/assertj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ recipeList:
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: "org.assertj.core.api.AssertionsForInterfaceTypes assertThat(..)"
fullyQualifiedTargetTypeName: "org.assertj.core.api.Assertions"
- org.openrewrite.java.ChangeMethodTargetToStatic:
methodPattern: "org.assertj.core.api.Fail fail(..)"
fullyQualifiedTargetTypeName: "org.assertj.core.api.Assertions"
- org.openrewrite.java.UseStaticImport:
methodPattern: "org.assertj.core.api.Assertions *(..)"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void useAssertionsStaticImport() {
import org.assertj.core.api.AssertionsForInterfaceTypes;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.assertj.core.api.Fail.fail;
public class Test {
List<String> exampleList;
Expand All @@ -59,13 +60,15 @@ void method() {
AssertionsForClassTypes.assertThat(true).isTrue();
assertThat(true).isTrue();
assertThat(exampleList).hasSize(0);
fail("This is a failure");
}
}
""",
"""
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
public class Test {
List<String> exampleList;
Expand All @@ -74,6 +77,7 @@ void method() {
assertThat(true).isTrue();
assertThat(true).isTrue();
assertThat(exampleList).hasSize(0);
fail("This is a failure");
}
}
"""
Expand Down

0 comments on commit d81cc70

Please sign in to comment.