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

Quick attempt at idomatic AssertJ assertions through Refaster #550

Closed
wants to merge 1 commit into from

Conversation

timtebeek
Copy link
Contributor

What's changed?

  • Added rewrite-templating for Refaster recipe support
  • A recipe that aims to rewrite assertThat(actual).isEqualTo(0) to assertThat(actual).isZero()`

What's your motivation?

Get more idiomatic AssertJ assertions developed more easily, from having a first example here.

Anything in particular you'd like reviewers to focus on?

Currently fails as the before template isn't matched

                final JavaTemplate before = JavaTemplate
                        .builder("org.assertj.core.api.Assertions.assertThat(#{actual:any(int)}).isEqualTo(0);")
                        .javaParser(JavaParser.fromJavaVersion().classpath(JavaParser.runtimeClasspath()))
                        .build();

image

org.assertj.core.api.AbstractIntegerAssert<Generic{SELF extends }>{name=isEqualTo,return=Generic{?},parameters=[int]}

Have you considered any alternatives or workarounds?

Explicit recipe would work for this case, but is less easily developed and maintained, whereas we expect more similar recipes to be welcome here.

Any additional context

@timtebeek timtebeek self-assigned this Jul 11, 2024
@timtebeek timtebeek added the recipe Recipe request label Jul 11, 2024
@timtebeek
Copy link
Contributor Author

Likely a similar issue to what's explored in

@timtebeek
Copy link
Contributor Author

timtebeek commented Jul 25, 2024

Closing this effort for now, as we need an upstream fix in rewrite-templating first, and in parallel we also have

@timtebeek timtebeek closed this Jul 25, 2024
@timtebeek timtebeek deleted the idomatic-assertj-assertions-through-refaster branch August 21, 2024 08:03
@knutwannheden
Copy link
Contributor

Indeed.
Screenshot_20240828-044626

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants