From 7206af04391125d339145555df8649a02dc022d6 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 2 Nov 2025 23:14:53 +0000 Subject: [PATCH] JUnit Jupiter best practices Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.testing.junit.JupiterBestPractices?organizationId=YTA5ODhiOTYtNDI5OS00OGY3LTg0NjctNGZiNmI4OTY1ZjY3 Co-authored-by: Moderne --- .../maven/plugins/source/SourceJarMojoTest.java | 14 +++++++------- .../plugins/source/TestSourceJarMojoTest.java | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java b/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java index faed337..7b2e1a3 100644 --- a/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java @@ -45,7 +45,7 @@ * @author Maria Odea Ching */ @MojoTest -public class SourceJarMojoTest extends AbstractSourcePluginTestCase { +class SourceJarMojoTest extends AbstractSourcePluginTestCase { private String[] addMavenDescriptor(String project, String... listOfElements) { final String metainf = "META-INF/"; @@ -65,7 +65,7 @@ private String[] addMavenDescriptor(String project, String... listOfElements) { @InjectMojo(goal = "jar") @Basedir("${basedir}/target/test-classes/unit/project-001") @MojoParameter(name = "classifier", value = "sources") - void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { + void defaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); @@ -85,7 +85,7 @@ void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { @Test @InjectMojo(goal = "jar") @Basedir("${basedir}/target/test-classes/unit/project-003") - public void testExcludes(AbstractSourceJarMojo mojo) throws Exception { + void excludes(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); @@ -105,7 +105,7 @@ public void testExcludes(AbstractSourceJarMojo mojo) throws Exception { @Test @InjectMojo(goal = "jar") @Basedir("${basedir}/target/test-classes/unit/project-005") - public void testNoSources(AbstractSourceJarMojo mojo) throws Exception { + void noSources(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); // Now make sure that no archive got created @@ -118,7 +118,7 @@ public void testNoSources(AbstractSourceJarMojo mojo) throws Exception { @Test @InjectMojo(goal = "jar") @Basedir("${basedir}/target/test-classes/unit/project-007") - public void testIncludes(AbstractSourceJarMojo mojo) throws Exception { + void includes(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); @@ -139,7 +139,7 @@ public void testIncludes(AbstractSourceJarMojo mojo) throws Exception { @Test @InjectMojo(goal = "jar") @Basedir("${basedir}/target/test-classes/unit/project-009") - public void testIncludePom(AbstractSourceJarMojo mojo) throws Exception { + void includePom(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); @@ -160,7 +160,7 @@ public void testIncludePom(AbstractSourceJarMojo mojo) throws Exception { @Test @InjectMojo(goal = "jar") @Basedir("${basedir}/target/test-classes/unit/project-010") - public void testIncludeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) throws Exception { + void includeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); diff --git a/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java b/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java index e0bc5fe..980ccc2 100644 --- a/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/source/TestSourceJarMojoTest.java @@ -45,13 +45,13 @@ * @author Maria Odea Ching */ @MojoTest -public class TestSourceJarMojoTest extends AbstractSourcePluginTestCase { +class TestSourceJarMojoTest extends AbstractSourcePluginTestCase { @Test @InjectMojo(goal = "test-jar") @Basedir("${basedir}/target/test-classes/unit/project-001") @MojoParameter(name = "classifier", value = "test-sources") - public void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { + void defaultConfiguration(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); @@ -75,7 +75,7 @@ public void testDefaultConfiguration(AbstractSourceJarMojo mojo) throws Exceptio @InjectMojo(goal = "test-jar") @Basedir("${basedir}/target/test-classes/unit/project-003") @MojoParameter(name = "classifier", value = "test-sources") - public void testExcludes(AbstractSourceJarMojo mojo) throws Exception { + void excludes(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target"); @@ -99,7 +99,7 @@ public void testExcludes(AbstractSourceJarMojo mojo) throws Exception { @InjectMojo(goal = "test-jar") @Basedir("${basedir}/target/test-classes/unit/project-005") @MojoParameter(name = "classifier", value = "test-sources") - public void testNoSources(AbstractSourceJarMojo mojo) throws Exception { + void noSources(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); // Now make sure that no archive got created @@ -113,7 +113,7 @@ public void testNoSources(AbstractSourceJarMojo mojo) throws Exception { @InjectMojo(goal = "test-jar") @Basedir("${basedir}/target/test-classes/unit/project-010") @MojoParameter(name = "classifier", value = "test-sources") - public void testIncludeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) throws Exception { + void includeMavenDescriptorWhenExplicitlyConfigured(AbstractSourceJarMojo mojo) throws Exception { mojo.execute(); File target = new File(getBasedir(), "target");