-
Notifications
You must be signed in to change notification settings - Fork 27
Update dependencies #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
s-yonkov-yonkov
wants to merge
5
commits into
master
Choose a base branch
from
update-dependencies
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Update dependencies #331
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4693013
update dependencies and refactor code (#323)
s-yonkov-yonkov fff8a4a
small fixes on dependency sources (#324)
s-yonkov-yonkov 30b1a65
update dependencies (#327)
s-yonkov-yonkov cc32f90
add small version updates
s-yonkov-yonkov 6ed8eb6
add more updates
s-yonkov-yonkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,12 @@ | |
|
|
||
| import org.cloudfoundry.multiapps.common.ParsingException; | ||
| import org.cloudfoundry.multiapps.mta.Messages; | ||
| import org.cloudfoundry.multiapps.mta.parsers.PartialVersionConverter; | ||
|
|
||
| import com.vdurmont.semver4j.Semver; | ||
| import com.vdurmont.semver4j.Semver.SemverType; | ||
| import com.vdurmont.semver4j.SemverException; | ||
| import org.semver4j.Semver; | ||
| import org.semver4j.SemverException; | ||
|
|
||
| public class Version implements Comparable<Version> { | ||
|
|
||
| private static final PartialVersionConverter PARTIAL_VERSION_CONVERTER = new PartialVersionConverter(); | ||
|
|
||
| private final Semver version; | ||
|
|
||
| private Version(Semver version) { | ||
|
|
@@ -32,21 +28,12 @@ public int getPatch() { | |
| return version.getPatch(); | ||
| } | ||
|
|
||
| public String getBuild() { | ||
| return version.getBuild(); | ||
| } | ||
|
|
||
| public String[] getSuffixTokens() { | ||
| return version.getSuffixTokens(); | ||
| } | ||
|
|
||
| public static Version parseVersion(String versionString) { | ||
| try { | ||
| String fullVersionString = PARTIAL_VERSION_CONVERTER.convertToFullVersionString(versionString); | ||
| return new Version(new Semver(fullVersionString, SemverType.NPM)); | ||
| } catch (SemverException e) { | ||
| throw new ParsingException(e, Messages.UNABLE_TO_PARSE_VERSION, versionString); | ||
| var version = Semver.coerce(versionString); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. were there some issues with semver or it was only reverted because of spring? |
||
| if (version == null) { | ||
| throw new ParsingException(MessageFormat.format(Messages.UNABLE_TO_PARSE_VERSION, versionString)); | ||
| } | ||
| return new Version(version); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -56,7 +43,7 @@ public int hashCode() { | |
|
|
||
| @Override | ||
| public String toString() { | ||
| return version.getValue(); | ||
| return version.toString(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -81,7 +68,8 @@ public boolean equals(Object obj) { | |
|
|
||
| public boolean satisfies(String requirement) { | ||
| try { | ||
| return version.satisfies(requirement); | ||
| // The second parameter is preventing the default behavior of Semver to treat the suffix as a pre-release tag. | ||
| return version.satisfies(requirement, true); | ||
| } catch (SemverException e) { | ||
| throw new IllegalArgumentException(MessageFormat.format(Messages.UNABLE_TO_PARSE_VERSION_REQUIREMENT, requirement)); | ||
| } | ||
|
|
||
48 changes: 0 additions & 48 deletions
48
...pps-mta/src/main/java/org/cloudfoundry/multiapps/mta/parsers/PartialVersionConverter.java
This file was deleted.
Oops, something went wrong.
205 changes: 205 additions & 0 deletions
205
multiapps-mta/src/test/java/org/cloudfoundry/multiapps/mta/model/VersionTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| package org.cloudfoundry.multiapps.mta.model; | ||
|
|
||
| import java.util.stream.Stream; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Nested; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| class VersionTest { | ||
|
|
||
| private static final String UNABLE_TO_PARSE_VERSION = "Unable to parse version"; | ||
|
|
||
| // --------------------------------------------------------------------------------------------- | ||
| // PARSING AND NORMALIZATION TESTS | ||
| // --------------------------------------------------------------------------------------------- | ||
| @Nested | ||
| @DisplayName("parseVersion() and normalization behavior") | ||
| class ParseVersionTests { | ||
|
|
||
| @Test | ||
| @DisplayName("should parse complex versions with build metadata and timestamps") | ||
| void testParseComplexVersions() { | ||
| Version v1 = Version.parseVersion("0.0.1-20251105063220+e303076b5d51da7f0f3a10cd69de018ac0a3853d"); | ||
| Version v2 = Version.parseVersion("1.2.0-20251105043948+cb754700fb069b3367c869938ac6beb396c800e4"); | ||
| Version v3 = Version.parseVersion("1.0.0-SNAPSHOT-20240116224612+200df4832787863cc2f94d998c6cbcd711518933"); | ||
|
|
||
| assertNotNull(v1); | ||
| assertNotNull(v2); | ||
| assertNotNull(v3); | ||
|
|
||
| assertVersionParts(v1, 0, 0, 1); | ||
| assertVersionParts(v2, 1, 2, 0); | ||
| assertVersionParts(v3, 1, 0, 0); | ||
| } | ||
|
|
||
| private void assertVersionParts(Version version, int major, int minor, int patch) { | ||
| assertEquals(major, version.getMajor()); | ||
| assertEquals(minor, version.getMinor()); | ||
| assertEquals(patch, version.getPatch()); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "Partial version \"{0}\" should normalize to \"{1}\"") | ||
| @MethodSource | ||
| void testNormalizePartialVersions(String input, String expected) { | ||
| Version version = Version.parseVersion(input); | ||
| assertEquals(expected, version.toString()); | ||
| } | ||
|
|
||
| static Stream<Arguments> testNormalizePartialVersions() { | ||
| return Stream.of( | ||
| Arguments.of("1.0.0", "1.0.0"), | ||
| Arguments.of("2.1", "2.1.0"), | ||
| Arguments.of("2", "2.0.0"), | ||
| Arguments.of("1.9.0-SNAPSHOT", "1.9.0-SNAPSHOT"), | ||
| Arguments.of("1.9-SNAPSHOT", "1.9.0"), | ||
| Arguments.of("1-SNAPSHOT", "1.0.0"), | ||
| Arguments.of("1.2.0-beta+exp.sha.5114f85", "1.2.0-beta+exp.sha.5114f85"), | ||
| Arguments.of("1.2-beta+exp.sha.5114f85", "1.2.0"), | ||
| Arguments.of("1-beta+exp.sha.5114f85", "1.0.0"), | ||
| Arguments.of("v1.2.3", "1.2.3") | ||
| ); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "Invalid version \"{0}\" should throw SemverException or ParsingException") | ||
| @MethodSource | ||
| void testInvalidVersions(String invalid, String expectedMessage) { | ||
| Exception ex = assertThrows(Exception.class, () -> Version.parseVersion(invalid)); | ||
| assertTrue(ex.getMessage() | ||
| .contains(expectedMessage)); | ||
| } | ||
|
|
||
| static Stream<Arguments> testInvalidVersions() { | ||
| return Stream.of( | ||
| Arguments.of("a.b.c", UNABLE_TO_PARSE_VERSION), | ||
| Arguments.of("", UNABLE_TO_PARSE_VERSION), | ||
| Arguments.of("null", UNABLE_TO_PARSE_VERSION), | ||
| Arguments.of("not-a-version", UNABLE_TO_PARSE_VERSION) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // --------------------------------------------------------------------------------------------- | ||
| // COMPARISON AND EQUALITY TESTS | ||
| // --------------------------------------------------------------------------------------------- | ||
| @Nested | ||
| @DisplayName("compareTo() and equality behavior") | ||
| class CompareTests { | ||
|
|
||
| @Test | ||
| void testVersionComparison() { | ||
| Version v1 = Version.parseVersion("1.2.3"); | ||
| Version v2 = Version.parseVersion("1.3.0"); | ||
| Version v3 = Version.parseVersion("1.2.3"); | ||
|
|
||
| assertTrue(v1.compareTo(v2) < 0); | ||
| assertTrue(v2.compareTo(v1) > 0); | ||
| assertEquals(0, v1.compareTo(v3)); | ||
| } | ||
|
|
||
| @Test | ||
| void testEqualsAndHashCode() { | ||
| Version v1 = Version.parseVersion("2.0.0"); | ||
| Version v2 = Version.parseVersion("2.0.0"); | ||
| Version v3 = Version.parseVersion("2.0.1"); | ||
|
|
||
| assertEquals(v1, v2); | ||
| assertNotEquals(v1, v3); | ||
| assertEquals(v1.hashCode(), v2.hashCode()); | ||
| assertNotEquals(v1.hashCode(), v3.hashCode()); | ||
| } | ||
| } | ||
|
|
||
| // --------------------------------------------------------------------------------------------- | ||
| // TO STRING & EDGE CASE TESTS | ||
| // --------------------------------------------------------------------------------------------- | ||
| @Nested | ||
| class ToStringAndEdgeCases { | ||
|
|
||
| @Test | ||
| void testToStringRepresentation() { | ||
| String raw = "3.4.5-alpha+build"; | ||
| Version version = Version.parseVersion(raw); | ||
| assertEquals(raw, version.toString()); | ||
| } | ||
|
|
||
| @Test | ||
| void testLargeVersionNumbers() { | ||
| Version version = Version.parseVersion("9999.9999.9999"); | ||
| assertEquals(9999, version.getMajor()); | ||
| } | ||
|
|
||
| @Test | ||
| void testPreReleaseVersion() { | ||
| Version version = Version.parseVersion("1.0.0-alpha"); | ||
| assertTrue(version.toString() | ||
| .contains("alpha")); | ||
| } | ||
| } | ||
|
|
||
| // --------------------------------------------------------------------------------------------- | ||
| // SATISFIES() RANGE CHECK TESTS | ||
| // --------------------------------------------------------------------------------------------- | ||
| @Nested | ||
| class SatisfiesBehavior { | ||
|
|
||
| @Test | ||
| void testSimpleComparisons() { | ||
| Version v = Version.parseVersion("3.1.4"); | ||
|
|
||
| assertTrue(v.satisfies(">3.0.0")); | ||
| assertTrue(v.satisfies(">=3.1.4")); | ||
| assertFalse(v.satisfies("<3.0.0")); | ||
| assertFalse(v.satisfies("<=3.1.3")); | ||
| } | ||
|
|
||
| @Test | ||
| void testCompositeRanges() { | ||
| Version v = Version.parseVersion("3.1.4"); | ||
| assertTrue(v.satisfies(">=3.1.4 <4.0.0")); | ||
| assertTrue(v.satisfies(">=3.0.0 <=3.1.4")); | ||
| assertFalse(v.satisfies(">=3.2.0 <4.0.0")); | ||
| } | ||
|
|
||
| @Test | ||
| void testCaretAndTilde() { | ||
| Version v = Version.parseVersion("1.3.5"); | ||
| assertTrue(v.satisfies("^1.3.0")); | ||
| assertTrue(v.satisfies("~1.3.0")); | ||
| assertFalse(v.satisfies("^2.0.0")); | ||
| } | ||
|
|
||
| @Test | ||
| void testMalformedRequirementsReturnFalse() { | ||
| Version v = Version.parseVersion("3.1.4"); | ||
| assertFalse(v.satisfies("not-a-requirement")); | ||
| assertFalse(v.satisfies("pesho3.1.4")); | ||
| assertFalse(v.satisfies("3.1.4.2.3.4.5")); | ||
| } | ||
|
|
||
| @Test | ||
| void testNullRequirement() { | ||
| Version v = Version.parseVersion("3.1.4"); | ||
| assertThrows(NullPointerException.class, () -> v.satisfies(null)); | ||
| } | ||
|
|
||
| @Test | ||
| void testSatisfiesWithComplexVersions() { | ||
| Version v = Version.parseVersion("1.2.3-20251105063220+e303076b5d51da7f0f3a10cd69de018ac0a3853d"); | ||
| assertTrue(v.satisfies(">=1.2.0")); | ||
| assertFalse(v.satisfies(">1.2.3")); | ||
| assertTrue(v.satisfies(">=1.2.0 <2.0.0")); | ||
| assertFalse(v.satisfies(">1.2.3 <2.0.0")); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
order ASC