Class JUnitAssertTrueToAssertThat
- java.lang.Object
-
- org.openrewrite.Recipe
-
- org.openrewrite.java.testing.assertj.JUnitAssertTrueToAssertThat
-
public class JUnitAssertTrueToAssertThat extends org.openrewrite.RecipeThis is a refactoring visitor that will convert JUnit-style assertTrue() to assertJ's assertThat().isTrue().This visitor only supports the migration of the following JUnit 5 assertTrue() methods:
assertTrue(boolean condition) == assertThat(condition).isTrue() assertTrue(boolean condition, String message) == assertThat(condition).withFailMessage(message).isTrue(); assertTrue(boolean condition, Supplier
messageSupplier) == assertThat(condition).withFailMessage(messageSupplier).isTrue(); Note: There are three additional method signatures in JUnit that use a BooleanSupplier for the condition. Attempts to map these signatures into assertJ's model obfuscates the original assertion. It would be possible to use a shim method to support these method signatures, however, those shims would need to exist on each compilation unit or in a shared testing utilities library.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJUnitAssertTrueToAssertThat.AssertTrueToAssertThatVisitor
-
Constructor Summary
Constructors Constructor Description JUnitAssertTrueToAssertThat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetDescription()java.lang.StringgetDisplayName()protected org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext>getVisitor()
-
-
-
Method Detail
-
getDisplayName
public java.lang.String getDisplayName()
- Specified by:
getDisplayNamein classorg.openrewrite.Recipe
-
getDescription
public java.lang.String getDescription()
- Overrides:
getDescriptionin classorg.openrewrite.Recipe
-
getVisitor
protected org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
- Overrides:
getVisitorin classorg.openrewrite.Recipe
-
-