diff --git a/build.gradle.kts b/build.gradle.kts index d5abd96..702004b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,20 +37,6 @@ dependencies { runtimeOnly("software.amazon.awssdk:v2-migration:latest.release") runtimeOnly("tech.picnic.error-prone-support:error-prone-contrib:${rewriteVersion}:recipes") - // error-prone-contrib only has provided dependencies, whereas the platform needs these on the classpath at runtime - runtimeOnly("org.junit.jupiter:junit-jupiter-api:5.+") - runtimeOnly("org.assertj:assertj-core:latest.release") - runtimeOnly(platform("org.springframework:spring-framework-bom:5.3.39")) // Necessary for Java 8 compatibility - runtimeOnly("org.springframework:spring-context") - runtimeOnly("org.springframework:spring-test") - runtimeOnly("org.springframework:spring-web") - runtimeOnly("org.springframework:spring-webflux") - runtimeOnly("org.testng:testng:7.5") - runtimeOnly("io.projectreactor:reactor-core:latest.release") - runtimeOnly("io.projectreactor:reactor-test:latest.release") - runtimeOnly("io.projectreactor.addons:reactor-adapter:latest.release") - runtimeOnly("io.projectreactor.addons:reactor-extra:latest.release") - testImplementation("org.openrewrite:rewrite-java") testImplementation("org.openrewrite:rewrite-test") @@ -62,6 +48,30 @@ dependencies { testRuntimeOnly("org.gradle:gradle-tooling-api:latest.release") } +recipeDependencies { + // error-prone-contrib only has provided dependencies, whereas the platform needs these on the classpath at runtime + parserClasspath("com.fasterxml.jackson.core:jackson-core:2.+") + parserClasspath("com.fasterxml.jackson.core:jackson-databind:2.+") + parserClasspath("com.github.ben-manes.caffeine:caffeine:3.+") + parserClasspath("com.google.guava:guava:33.+") + parserClasspath("org.jspecify:jspecify:1.+") + parserClasspath("org.junit.jupiter:junit-jupiter-api:5.+") + parserClasspath("org.assertj:assertj-core:3.+") + parserClasspath("org.mockito:mockito-core:5.+") + parserClasspath("org.reactivestreams:reactive-streams:1.+") + parserClasspath("org.springframework:spring-context:6.+") + parserClasspath("org.springframework:spring-test:6.+") + parserClasspath("org.springframework:spring-web:6.+") + parserClasspath("org.springframework:spring-webflux:6.+") + parserClasspath("org.testng:testng:7.+") + parserClasspath("io.micrometer:micrometer-core:1.+") + parserClasspath("io.projectreactor:reactor-core:3.+") + parserClasspath("io.projectreactor:reactor-test:3.+") + parserClasspath("io.projectreactor.addons:reactor-adapter:3.+") + parserClasspath("io.projectreactor.addons:reactor-extra:3.+") + parserClasspath("io.reactivex.rxjava2:rxjava:2.+") +} + // ./gradlew shadowJar tasks.withType { archiveClassifier.set("") diff --git a/src/main/resources/META-INF/rewrite/classpath.tsv.gz b/src/main/resources/META-INF/rewrite/classpath.tsv.gz new file mode 100644 index 0000000..9cf3d3d Binary files /dev/null and b/src/main/resources/META-INF/rewrite/classpath.tsv.gz differ diff --git a/src/test/java/org/openrewrite/recipe/quarkus/internal/AggregateQuarkusUpdatesTest.java b/src/test/java/org/openrewrite/recipe/quarkus/internal/AggregateQuarkusUpdatesTest.java index 212ebc4..1c6a4d9 100644 --- a/src/test/java/org/openrewrite/recipe/quarkus/internal/AggregateQuarkusUpdatesTest.java +++ b/src/test/java/org/openrewrite/recipe/quarkus/internal/AggregateQuarkusUpdatesTest.java @@ -72,7 +72,7 @@ void minoSkipsUpdateProperties() { void readRecipesFromCamlQuarkusModule() throws Exception { Path camelQuarkusDir = Path.of("quarkus-updates/recipes/src/main/resources/quarkus-updates/org.apache.camel.quarkus"); assertThat(recipesDefinedInQuarkusRepo(camelQuarkusDir)) - .containsExactlyInAnyOrderEntriesOf( + .containsAllEntriesOf( Map.of( new AggregateQuarkusUpdates.Version(3, 0, 0), List.of("io.quarkus.updates.camel.camel40.CamelQuarkusMigrationRecipe", "org.openrewrite.java.camel.migrate.removedExtensions"), new AggregateQuarkusUpdates.Version(3, 8, 0), List.of("io.quarkus.updates.camel.camel44.CamelQuarkusMigrationRecipe"), diff --git a/src/test/java/tech/picnic/errorprone/refasterrules/AssertJStringRulesRecipesTest.java b/src/test/java/tech/picnic/errorprone/refasterrules/AssertJStringRulesRecipesTest.java new file mode 100644 index 0000000..2ae4f19 --- /dev/null +++ b/src/test/java/tech/picnic/errorprone/refasterrules/AssertJStringRulesRecipesTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package tech.picnic.errorprone.refasterrules; + +import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; +import org.openrewrite.InMemoryExecutionContext; +import org.openrewrite.java.JavaParser; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.java.Assertions.java; + +class AssertJStringRulesRecipesTest implements RewriteTest { + @Override + public void defaults(RecipeSpec spec) { + spec + .parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "assertj-core-3")) + .recipe(new AssertJStringRulesRecipes()); + } + + @DocumentExample + @Test + void assertThatStringIsEmpty() { + //language=java + rewriteRun( + java( + """ + import static org.assertj.core.api.Assertions.assertThat; + + class Test { + void test(String actual) { + assertThat(actual).isEqualTo(""); + } + } + """, + """ + import static org.assertj.core.api.Assertions.assertThat; + + class Test { + void test(String actual) { + assertThat(actual).isEmpty(); + } + } + """ + ) + ); + } +}