Bukama commented on code in PR #11453:
URL: https://github.com/apache/maven/pull/11453#discussion_r2534958877
##########
impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelVersionUtilsTest.java:
##########
@@ -103,23 +104,6 @@ void shouldReturnDefaultVersionWhenModelVersionMissing()
throws Exception {
String result = ModelVersionUtils.detectModelVersion(document);
assertEquals("4.0.0", result); // Default version
}
-
- @Test
- @DisplayName("should detect version from namespace when model version
is missing")
- void shouldDetectVersionFromNamespaceWhenModelVersionMissing() throws
Exception {
Review Comment:
hmm. Guess I mixed it up with another. Restored.
##########
impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/ModelVersionUtilsTest.java:
##########
@@ -167,45 +151,61 @@ private static Stream<Arguments> provideInvalidVersions()
{
@DisplayName("Upgrade Path Validation")
class UpgradePathValidationTests {
- @Test
- @DisplayName("should validate upgrade path from 4.0.0 to 4.1.0")
- void shouldValidateUpgradePathFrom400To410() {
- assertTrue(ModelVersionUtils.canUpgrade("4.0.0", "4.1.0"));
+ @ParameterizedTest(name = "from {0} to {1}")
+ @MethodSource("provideValidPathUpgradeVersions")
+ @DisplayName("should validate upgrade path")
+ void shouldValidateUpgradePath(String from, String to) {
+ assertTrue(ModelVersionUtils.canUpgrade(from, to));
}
- @Test
- @DisplayName("should reject downgrade from 4.1.0 to 4.0.0")
- void shouldRejectDowngradeFrom410To400() {
- assertFalse(ModelVersionUtils.canUpgrade("4.1.0", "4.0.0"));
+ private static Stream<Arguments> provideValidPathUpgradeVersions() {
+ return Stream.of(
+ Arguments.of("4.0.0", "4.1.0"), Arguments.of("4.1.0",
"4.2.0"), Arguments.of("4.0.0", "4.2.0"));
}
- @Test
+ @ParameterizedTest(name = "from {0} to {1}")
+ @MethodSource("provideInvalidPathUpgradeVersions")
+ @DisplayName("should reject downgrade")
+ void shouldRejectDowngrade(String from, String to) {
+ assertFalse(ModelVersionUtils.canUpgrade(from, to));
+ }
+
+ private static Stream<Arguments> provideInvalidPathUpgradeVersions() {
+ return Stream.of(
+ Arguments.of("4.1.0", "4.0.0"), Arguments.of("4.2.0",
"4.1.0"), Arguments.of("4.2.0", "4.0.0"));
+ }
+
+ @ParameterizedTest(name = "from {0} to {0}")
+ @ValueSource(strings = {"4.0.0", "4.1.0", "4.2.0"})
@DisplayName("should reject upgrade to same version")
- void shouldRejectUpgradeToSameVersion() {
- assertFalse(ModelVersionUtils.canUpgrade("4.0.0", "4.0.0"));
- assertFalse(ModelVersionUtils.canUpgrade("4.1.0", "4.1.0"));
+ void shouldRejectUpgradeToSameVersion(String version) {
+ assertFalse(ModelVersionUtils.canUpgrade(version, version));
}
- @Test
+ @ParameterizedTest(name = "from {0}")
+ @ValueSource(strings = {"3.0.0", "5.0.0"})
@DisplayName("should reject upgrade from unsupported version")
- void shouldRejectUpgradeFromUnsupportedVersion() {
- assertFalse(ModelVersionUtils.canUpgrade("3.0.0", "4.1.0"));
- assertFalse(ModelVersionUtils.canUpgrade("5.0.0", "4.1.0"));
+ void shouldRejectUpgradeFromUnsupportedVersion(String
unsupportedVersion) {
+ assertFalse(ModelVersionUtils.canUpgrade(unsupportedVersion,
"4.1.0"));
}
- @Test
+ @ParameterizedTest(name = "to {0}")
+ @ValueSource(strings = {"3.0.0", "5.0.0"})
@DisplayName("should reject upgrade to unsupported version")
- void shouldRejectUpgradeToUnsupportedVersion() {
- assertFalse(ModelVersionUtils.canUpgrade("4.0.0", "3.0.0"));
- assertFalse(ModelVersionUtils.canUpgrade("4.0.0", "5.0.0"));
+ void shouldRejectUpgradeToUnsupportedVersion(String
unsupportedVersion) {
+ assertFalse(ModelVersionUtils.canUpgrade("4.0.0",
unsupportedVersion));
+ assertFalse(ModelVersionUtils.canUpgrade("4.0.0",
unsupportedVersion));
Review Comment:
thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]