Skip to content

CollapseConsecutiveAssertThatStatements does not work on Integers (possibly only on Lists?) #605

@timo-abele

Description

@timo-abele

What version of OpenRewrite are you using?

I am using the latest as of 2024-09-20

How are you running OpenRewrite?

Gradle by editing build file, confirmed by tests on this repository:

What is the smallest, simplest way to reproduce the problem?

in short:

                      Integer i = 1+1;
                      assertThat(i).isNotNull();
                      assertThat(i).isEqualTo(2);

What did you expect to see?

                      Integer i = 1+1;
                      assertThat(i).isNotNull().isEqualTo(2);

What did you see instead?

no change

What is the full stack trace of any errors you encountered?

per https://github.com/openrewrite/rewrite-testing-frameworks/actions/runs/10971127404/job/30465846209?pr=604#step:5:1484

CollapseConsecutiveAssertThatStatementsTest > collapseAssertThatsOnInteger() FAILED
    java.lang.AssertionError: Recipe was expected to make a change but made no changes.
        at org.openrewrite.test.LargeSourceSetCheckingExpectedCycles.afterCycle(LargeSourceSetCheckingExpectedCycles.java:119)
        at org.openrewrite.RecipeScheduler.runRecipeCycles(RecipeScheduler.java:98)
        at org.openrewrite.RecipeScheduler.scheduleRun(RecipeScheduler.java:41)
        at org.openrewrite.Recipe.run(Recipe.java:376)
        at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:371)
        at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:130)
        at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:125)
        at org.openrewrite.java.testing.assertj.CollapseConsecutiveAssertThatStatementsTest.collapseAssertThatsOnInteger(CollapseConsecutiveAssertThatStatementsTest.java:197)

Context

The existing test are all on Lists, so maybe the recipe currently only works on those and other types need to be enabled in general.

Are you interested in contributing a fix to OpenRewrite?

No

Metadata

Metadata

Assignees

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions