Refaster rules that replace TestNG APIs with AssertJ equivalents
tech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipesorg.openrewrite.recipe:rewrite-third-partySome of the classes below have TestNG @BeforeTemplates that reference wildcard type
bounds (<?>), while the associated AssertJ @AfterTemplates reference stricter
type bounds. This introduces the risk of producing invalid code. We do this anyway, because
TestNG's wildcard types can cause javac to infer less specific types than AssertJ requires, while
the appropriate (more specific) types _will_ be inferred properly when plugged into AssertJ's
API.
The following is an example of a TestNG statement, which would not be rewritten if it weren't
for the wildcard matching (note that the type parameters of the map on the right-hand side will
be inferred to be <Object, Object> rather than <String, Object>).
``java
List<Map<String, Object>> myMaps = new ArrayList<>();
assertEquals(myMaps, ImmutableList.of(ImmutableMap.of()));
<strong>Warning:</strong> while both libraries throw an AssertionError` in case of an
assertion failure, the exact subtype used generally differs.
Source.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe tech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipesIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-third-party:0.44.0Definition
This recipe runs the following recipes in order.
- Refaster template
TestNGToAssertJRules.Failtech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$FailRecipe - Refaster template
TestNGToAssertJRules.FailWithStringtech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$FailWithStringRecipe - Refaster template
TestNGToAssertJRules.FailWithStringAndThrowabletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$FailWithStringAndThrowableRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsTruetech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsTrueRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsTruetech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsTrueRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsFalsetech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsFalseRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsFalsetech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsFalseRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsNulltech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsNullRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsNulltech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsNullRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsNotNulltech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsNotNullRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsNotNulltech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsNotNullRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsSameAstech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsSameAsRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsSameAstech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsSameAsRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsNotSameAstech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsNotSameAsRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsNotSameAstech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsNotSameAsRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsEqualTotech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsEqualToRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsEqualTotech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsEqualToRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsCloseToOffsetFloattech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsCloseToOffsetFloatRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsCloseToOffsetFloattech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsCloseToOffsetFloatRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsCloseToOffsetDoubletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsCloseToOffsetDoubleRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsCloseToOffsetDoubletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsCloseToOffsetDoubleRecipe - Refaster template
TestNGToAssertJRules.AssertThatContainsExactlytech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatContainsExactlyRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageContainsExactlytech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageContainsExactlyRecipe - Refaster template
TestNGToAssertJRules.AssertThatContainsExactlyOffsetFloattech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatContainsExactlyOffsetFloatRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageContainsExactlyOffsetFloattech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageContainsExactlyOffsetFloatRecipe - Refaster template
TestNGToAssertJRules.AssertThatContainsExactlyOffsetDoubletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatContainsExactlyOffsetDoubleRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageContainsExactlyOffsetDoubletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageContainsExactlyOffsetDoubleRecipe - Refaster template
TestNGToAssertJRules.AssertThatContainsExactlyInAnyOrdertech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatContainsExactlyInAnyOrderRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageContainsExactlyInAnyOrdertech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageContainsExactlyInAnyOrderRecipe - Refaster template
TestNGToAssertJRules.AssertThatToIterableContainsExactlyElementsOfImmutableListCopyOftech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatToIterableContainsExactlyElementsOfImmutableListCopyOfRecipe - Refaster template
TestNGToAssertJRules.AssertThatToIterableWithFailMessageContainsExactlyElementsOfImmutableListCopyOftech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatToIterableWithFailMessageContainsExactlyElementsOfImmutableListCopyOfRecipe - Refaster template
TestNGToAssertJRules.AssertThatContainsExactlyElementsOftech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatContainsExactlyElementsOfRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageContainsExactlyElementsOftech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageContainsExactlyElementsOfRecipe - Refaster template
TestNGToAssertJRules.AssertThatHasSameElementsAstech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatHasSameElementsAsRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageHasSameElementsAstech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageHasSameElementsAsRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsNotEqualTotech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsNotEqualToRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsNotEqualTotech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsNotEqualToRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsNotCloseToOffsetFloattech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsNotCloseToOffsetFloatRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsNotCloseToOffsetFloattech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsNotCloseToOffsetFloatRecipe - Refaster template
TestNGToAssertJRules.AssertThatIsNotCloseToOffsetDoubletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatIsNotCloseToOffsetDoubleRecipe - Refaster template
TestNGToAssertJRules.AssertThatWithFailMessageIsNotCloseToOffsetDoubletech.picnic.errorprone.refasterrules.TestNGToAssertJRulesRecipes$AssertThatWithFailMessageIsNotCloseToOffsetDoubleRecipe
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats