|
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; |
19 | 19 | import lombok.EqualsAndHashCode; |
20 | 20 | import lombok.Value; |
21 | | -import org.openrewrite.ExecutionContext; |
22 | | -import org.openrewrite.Option; |
23 | | -import org.openrewrite.Recipe; |
24 | | -import org.openrewrite.TreeVisitor; |
| 21 | +import org.openrewrite.*; |
25 | 22 | import org.openrewrite.internal.lang.Nullable; |
26 | 23 | import org.openrewrite.java.JavaIsoVisitor; |
27 | 24 | import org.openrewrite.java.JavaParser; |
@@ -96,14 +93,20 @@ private JavaTemplate getExtendsWithTemplate() { |
96 | 93 | if (extendsWithTemplate == null) { |
97 | 94 | extendsWithTemplate = JavaTemplate.builder(this::getCursor, "@ExtendWith(#{}.class)") |
98 | 95 | .javaParser(() -> JavaParser.fromJavaVersion().dependsOn(Arrays.asList( |
| 96 | + fromString("package org.junit.jupiter.api.extension;\n" + |
| 97 | + "public interface Extension {}"), |
99 | 98 | fromString("package org.junit.jupiter.api.extension;\n" + |
100 | 99 | "public @interface ExtendWith {\n" + |
101 | 100 | " Class<? extends Extension>[] value();\n" + |
102 | 101 | "}"), |
103 | 102 | fromString("package " + extensionType.getPackageName() + ";\n" + |
104 | | - "public class " + extensionType.getClassName() + " {}" |
105 | | - ))).build()) |
106 | | - .imports("org.junit.jupiter.api.extension.ExtendWith", extension) |
| 103 | + "import org.junit.jupiter.api.extension.Extension;\n" + |
| 104 | + "public class " + extensionType.getClassName() + " implements Extension {}" |
| 105 | + ))) |
| 106 | + .classpath("junit") |
| 107 | + .build()) |
| 108 | + .imports("org.junit.jupiter.api.extension.ExtendWith", |
| 109 | + "org.junit.jupiter.api.extension.Extension", extension) |
107 | 110 | .build(); |
108 | 111 | } |
109 | 112 | return extendsWithTemplate; |
|
0 commit comments