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

isGreaterThanOrEqualTo for java.util.Date by HamcrestMatcherToAssertJ should result isAfterOrEqualTo #526

Closed
ssheikin opened this issue Jun 14, 2024 · 3 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers recipe Recipe request

Comments

@ssheikin
Copy link

What version of OpenRewrite are you using?

I am using

  • Maven/Gradle plugin 5.32.0
  • rewrite-testing-frameworks 2.10.1

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi module project.

            <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>5.32.0</version>
                <configuration>
                    <activeRecipes>
                        <recipe>org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ</recipe>
                    </activeRecipes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.openrewrite.recipe</groupId>
                        <artifactId>rewrite-testing-frameworks</artifactId>
                        <version>2.10.1</version>
                    </dependency>
                </dependencies>
            </plugin>

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

java.sql.Timestamp actualDate;
assertThat(actualDate, greaterThanOrEqualTo(expectedDate));

What did you expect to see?

assertThat(actualDate).isAfterOrEqualTo(expectedDate);

What did you see instead?

assertThat(actualDate).isGreaterThanOrEqualTo(expectedDate);

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

[ERROR] cannot find symbol
[ERROR]   symbol:   method isGreaterThanOrEqualTo(java.sql.Timestamp)
[ERROR]   location: class org.assertj.core.api.AbstractDateAssert<capture#1 of ?>

Are you interested in contributing a fix to OpenRewrite?

@ssheikin ssheikin added the bug Something isn't working label Jun 14, 2024
@timtebeek
Copy link
Contributor

Thanks for the report! Looks like we should be able to fix this quite easily by adding an additional step with an argumentType: java.util.Date that converts to isAfterOrEqualTo instead, and runs before the generalized case

- org.openrewrite.java.testing.hamcrest.HamcrestMatcherToAssertJ:
matcher: greaterThanOrEqualTo
assertion: isGreaterThanOrEqualTo

Just a couple lines of Yaml for a contribution if you're up for it; test optional as we're just reusing existing components. Is that something you'd like to contribute?

@timtebeek timtebeek added good first issue Good for newcomers recipe Recipe request labels Jun 14, 2024
@ssheikin
Copy link
Author

Sure! I'll try to take a look on my free evening.

@timtebeek
Copy link
Contributor

Awesome, thanks a lot!

@timtebeek timtebeek self-assigned this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers recipe Recipe request
Projects
Archived in project
Development

No branches or pull requests

2 participants