Skip to content

Commit a4fc572

Browse files
committed
Fix failing TemporaryFolderToTempDir test
The test didn't register a Groovy parser with the required classpath entries even though one of the test cases included a Groovy source. As a result the type attribution was missing and the recipe didn't get fully applied.
1 parent e8eada9 commit a4fc572

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/main/java/org/openrewrite/java/testing/junit5/TemporaryFolderToTempDir.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
5656
return new JavaVisitor<ExecutionContext>() {
5757

5858
@Nullable
59-
private Supplier<JavaParser> javaParser;
59+
private JavaParser.Builder<?, ?> javaParser;
6060

61-
private Supplier<JavaParser> javaParser(ExecutionContext ctx) {
61+
private JavaParser.Builder<?, ?> javaParser(ExecutionContext ctx) {
6262
if (javaParser == null) {
63-
javaParser = () -> JavaParser.fromJavaVersion()
64-
.classpathFromResources(ctx, "junit-jupiter-api-5.9.2")
65-
.build();
63+
javaParser = JavaParser.fromJavaVersion()
64+
.classpathFromResources(ctx, "junit-jupiter-api-5.9.2");
6665
}
6766
return javaParser;
6867

src/test/java/org/openrewrite/java/testing/junit5/TemporaryFolderToTempDirTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.junit.jupiter.api.Test;
1919
import org.openrewrite.InMemoryExecutionContext;
2020
import org.openrewrite.Issue;
21+
import org.openrewrite.groovy.GroovyParser;
2122
import org.openrewrite.java.JavaParser;
2223
import org.openrewrite.test.RecipeSpec;
2324
import org.openrewrite.test.RewriteTest;
@@ -34,6 +35,8 @@ public void defaults(RecipeSpec spec) {
3435
spec
3536
.parser(JavaParser.fromJavaVersion()
3637
.classpathFromResources(new InMemoryExecutionContext(), "junit-4.13.+"))
38+
.parser(GroovyParser.builder()
39+
.classpathFromResource(new InMemoryExecutionContext(), "junit-4.13.+"))
3740
.recipe(new TemporaryFolderToTempDir());
3841
}
3942

0 commit comments

Comments
 (0)