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

Troubleshoot mismatched AssertJ AbstractStringAssert.isEqualTo("") #91

Closed
wants to merge 1 commit into from

Conversation

timtebeek
Copy link
Contributor

This is a recipe that originates with Picnic: https://error-prone.picnic.tech/refasterrules/AssertJStringRules/#abstractstringassertstringisempty

At present it fails to convert this test case

@Test
void convertsIsEqualToEmptyString() {
    rewriteRun(
      //language=java
      java(
        """
          import static org.assertj.core.api.Assertions.assertThat;
          class Test {
              void test() {
                  assertThat("test").isEqualTo("");
              }
          }
          """,
        """
          import static org.assertj.core.api.Assertions.assertThat;
          class Test {
              void test() {
                  assertThat("test").isEmpty();
              }
          }
          """
      )
    );
}

As discovered on

Not yet sure if the fix should go into the generated recipe, or in the matchers used in the generated recipe. Figured log this as a pseudo issue to more easily see the generated recipe.

@timtebeek timtebeek added the bug Something isn't working label Jun 15, 2024
@timtebeek timtebeek changed the title Troubleshoot mismatched AssertJ method Troubleshoot mismatched AssertJ AbstractStringAssert.isEqualTo("") Jun 15, 2024
@timtebeek
Copy link
Contributor Author

Setting a breakpoint in tech.picnic.errorprone.refasterrules.AssertJStringRulesRecipes.AbstractStringAssertStringIsEmptyRecipe#getVisitor shows that the before matcher does not match the input in the case.

image

@timtebeek
Copy link
Contributor Author

Continued here; as the problem looks to be with the matcher, not the generator.

@timtebeek timtebeek closed this Aug 16, 2024
@timtebeek timtebeek deleted the troubleshoot-mismatched-assertj-method branch August 16, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant