Skip to content

Commit

Permalink
add test to confirm issue
Browse files Browse the repository at this point in the history
  • Loading branch information
timo-abele committed Sep 21, 2024
1 parent 5be8a6f commit 9b6de84
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,36 @@ class AssertJBestPracticesTest implements RewriteTest {
public void defaults(RecipeSpec spec) {
spec.parser(
JavaParser.fromJavaVersion()
.classpathFromResources(new InMemoryExecutionContext(), "assertj-core-3.24"))
.classpathFromResources(new InMemoryExecutionContext(), "assertj-core-3.24", "junit-jupiter-api-5.9"))
.recipeFromResources("org.openrewrite.java.testing.assertj.Assertj");
}

@Test
@SuppressWarnings("DataFlowIssue")
void convertsIsInstanceOf() {//todo migrate this test to the specific sub recipe
rewriteRun(
// language=java
java(
"""
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
class Test {
void test() {
assertInstanceOf(Integer.class, 4);
}
}
""",
"""
import static org.assertj.core.api.Assertions.assertThat;
class Test {
void test() {
assertThat(4).isInstanceOf(Integer.class);
}
}
"""
)
);
}

@DocumentExample
@Test
@SuppressWarnings("DataFlowIssue")
Expand Down Expand Up @@ -319,4 +345,5 @@ void test(%2$s x, %2$s y, Object value) {
template.formatted(imprt, argumentsType, dedicatedAssertion)));
}
}

}

0 comments on commit 9b6de84

Please sign in to comment.