Skip to content

Commit

Permalink
Merge branch 'main' into ssheikin/testng-assert
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Jun 17, 2024
2 parents 70f6c38 + 60cff4b commit 20f2666
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ dependencies {
implementation("org.openrewrite:rewrite-maven")
implementation("org.openrewrite.recipe:rewrite-java-dependencies:$rewriteVersion")
implementation("org.openrewrite.recipe:rewrite-static-analysis:$rewriteVersion")
implementation("org.openrewrite.recipe:rewrite-third-party:$rewriteVersion") {
// TODO remove once available from https://github.com/openrewrite/rewrite-third-party/commit/474b3461cdae4bcbd80
exclude(module = "jakarta.xml.bind-api")
}
implementation("org.openrewrite.recipe:rewrite-third-party:$rewriteVersion")
runtimeOnly("org.openrewrite:rewrite-java-17")

compileOnly("org.projectlombok:lombok:latest.release")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

import java.util.Collections;

/**
* AssertJ has a more idiomatic way of asserting that a String is empty.
* This recipe will find instances of `assertThat(String).isEqualTo("")` and replace them with `isEmpty()`.
*
* @deprecated Use {@link tech.picnic.errorprone.refasterrules.AssertJStringRulesRecipes.AbstractStringAssertStringIsEmptyRecipe} instead.
*/
@Deprecated
public class IsEqualToEmptyString extends Recipe {

private static final MethodMatcher IS_EQUAL_TO = new MethodMatcher("org.assertj.core.api.AbstractStringAssert isEqualTo(java.lang.String)");
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/META-INF/rewrite/assertj.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ recipeList:
- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertions
- org.openrewrite.java.testing.assertj.IsEqualToEmptyString

- tech.picnic.errorprone.refasterrules.AssertJBigDecimalRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJBigIntegerRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJBooleanRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJByteRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJCharSequenceRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJDoubleRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJFloatRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJIntegerRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJLongRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJNumberRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJPrimitiveRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJShortRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJStringRulesRecipes
- tech.picnic.errorprone.refasterrules.AssertJThrowingCallableRulesRecipes

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.testing.assertj.StaticImports
Expand Down Expand Up @@ -366,3 +382,4 @@ recipeList:
version: 3.x
onlyIfUsing: org.assertj.core.api.Assertions
acceptTransitive: true
- tech.picnic.errorprone.refasterrules.JUnitToAssertJRulesRecipes
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@

import static org.openrewrite.java.Assertions.java;

class IsEqualToEmptyStringTest implements RewriteTest {
class AssertJBestPracticesTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec
.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "assertj-core-3.24"))
.recipe(new IsEqualToEmptyString());
.recipeFromResources("org.openrewrite.java.testing.assertj.Assertj");
}

@DocumentExample
Expand Down

0 comments on commit 20f2666

Please sign in to comment.