From a01374649e6efd08f3e7c3a342eb05ae80fd5aca Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 16 May 2024 18:49:55 +0200 Subject: [PATCH] Remove public modifiers from JUnit 5 tests --- .../mojo/buildhelper/ParseVersionTest.java | 59 ++++++++++--------- .../versioning/VersionInformationTest.java | 6 +- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java b/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java index 4ecb55b2..3cf57ff9 100644 --- a/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java +++ b/src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java @@ -32,27 +32,28 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class ParseVersionTest { - public static class TestParseVersionMojo extends ParseVersionMojo { +class ParseVersionTest { + static class TestParseVersionMojo extends ParseVersionMojo { private final Properties properties; - public TestParseVersionMojo(Properties properties) { + TestParseVersionMojo(Properties properties) { this.properties = properties; } + @Override protected void defineProperty(String name, String value) { properties.put(name, value); } } @Nested - public class TestParseVersion { + class TestParseVersion { private Properties props; private ParseVersionMojo mojo; @BeforeEach - public void beforeClass() { + void beforeClass() { props = new Properties(); mojo = new TestParseVersionMojo(props); mojo.setPropertyPrefix("parsed"); @@ -67,7 +68,7 @@ public void beforeClass() { } @Test - public void checkJunkVersion() { + void checkJunkVersion() { // Test a junk version string mojo.parseVersion("junk"); @@ -80,7 +81,7 @@ public void checkJunkVersion() { } @Test - public void checkBasicMavenVersionString() { + void checkBasicMavenVersionString() { // Test a basic maven version string mojo.parseVersion("1.0.0"); @@ -93,7 +94,7 @@ public void checkBasicMavenVersionString() { } @Test - public void checkVersionStringWithQualifier() { + void checkVersionStringWithQualifier() { // Test a version string with qualifier mojo.parseVersion("2.3.4-beta-5"); @@ -106,7 +107,7 @@ public void checkVersionStringWithQualifier() { } @Test - public void checkOSGiVersionStringWithQualifier() { + void checkOSGiVersionStringWithQualifier() { // Test an osgi version string mojo.parseVersion("2.3.4.beta_5"); @@ -119,7 +120,7 @@ public void checkOSGiVersionStringWithQualifier() { } @Test - public void checkSnapshotVersion() { + void checkSnapshotVersion() { // Test a snapshot version string mojo.parseVersion("1.2.3-SNAPSHOT"); @@ -132,7 +133,7 @@ public void checkSnapshotVersion() { } @Test - public void checkSnapshotVersion2() { + void checkSnapshotVersion2() { // Test a snapshot version string mojo.parseVersion("2.0.17-SNAPSHOT"); @@ -145,7 +146,7 @@ public void checkSnapshotVersion2() { } @Test - public void checkVersionStringWithBuildNumber() { + void checkVersionStringWithBuildNumber() { // Test a version string with a build number mojo.parseVersion("1.2.3-4"); @@ -158,7 +159,7 @@ public void checkVersionStringWithBuildNumber() { } @Test - public void checkSnapshotVersionStringWithBuildNumber() { + void checkSnapshotVersionStringWithBuildNumber() { // Test a version string with a build number mojo.parseVersion("1.2.3-4-SNAPSHOT"); @@ -178,7 +179,7 @@ class TestParseNextVersion { private ParseVersionMojo mojo; @BeforeEach - public void beforeClass() { + void beforeClass() { props = new Properties(); mojo = new TestParseVersionMojo(props); mojo.setPropertyPrefix("parsed"); @@ -192,7 +193,7 @@ public void beforeClass() { } @Test - public void checkJunkVersion() { + void checkJunkVersion() { mojo.parseVersion("junk"); assertEquals("1", props.getProperty("parsed.nextMajorVersion")); @@ -202,7 +203,7 @@ public void checkJunkVersion() { } @Test - public void testBasicMavenVersion() { + void testBasicMavenVersion() { mojo.parseVersion("1.0.0"); assertEquals("2", props.getProperty("parsed.nextMajorVersion")); @@ -212,7 +213,7 @@ public void testBasicMavenVersion() { } @Test - public void testVersionStringWithQualifier() { + void testVersionStringWithQualifier() { mojo.parseVersion("2.3.4-beta-5"); assertEquals("3", props.getProperty("parsed.nextMajorVersion")); @@ -222,7 +223,7 @@ public void testVersionStringWithQualifier() { } @Test - public void testOSGiVersion() { + void testOSGiVersion() { mojo.parseVersion("2.3.4.beta_5"); assertEquals("3", props.getProperty("parsed.nextMajorVersion")); @@ -232,7 +233,7 @@ public void testOSGiVersion() { } @Test - public void testSnapshotVersion() { + void testSnapshotVersion() { // Test a snapshot version string mojo.parseVersion("1.2.3-SNAPSHOT"); @@ -243,7 +244,7 @@ public void testSnapshotVersion() { } @Test - public void testSnapshotVersion2() { + void testSnapshotVersion2() { // Test a snapshot version string mojo.parseVersion("2.0.17-SNAPSHOT"); @@ -254,7 +255,7 @@ public void testSnapshotVersion2() { } @Test - public void testVersionStringWithBuildNumber() { + void testVersionStringWithBuildNumber() { mojo.parseVersion("1.2.3-4"); assertEquals("2", props.getProperty("parsed.nextMajorVersion")); @@ -271,7 +272,7 @@ class TestFormattedVersion { private ParseVersionMojo mojo; @BeforeEach - public void beforeClass() { + void beforeClass() { props = new Properties(); mojo = new TestParseVersionMojo(props); mojo.setPropertyPrefix("parsed"); @@ -285,7 +286,7 @@ public void beforeClass() { } @Test - public void testJunkVersion() { + void testJunkVersion() { mojo.parseVersion("junk"); assertEquals("00", props.getProperty("formatted.majorVersion")); @@ -300,7 +301,7 @@ public void testJunkVersion() { } @Test - public void testBasicMavenVersion() { + void testBasicMavenVersion() { mojo.parseVersion("1.0.0"); assertEquals("01", props.getProperty("formatted.majorVersion")); @@ -315,7 +316,7 @@ public void testBasicMavenVersion() { } @Test - public void testVersionStringWithQualifier() { + void testVersionStringWithQualifier() { mojo.parseVersion("2.3.4-beta-5"); assertEquals("02", props.getProperty("formatted.majorVersion")); @@ -330,7 +331,7 @@ public void testVersionStringWithQualifier() { } @Test - public void testOSGiVersion() { + void testOSGiVersion() { mojo.parseVersion("2.3.4.beta_5"); assertEquals("02", props.getProperty("formatted.majorVersion")); @@ -345,7 +346,7 @@ public void testOSGiVersion() { } @Test - public void testSnapshotVersion() { + void testSnapshotVersion() { // Test a snapshot version string mojo.parseVersion("1.2.3-SNAPSHOT"); @@ -361,7 +362,7 @@ public void testSnapshotVersion() { } @Test - public void testSnapshotVersion2() { + void testSnapshotVersion2() { // Test a snapshot version string mojo.parseVersion("2.0.17-SNAPSHOT"); @@ -377,7 +378,7 @@ public void testSnapshotVersion2() { } @Test - public void testVersionStringWithBuildNumber() { + void testVersionStringWithBuildNumber() { mojo.parseVersion("1.2.3-4"); assertEquals("01", props.getProperty("formatted.majorVersion")); diff --git a/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java b/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java index 664f5ec6..fa04a48f 100644 --- a/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java +++ b/src/test/java/org/codehaus/mojo/buildhelper/versioning/VersionInformationTest.java @@ -29,7 +29,7 @@ /** * @author Karl Heinz Marbaise khmarbaise@apache.org */ -public class VersionInformationTest { +class VersionInformationTest { // @formatter:off private static Object[][] createVersions() { return new Object[][] { @@ -71,7 +71,7 @@ private static Object[][] createVersions() { @ParameterizedTest @MethodSource("createVersions") - public void checkVersions(String version, int major, int minor, int patch, long buildNumber, String qualifier) { + void checkVersions(String version, int major, int minor, int patch, long buildNumber, String qualifier) { VersionInformation vi = new VersionInformation(version); assertEquals(vi.getMajor(), major); assertEquals(vi.getMinor(), minor); @@ -81,7 +81,7 @@ public void checkVersions(String version, int major, int minor, int patch, long } @Test - public void shouldFaileWithNumberFormatException() { + void shouldFaileWithNumberFormatException() { assertThrows(NumberFormatException.class, () -> new VersionInformation("999999999999.12345678.12.beta_5")); } }