Skip to content

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

Closed
timtebeek wants to merge 1 commit intomainfrom
troubleshoot-mismatched-assertj-method
Closed

Troubleshoot mismatched AssertJ AbstractStringAssert.isEqualTo("")#91
timtebeek wants to merge 1 commit intomainfrom
troubleshoot-mismatched-assertj-method

Conversation

@timtebeek
Copy link
Copy Markdown
Member

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
Copy Markdown
Member 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
Copy Markdown
Member 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