Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ protected Optional<String> getLowerBound(ArtifactVersion version, Optional<Segme
}
if (segmentCount > 2) {
if (version.getQualifier() != null) {
newVersion.append("-").append(unchangedSegment.get().value() >= 3 ? version.getQualifier() : "0");
newVersion.append("-").append(unchangedSegment.get().value() >= 3 ? version.getQualifier() : "A0");
} else {
newVersion.append("-").append(unchangedSegment.get().value() >= 3 ? version.getBuildNumber() : "0");
newVersion.append("-").append(unchangedSegment.get().value() >= 3 ? version.getBuildNumber() : "A0");
}
}
return of(newVersion.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.emptyArray;
import static org.hamcrest.Matchers.endsWith;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasToString;
Expand Down Expand Up @@ -375,4 +376,31 @@ void testRestrictionForIgnoreScopeLowerBoundNull() throws InvalidSegmentExceptio
versions.restrictionForIgnoreScope(null, Optional.of(MAJOR)),
is(equalTo(new Restriction(null, false, null, false))));
}

@Test
void testGetNewerVersionsSnapshotToPrereleaseMajor() throws InvalidSegmentException {
ArtifactVersions instance = new ArtifactVersions(
new DefaultArtifact("default-group", "dummy-api", "1.0.0-SNAPSHOT", "foo", "bar", "jar", null),
Arrays.asList(versions("1.0.0-SNAPSHOT", "1.0.0-RC1", "1.0.0-beta", "1.0.0")));

ArtifactVersion[] result = instance.getNewerVersions("1.0.0-SNAPSHOT", of(MAJOR), false, true);

assertThat(
"Prerelease versions should be filterable from snapshot with MAJOR segment",
result,
arrayContaining(version("1.0.0-beta"), version("1.0.0-RC1"), version("1.0.0")));
}

@Test
void testLowerBoundPreservesQualifierForMajorSegment() throws InvalidSegmentException {
ArtifactVersions instance = new ArtifactVersions(
new DefaultArtifact("default-group", "dummy-api", "1.0.0-SNAPSHOT", "foo", "bar", "jar", null),
Arrays.asList(versions("1.0.0-SNAPSHOT")));

Optional<String> lowerBound =
instance.getLowerBound(ArtifactVersionService.getArtifactVersion("1.0.0-SNAPSHOT"), of(MAJOR));

assertThat("Lower bound must be present", lowerBound.isPresent());
assertThat("Lower bound should preserve qualifier, not replace with -0", lowerBound.get(), not(endsWith("-0")));
}
}