Skip to content

Commit 4f6a49a

Browse files
committed
TestRuleToTestInfo adds java.util.Optional import. (fixes #229)
1 parent 8316682 commit 4f6a49a

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
152152
cd.getBody().getCoordinates().lastStatement(),
153153
varDecls.getVariables().get(0).getName().getSimpleName());
154154
maybeAddImport("java.lang.reflect.Method");
155+
maybeAddImport("java.util.Optional");
155156
} else {
156157
doAfterVisit(new BeforeMethodToTestInfoVisitor(beforeMethod, varDecls, testMethodStatement));
157158
}
@@ -195,6 +196,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
195196
md = md.withBody(md.getBody().withStatements(reorderedStatements));
196197
}
197198
maybeAddImport("java.lang.reflect.Method");
199+
maybeAddImport("java.util.Optional");
198200
}
199201
return md;
200202
}

src/test/kotlin/org/openrewrite/java/testing/junit5/TestRuleToTestInfoTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class TestRuleToTestInfoTest : JavaRecipeTest {
4848
import org.junit.jupiter.api.TestInfo;
4949
5050
import java.lang.reflect.Method;
51+
import java.util.Optional;
5152
5253
public class SomeTest {
5354
@@ -99,6 +100,7 @@ class TestRuleToTestInfoTest : JavaRecipeTest {
99100
import org.junit.jupiter.api.TestInfo;
100101
101102
import java.lang.reflect.Method;
103+
import java.util.Optional;
102104
103105
public class SomeTest {
104106
protected int count;

0 commit comments

Comments
 (0)