Skip to content

Commit

Permalink
Remove public modifiers from JUnit 5 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed May 16, 2024
1 parent f21a027 commit b99f6be
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
59 changes: 30 additions & 29 deletions src/test/java/org/codehaus/mojo/buildhelper/ParseVersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -67,7 +68,7 @@ public void beforeClass() {
}

@Test
public void checkJunkVersion() {
void checkJunkVersion() {
// Test a junk version string
mojo.parseVersion("junk");

Expand All @@ -80,7 +81,7 @@ public void checkJunkVersion() {
}

@Test
public void checkBasicMavenVersionString() {
void checkBasicMavenVersionString() {
// Test a basic maven version string
mojo.parseVersion("1.0.0");

Expand All @@ -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");

Expand All @@ -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");

Expand All @@ -119,7 +120,7 @@ public void checkOSGiVersionStringWithQualifier() {
}

@Test
public void checkSnapshotVersion() {
void checkSnapshotVersion() {
// Test a snapshot version string
mojo.parseVersion("1.2.3-SNAPSHOT");

Expand All @@ -132,7 +133,7 @@ public void checkSnapshotVersion() {
}

@Test
public void checkSnapshotVersion2() {
void checkSnapshotVersion2() {
// Test a snapshot version string
mojo.parseVersion("2.0.17-SNAPSHOT");

Expand All @@ -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");

Expand All @@ -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");

Expand All @@ -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");
Expand All @@ -192,7 +193,7 @@ public void beforeClass() {
}

@Test
public void checkJunkVersion() {
void checkJunkVersion() {
mojo.parseVersion("junk");

assertEquals("1", props.getProperty("parsed.nextMajorVersion"));
Expand All @@ -202,7 +203,7 @@ public void checkJunkVersion() {
}

@Test
public void testBasicMavenVersion() {
void testBasicMavenVersion() {
mojo.parseVersion("1.0.0");

assertEquals("2", props.getProperty("parsed.nextMajorVersion"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand All @@ -232,7 +233,7 @@ public void testOSGiVersion() {
}

@Test
public void testSnapshotVersion() {
void testSnapshotVersion() {
// Test a snapshot version string
mojo.parseVersion("1.2.3-SNAPSHOT");

Expand All @@ -243,7 +244,7 @@ public void testSnapshotVersion() {
}

@Test
public void testSnapshotVersion2() {
void testSnapshotVersion2() {
// Test a snapshot version string
mojo.parseVersion("2.0.17-SNAPSHOT");

Expand All @@ -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"));
Expand All @@ -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");
Expand All @@ -285,7 +286,7 @@ public void beforeClass() {
}

@Test
public void testJunkVersion() {
void testJunkVersion() {
mojo.parseVersion("junk");

assertEquals("00", props.getProperty("formatted.majorVersion"));
Expand All @@ -300,7 +301,7 @@ public void testJunkVersion() {
}

@Test
public void testBasicMavenVersion() {
void testBasicMavenVersion() {
mojo.parseVersion("1.0.0");

assertEquals("01", props.getProperty("formatted.majorVersion"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand All @@ -345,7 +346,7 @@ public void testOSGiVersion() {
}

@Test
public void testSnapshotVersion() {
void testSnapshotVersion() {
// Test a snapshot version string
mojo.parseVersion("1.2.3-SNAPSHOT");

Expand All @@ -361,7 +362,7 @@ public void testSnapshotVersion() {
}

@Test
public void testSnapshotVersion2() {
void testSnapshotVersion2() {
// Test a snapshot version string
mojo.parseVersion("2.0.17-SNAPSHOT");

Expand All @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* @author Karl Heinz Marbaise <a href="mailto:khmarbaise@apache.org">khmarbaise@apache.org</a>
*/
public class VersionInformationTest {
class VersionInformationTest {
// @formatter:off
private static Object[][] createVersions() {
return new Object[][] {
Expand Down Expand Up @@ -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);
Expand All @@ -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"));
}
}

0 comments on commit b99f6be

Please sign in to comment.