diff --git a/src/main/java/org/openrewrite/java/spring/RenameBean.java b/src/main/java/org/openrewrite/java/spring/RenameBean.java index 6b74ae7cf..04a65ef3b 100644 --- a/src/main/java/org/openrewrite/java/spring/RenameBean.java +++ b/src/main/java/org/openrewrite/java/spring/RenameBean.java @@ -143,7 +143,7 @@ private static BeanSearchResult isBean(Collection annotations, Set private static boolean anyAnnotationMatches(J.Annotation type, Set types) { for (String it : types) { - if (!FindAnnotations.find(type, it, true).isEmpty()) { + if (!FindAnnotations.find(type, '@' + it, true).isEmpty()) { return true; } } diff --git a/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/NoAutowiredOnConstructorTest.java b/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/NoAutowiredOnConstructorTest.java index 7c19895a4..6d9475507 100644 --- a/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/NoAutowiredOnConstructorTest.java +++ b/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/NoAutowiredOnConstructorTest.java @@ -29,7 +29,7 @@ class NoAutowiredOnConstructorTest implements RewriteTest { @Override public void defaults(RecipeSpec spec) { spec.recipe(new NoAutowiredOnConstructor()) - .parser(JavaParser.fromJavaVersion().classpath("spring-beans")); + .parser(JavaParser.fromJavaVersion().classpath("spring-beans", "spring-context", "spring-core")); } @Issue("https://github.com/openrewrite/rewrite-spring/issues/78") @@ -524,11 +524,12 @@ void noAutowiredAnnotations() { rewriteRun( java( """ + import org.springframework.context.annotation.Primary; import javax.sql.DataSource; public class DatabaseConfiguration { private final DataSource dataSource; - + @Primary public DatabaseConfiguration(DataSource dataSource) { } diff --git a/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedConditionTest.java b/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedConditionTest.java index 92961cfcb..82398da82 100644 --- a/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedConditionTest.java +++ b/src/testWithSpringBoot_1_5/java/org/openrewrite/java/spring/boot2/ConditionalOnBeanAnyNestedConditionTest.java @@ -37,6 +37,11 @@ public void defaults(RecipeSpec spec) { void conditionalAnnotationSingleClassCandidateNoChange() { //language=java rewriteRun( + spec -> spec.typeValidationOptions(TypeValidation.builder() + .methodDeclarations(false) + .constructorInvocations(false) + .identifiers(false) + .build()), java( """ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; diff --git a/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/NoRequestMappingAnnotationTest.java b/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/NoRequestMappingAnnotationTest.java index a4fe16e30..1f2e07923 100644 --- a/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/NoRequestMappingAnnotationTest.java +++ b/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/NoRequestMappingAnnotationTest.java @@ -235,6 +235,7 @@ void requestMappingWithMultipleMethods() { import java.util.*; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; + import org.springframework.web.bind.annotation.RestController; import static org.springframework.web.bind.annotation.RequestMethod.GET; import static org.springframework.web.bind.annotation.RequestMethod.HEAD; diff --git a/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/boot2/LegacyHttpSecurityTest.java b/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/boot2/LegacyHttpSecurityTest.java index 1e5ec0bda..c3c2604fd 100644 --- a/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/boot2/LegacyHttpSecurityTest.java +++ b/src/testWithSpringBoot_2_1/java/org/openrewrite/java/spring/boot2/LegacyHttpSecurityTest.java @@ -19,6 +19,7 @@ import org.openrewrite.java.JavaParser; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; +import org.openrewrite.test.TypeValidation; import static org.openrewrite.java.Assertions.java; @@ -34,6 +35,7 @@ public void defaults(RecipeSpec spec) { void dontUseUnavailableMethods() { //language=java rewriteRun( + spec -> spec.typeValidationOptions(TypeValidation.none()), java( """ import org.springframework.security.config.annotation.web.builders.HttpSecurity;