Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void main(String[] args) throws RunnerException {

@Benchmark
public void changeMethodTargetToStatic(JavaCompilationUnitState state) {
new ChangeMethodTargetToStatic("org.junit.Assert assertThat(..)", "org.hamcrest.MatcherAssert", null, null)
new ChangeMethodTargetToStatic("org.junit.Assert assertThat(..)", "org.hamcrest.MatcherAssert", null, null, false)
.run(state.getSourceSet(), new InMemoryExecutionContext());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void defaults(RecipeSpec spec) {
@Test
void relocateDependency() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -71,7 +71,7 @@ void relocateDependency() {
@Test
void changeGroupIdOnly() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", null, null, null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", null, null, null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -108,7 +108,7 @@ void changeGroupIdOnly() {
@Test
void changeArtifactIdOnly() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", null, "commons-lang3", null, null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", null, "commons-lang3", null, null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -145,7 +145,7 @@ void changeArtifactIdOnly() {
@Test
void worksWithPlatform() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -180,7 +180,7 @@ implementation platform("org.apache.commons:commons-lang3:3.11")
@Test
void worksWithGString() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -217,7 +217,7 @@ implementation platform("org.apache.commons:commons-lang3:3.11")
@Test
void changeDependencyWithLowerVersionAfter() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("org.openrewrite", "plugin", "io.moderne", "moderne-gradle-plugin", "0.x", null, null)),
spec -> spec.recipe(new ChangeDependency("org.openrewrite", "plugin", "io.moderne", "moderne-gradle-plugin", "0.x", null, null, true)),
buildGradle(
"""
buildscript {
Expand Down Expand Up @@ -248,7 +248,7 @@ void changeDependencyWithLowerVersionAfter() {
@Test
void doNotPinWhenNotVersioned() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("mysql", "mysql-connector-java", "com.mysql", "mysql-connector-j", "8.0.x", null, null)),
spec -> spec.recipe(new ChangeDependency("mysql", "mysql-connector-java", "com.mysql", "mysql-connector-j", "8.0.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -287,7 +287,7 @@ void doNotPinWhenNotVersioned() {
@Test
void doNotPinWhenNotVersionedOnMap() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("mysql", "mysql-connector-java", "com.mysql", "mysql-connector-j", "8.0.x", null, null)),
spec -> spec.recipe(new ChangeDependency("mysql", "mysql-connector-java", "com.mysql", "mysql-connector-j", "8.0.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -326,7 +326,7 @@ void doNotPinWhenNotVersionedOnMap() {
@Test
void pinWhenOverrideManagedVersion() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("mysql", "mysql-connector-java", "com.mysql", "mysql-connector-j", "8.0.x", null, true)),
spec -> spec.recipe(new ChangeDependency("mysql", "mysql-connector-java", "com.mysql", "mysql-connector-j", "8.0.x", null, true, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -365,7 +365,7 @@ void pinWhenOverrideManagedVersion() {
@Test
void warPluginProvidedConfigurations() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -404,7 +404,7 @@ void warPluginProvidedConfigurations() {
@Test
void relocateDependencyInJvmTestSuite() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -453,7 +453,7 @@ void relocateDependencyInJvmTestSuite() {
@Test
void kotlinDsl() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradleKts(
"""
plugins {
Expand Down Expand Up @@ -490,7 +490,7 @@ void kotlinDsl() {
@Test
void kotlinDslStringInterpolation() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null)),
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
buildGradleKts(
"""
plugins {
Expand Down Expand Up @@ -527,7 +527,7 @@ void kotlinDslStringInterpolation() {
@Test
void dependencyPluginManagedDependencies() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("javax.validation", "validation-api", "jakarta.validation", "jakarta.validation-api", "3.0.x", null, null)),
spec -> spec.recipe(new ChangeDependency("javax.validation", "validation-api", "jakarta.validation", "jakarta.validation-api", "3.0.x", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -592,7 +592,7 @@ void dependencyPluginManagedDependencies() {
@Test
void kotlinDependencyPluginManagedDependencies() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("javax.validation", "validation-api", "jakarta.validation", "jakarta.validation-api", "3.0.x", null, null)),
spec -> spec.recipe(new ChangeDependency("javax.validation", "validation-api", "jakarta.validation", "jakarta.validation-api", "3.0.x", null, null, true)),
buildGradleKts(
"""
plugins {
Expand Down Expand Up @@ -655,7 +655,7 @@ void kotlinDependencyPluginManagedDependencies() {
@Test
void makeChangesInDependencyManagementImports() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("io.moderne.recipe", "*", "org.openrewrite", "rewrite-core", "8.44.1", null, null)),
spec -> spec.recipe(new ChangeDependency("io.moderne.recipe", "*", "org.openrewrite", "rewrite-core", "8.44.1", null, null, true)),
buildGradle(
"""
plugins {
Expand Down Expand Up @@ -700,7 +700,7 @@ implementation platform("org.openrewrite:rewrite-core")
@Test
void makeChangesInKotlinDependencyManagementImports() {
rewriteRun(
spec -> spec.recipe(new ChangeDependency("io.moderne.recipe", "*", "org.openrewrite", "rewrite-core", "8.44.1", null, null)),
spec -> spec.recipe(new ChangeDependency("io.moderne.recipe", "*", "org.openrewrite", "rewrite-core", "8.44.1", null, null, true)),
buildGradleKts(
"""
plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void changePlugin() {
void changeApplyPluginSyntax() {
rewriteRun(
spec -> spec.recipes(
new ChangeDependency("org.openrewrite", "plugin", "io.moderne", "moderne-gradle-plugin", "0.x", null, null),
new ChangeDependency("org.openrewrite", "plugin", "io.moderne", "moderne-gradle-plugin", "0.x", null, null, true),
new ChangePlugin("org.openrewrite.rewrite", "io.moderne.rewrite", null)
),
buildGradle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ChangeMethodTargetToStaticTest implements RewriteTest {
void targetToStatic() {
rewriteRun(
spec -> spec.recipes(
new ChangeMethodTargetToStatic("a.A nonStatic()", "b.B", null, null),
new ChangeMethodTargetToStatic("a.A nonStatic()", "b.B", null, null, false),
new ChangeMethodName("b.B nonStatic()", "foo", null, null)
),
java(
Expand Down Expand Up @@ -73,7 +73,7 @@ public void test() {
@Test
void staticTargetToStatic() {
rewriteRun(
spec -> spec.recipe(new ChangeMethodTargetToStatic("a.A foo()", "b.B", null, null)),
spec -> spec.recipe(new ChangeMethodTargetToStatic("a.A foo()", "b.B", null, null, false)),
java(
"""
package b;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void test() {
@Test
void targetToStaticWhenMethodHasSameName() {
rewriteRun(
spec -> spec.recipe(new ChangeMethodTargetToStatic("a.A method()", "a.A", null, null)),
spec -> spec.recipe(new ChangeMethodTargetToStatic("a.A method()", "a.A", null, null, false)),
java(
"""
package a;
Expand Down Expand Up @@ -149,7 +149,7 @@ public void test() {
@Test
void staticMethodCalledOnInstanceToCallOnClass() {
rewriteRun(
spec -> spec.recipe(new ChangeMethodTargetToStatic("a.A method()", "a.A", null, null)),
spec -> spec.recipe(new ChangeMethodTargetToStatic("a.A method()", "a.A", null, null, false)),
java(
"""
package a;
Expand Down Expand Up @@ -191,7 +191,7 @@ public void test() {
@Test
void keepImportComments() {
rewriteRun(
spec -> spec.recipe(new ChangeMethodTargetToStatic("org.codehaus.plexus.util.StringUtils isBlank(String)", "org.openrewrite.internal.StringUtils", null, null)),
spec -> spec.recipe(new ChangeMethodTargetToStatic("org.codehaus.plexus.util.StringUtils isBlank(String)", "org.openrewrite.internal.StringUtils", null, null, false)),
java(
"""
package org.codehaus.plexus.util;
Expand Down