valepakh commented on code in PR #6285: URL: https://github.com/apache/ignite-3/pull/6285#discussion_r2219683848
########## modules/core/src/test/java/org/apache/ignite/internal/properties/IgniteProductVersionTest.java: ########## @@ -95,4 +100,46 @@ void testInvalidVersions() { assertThrows(IllegalArgumentException.class, () -> IgniteProductVersion.fromString("1.2.3-")); assertThrows(IllegalArgumentException.class, () -> IgniteProductVersion.fromString("1.2.3-SNAPSHOT-alpha123")); } + + @ParameterizedTest(name = "[{index}] {0}.compareTo({1}) = {2}") + @MethodSource("versionCompareProvider") + void testCompareTo(IgniteProductVersion v1, IgniteProductVersion v2, int expected) { + assertThat(Integer.signum(v1.compareTo(v2)), is(expected)); + } + + static Stream<Arguments> versionCompareProvider() { + return Stream.of( + // major version differences + arguments(version("2.0.0"), version("3.0.0"), -1), + arguments(version("3.0.0"), version("2.0.0"), 1), + arguments(version("3.0.0"), version("3.0.0"), 0), + + // minor version differences + arguments(version("3.1.0"), version("3.2.0"), -1), + arguments(version("3.2.0"), version("3.1.0"), 1), + arguments(version("3.2.0"), version("3.2.0"), 0), + + // maintenance version differences + arguments(version("3.2.1"), version("3.2.2"), -1), + arguments(version("3.2.2"), version("3.2.1"), 1), + arguments(version("3.2.2"), version("3.2.2"), 0), + + // patch version differences + arguments(version("3.2.1.1"), version("3.2.1.2"), -1), + arguments(version("3.2.1.2"), version("3.2.1.1"), 1), + arguments(version("3.2.1.1"), version("3.2.1"), 1), + arguments(version("3.2.1"), version("3.2.1.1"), -1), + arguments(version("3.2.1.1"), version("3.2.1.1"), 0), + + // pre-release differences + arguments(version("3.2.1-alpha"), version("3.2.1-beta"), -1), + arguments(version("3.2.1-beta"), version("3.2.1-alpha"), 1), + arguments(version("3.2.1-SNAPSHOT"), version("3.2.1-SNAPSHOT"), 0), + arguments(version("3.2.1.1-SNAPSHOT"), version("3.2.1.1-SNAPSHOT"), 0) + ); + } + + private static IgniteProductVersion version(String str) { + return IgniteProductVersion.fromString(str); Review Comment: I think we can import `fromString` method statically and inline the `version` method. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org