Skip to content

SImplify negated chained assertions with AssertJ #571

@timtebeek

Description

@timtebeek

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions