From 9f90cf1cd24b4e9911495c634d68260d710429d2 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 6 Feb 2023 22:22:27 +0000 Subject: [PATCH 1/3] refactor: Remove `public` visibility of JUnit 5 tests Partial fix for #496 Co-authored-by: Moderne --- .../java/org/openrewrite/maven/AbstractRewriteMojoTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/openrewrite/maven/AbstractRewriteMojoTest.java b/src/test/java/org/openrewrite/maven/AbstractRewriteMojoTest.java index a2a4204a..83c0f900 100644 --- a/src/test/java/org/openrewrite/maven/AbstractRewriteMojoTest.java +++ b/src/test/java/org/openrewrite/maven/AbstractRewriteMojoTest.java @@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; -public class AbstractRewriteMojoTest { +class AbstractRewriteMojoTest { @ParameterizedTest @ValueSource(strings = {"rewrite.yml", "https://httpstat.us/200"}) @@ -32,7 +32,7 @@ public void execute() { } }; - if(!loc.startsWith("http")) { + if (!loc.startsWith("http")) { Files.write(temp.resolve(loc), "rewrite".getBytes(StandardCharsets.UTF_8)); } From 72396a4a101137bc71cacc1ac11c09eab0e0c6cb Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 6 Feb 2023 23:27:15 +0100 Subject: [PATCH 2/3] Remove public modifier from IT classes Also remove unused imports --- src/test/java/org/openrewrite/maven/BasicIT.java | 3 +-- src/test/java/org/openrewrite/maven/ConfigureMojoIT.java | 2 +- .../org/openrewrite/maven/ConfigureMojoITNoActiveRecipe.java | 4 +--- src/test/java/org/openrewrite/maven/InitMojoIT.java | 2 +- src/test/java/org/openrewrite/maven/RemoveMojoIT.java | 2 +- src/test/java/org/openrewrite/maven/RewriteCycloneDxIT.java | 2 +- src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java | 2 +- src/test/java/org/openrewrite/maven/RewriteDryRunIT.java | 2 +- src/test/java/org/openrewrite/maven/RewriteRunIT.java | 2 +- 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/openrewrite/maven/BasicIT.java b/src/test/java/org/openrewrite/maven/BasicIT.java index e6bd4414..cea8e23c 100644 --- a/src/test/java/org/openrewrite/maven/BasicIT.java +++ b/src/test/java/org/openrewrite/maven/BasicIT.java @@ -2,14 +2,13 @@ import com.soebes.itf.jupiter.extension.*; import com.soebes.itf.jupiter.maven.MavenExecutionResult; -import org.junit.jupiter.api.Disabled; import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat; @MavenJupiterExtension @MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) @SuppressWarnings("NewClassNamingConvention") -public class BasicIT { +class BasicIT { @MavenTest void groupid_artifactid_should_be_ok(MavenExecutionResult result) { diff --git a/src/test/java/org/openrewrite/maven/ConfigureMojoIT.java b/src/test/java/org/openrewrite/maven/ConfigureMojoIT.java index 55e5725c..19e25a10 100644 --- a/src/test/java/org/openrewrite/maven/ConfigureMojoIT.java +++ b/src/test/java/org/openrewrite/maven/ConfigureMojoIT.java @@ -13,7 +13,7 @@ @SystemProperty(value = "dependencies", content = "org.openrewrite.recipe:rewrite-spring:4.14.1") }) @SuppressWarnings("NewClassNamingConvention") -public class ConfigureMojoIT { +class ConfigureMojoIT { @MavenTest void single_project(MavenExecutionResult result) { diff --git a/src/test/java/org/openrewrite/maven/ConfigureMojoITNoActiveRecipe.java b/src/test/java/org/openrewrite/maven/ConfigureMojoITNoActiveRecipe.java index bff33675..f2b8f4d6 100644 --- a/src/test/java/org/openrewrite/maven/ConfigureMojoITNoActiveRecipe.java +++ b/src/test/java/org/openrewrite/maven/ConfigureMojoITNoActiveRecipe.java @@ -5,8 +5,6 @@ import com.soebes.itf.jupiter.extension.MavenJupiterExtension; import com.soebes.itf.jupiter.extension.MavenOption; import com.soebes.itf.jupiter.extension.MavenTest; -import com.soebes.itf.jupiter.extension.SystemProperties; -import com.soebes.itf.jupiter.extension.SystemProperty; import com.soebes.itf.jupiter.maven.MavenExecutionResult; import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat; @@ -15,7 +13,7 @@ @MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover") @SuppressWarnings("NewClassNamingConvention") -public class ConfigureMojoITNoActiveRecipe { +class ConfigureMojoITNoActiveRecipe { @MavenTest void single_project(MavenExecutionResult result) { diff --git a/src/test/java/org/openrewrite/maven/InitMojoIT.java b/src/test/java/org/openrewrite/maven/InitMojoIT.java index 5858935c..37c07a0a 100644 --- a/src/test/java/org/openrewrite/maven/InitMojoIT.java +++ b/src/test/java/org/openrewrite/maven/InitMojoIT.java @@ -14,7 +14,7 @@ @SystemProperty(value = "rootOnly", content = "false") }) @SuppressWarnings("NewClassNamingConvention") -public class InitMojoIT { +class InitMojoIT { @MavenTest void single_project(MavenExecutionResult result) { diff --git a/src/test/java/org/openrewrite/maven/RemoveMojoIT.java b/src/test/java/org/openrewrite/maven/RemoveMojoIT.java index c4abd5f8..8f39d2da 100644 --- a/src/test/java/org/openrewrite/maven/RemoveMojoIT.java +++ b/src/test/java/org/openrewrite/maven/RemoveMojoIT.java @@ -9,7 +9,7 @@ @MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:remove") @SuppressWarnings("NewClassNamingConvention") -public class RemoveMojoIT { +class RemoveMojoIT { @MavenTest void single_project(MavenExecutionResult result) { diff --git a/src/test/java/org/openrewrite/maven/RewriteCycloneDxIT.java b/src/test/java/org/openrewrite/maven/RewriteCycloneDxIT.java index b2a965e1..2bee0d37 100644 --- a/src/test/java/org/openrewrite/maven/RewriteCycloneDxIT.java +++ b/src/test/java/org/openrewrite/maven/RewriteCycloneDxIT.java @@ -10,7 +10,7 @@ @MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:cyclonedx") @SuppressWarnings("NewClassNamingConvention") -public class RewriteCycloneDxIT { +class RewriteCycloneDxIT { @MavenTest @Disabled("module b consistently fails to resolve the locally-built artifact a due to aether resolution errors") diff --git a/src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java b/src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java index 4be16e81..8a33b9b4 100644 --- a/src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java +++ b/src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java @@ -10,7 +10,7 @@ @MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover") @SuppressWarnings("NewClassNamingConvention") -public class RewriteDiscoverIT { +class RewriteDiscoverIT { @Nested @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover") diff --git a/src/test/java/org/openrewrite/maven/RewriteDryRunIT.java b/src/test/java/org/openrewrite/maven/RewriteDryRunIT.java index 9dc2e4ce..906fbda0 100644 --- a/src/test/java/org/openrewrite/maven/RewriteDryRunIT.java +++ b/src/test/java/org/openrewrite/maven/RewriteDryRunIT.java @@ -9,7 +9,7 @@ @MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) @MavenOption(MavenCLIOptions.DEBUG) @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:dryRun") -public class RewriteDryRunIT { +class RewriteDryRunIT { @MavenTest void fail_on_dry_run(MavenExecutionResult result) { diff --git a/src/test/java/org/openrewrite/maven/RewriteRunIT.java b/src/test/java/org/openrewrite/maven/RewriteRunIT.java index d2de8d52..e2fb0a91 100644 --- a/src/test/java/org/openrewrite/maven/RewriteRunIT.java +++ b/src/test/java/org/openrewrite/maven/RewriteRunIT.java @@ -12,7 +12,7 @@ @DisabledOnOs(OS.WINDOWS) @MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:run") @SuppressWarnings("NewClassNamingConvention") -public class RewriteRunIT { +class RewriteRunIT { @MavenTest void multi_module_project(MavenExecutionResult result) { From b9c00087410f02cc9f77e220da0ac61b981000cf Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 6 Feb 2023 23:30:14 +0100 Subject: [PATCH 3/3] Restore DiscoverNoActiveRecipeIT after failed local merge --- .../maven/DiscoverNoActiveRecipeIT.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/test/java/org/openrewrite/maven/DiscoverNoActiveRecipeIT.java diff --git a/src/test/java/org/openrewrite/maven/DiscoverNoActiveRecipeIT.java b/src/test/java/org/openrewrite/maven/DiscoverNoActiveRecipeIT.java new file mode 100644 index 00000000..24292a1e --- /dev/null +++ b/src/test/java/org/openrewrite/maven/DiscoverNoActiveRecipeIT.java @@ -0,0 +1,25 @@ +package org.openrewrite.maven; + +import com.soebes.itf.jupiter.extension.MavenCLIOptions; +import com.soebes.itf.jupiter.extension.MavenGoal; +import com.soebes.itf.jupiter.extension.MavenJupiterExtension; +import com.soebes.itf.jupiter.extension.MavenOption; +import com.soebes.itf.jupiter.extension.MavenTest; +import com.soebes.itf.jupiter.maven.MavenExecutionResult; + +import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat; + +@MavenJupiterExtension +@MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS) +@MavenGoal("${project.groupId}:${project.artifactId}:${project.version}:discover") +class DiscoverNoActiveRecipeIT { + + @MavenTest + void single_project(MavenExecutionResult result) { + assertThat(result) + .isSuccessful() + .out() + .error() + .noneSatisfy(line -> assertThat(line).contains("Could not find recipe 'null' among available recipes")); + } +}