Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SImplify negated chained assertions with AssertJ #571

Closed
timtebeek opened this issue Aug 12, 2024 · 3 comments
Closed

SImplify negated chained assertions with AssertJ #571

timtebeek opened this issue Aug 12, 2024 · 3 comments
Assignees
Labels
good first issue Good for newcomers recipe Recipe request

Comments

@timtebeek
Copy link
Contributor

What problem are you trying to solve?

Right now we already simplify quite a few AssertJ assertions that look at isTrue.

- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
chainedAssertion: equals
assertToReplace: isTrue
dedicatedAssertion: isEqualTo
requiredType: java.lang.String
- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
chainedAssertion: equalsIgnoreCase
assertToReplace: isTrue
dedicatedAssertion: isEqualToIgnoringCase
requiredType: java.lang.String
- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
chainedAssertion: contains
assertToReplace: isTrue
dedicatedAssertion: contains
requiredType: java.lang.String

Some of these also have negated variants that we could quite easily cover as well:

  - org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
      chainedAssertion: matches
      assertToReplace: isFalse
      dedicatedAssertion: doesNotMatch
      requiredType: java.lang.String

We should add recipes for negated variants as well, starting with the one above and any similar ones we find.

@timtebeek timtebeek added the recipe Recipe request label Aug 12, 2024
@timtebeek timtebeek added the good first issue Good for newcomers label Aug 12, 2024
@timtebeek timtebeek moved this to Recipes Wanted in OpenRewrite Aug 12, 2024
@Tahanima
Copy link
Contributor

Tahanima commented Sep 6, 2024

Hi @timtebeek, I would like to add the following recipes:

- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
    chainedAssertion: startsWith
    assertToReplace: isFalse
    dedicatedAssertion: doesNotStartWith
    requiredType: java.lang.String
- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
    chainedAssertion: endsWith
    assertToReplace: isFalse
    dedicatedAssertion: doesNotEndWith
    requiredType: java.lang.String
- org.openrewrite.java.testing.assertj.SimplifyChainedAssertJAssertion:
    chainedAssertion: matches
    assertToReplace: isFalse
    dedicatedAssertion: doesNotMatch
    requiredType: java.lang.String

Should I send a PR?

@timtebeek
Copy link
Contributor Author

Hi! Yes please! Those are easiest for me to see through

@timtebeek
Copy link
Contributor Author

With the additions in #594 I think we can close this issue already; we could still identify and add more if needed of course, but there's no need to keep the issue open without a clear example to cover next. Thanks again @Tahanima !

@github-project-automation github-project-automation bot moved this from Recipes Wanted to Done in OpenRewrite Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers recipe Recipe request
Projects
Archived in project
Development

No branches or pull requests

2 participants