From 7db05b43c914b41f379487c02430be517f0e9bd4 Mon Sep 17 00:00:00 2001 From: Sam Snyder Date: Thu, 22 Apr 2021 21:20:48 -0700 Subject: [PATCH] Fix package name typo which was leading to imports not being added by OutputCaptureExtension. Should fix #46 for real this time. --- .../java/spring/boot2/OutputCaptureExtension.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openrewrite/java/spring/boot2/OutputCaptureExtension.java b/src/main/java/org/openrewrite/java/spring/boot2/OutputCaptureExtension.java index 44c7553f2..628ff9b74 100644 --- a/src/main/java/org/openrewrite/java/spring/boot2/OutputCaptureExtension.java +++ b/src/main/java/org/openrewrite/java/spring/boot2/OutputCaptureExtension.java @@ -40,8 +40,9 @@ public class OutputCaptureExtension extends Recipe { Parser.Input.fromString("package org.springframework.boot.test.system;\n" + "public interface CapturedOutput {\n" + " String getAll();\n" + - "}"), - Parser.Input.fromString("package org.junit.jupiter.api.extension.ExtendWith;\n" + + "}" + ), + Parser.Input.fromString("package org.junit.jupiter.api.extension;\n" + "public @interface ExtendWith {\n" + " Class[] value();\n" + "}") @@ -115,10 +116,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex )) ); - // We got a bug report that this import wasn't being added - // Couldn't reproduce why, assumed that type attribution failed for reasons that aren't obvious. - // Setting onlyIfReferenced to "false" just to be sure. - doAfterVisit(new AddImport<>("org.springframework.boot.test.system.OutputCaptureExtension", null, false)); + maybeAddImport("org.springframework.boot.test.system.OutputCaptureExtension"); maybeAddImport("org.junit.jupiter.api.extension.ExtendWith"); }