Skip to content

Commit

Permalink
Fixing mojohaus#769
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejj0 committed Oct 18, 2022
1 parent 0d7d90d commit e328768
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.mojo.versions.ordering.InvalidSegmentException;
import org.codehaus.mojo.versions.ordering.MavenVersionComparator;
import org.codehaus.mojo.versions.ordering.MercuryVersionComparator;
import org.hamcrest.Matchers;
import org.junit.Test;

import static java.util.Optional.of;
import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL;
import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
Expand All @@ -56,14 +57,14 @@ public void test4DigitVersions() throws Exception
assertEquals( "artifact", instance.getArtifactId() );
assertEquals( "group", instance.getGroupId() );
assertThat( instance.getVersions(),
Matchers.arrayContaining( versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1",
arrayContaining( versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1",
"3.1.0.1" ) ) );
assertThat( instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ),
Matchers.arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) );
arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) );

assertThat( instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ),
//Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1")));
Matchers.arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) );
arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) );

assertEquals( new DefaultArtifactVersion( "2.121.2.1" ),
instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ),
Expand Down Expand Up @@ -128,7 +129,7 @@ public void testReportLabels()
}

@Test
public void testGetNewerVersionsWithSnapshot()
public void testGetNewerVersionsWithSnapshot() throws InvalidSegmentException
{
ArtifactVersion[] versions = versions( "1.0.0-SNAPSHOT", "1.0.0" );
ArtifactVersions instance =
Expand All @@ -137,6 +138,7 @@ public void testGetNewerVersionsWithSnapshot()
"jar", null ),
Arrays.asList( versions ), new MavenVersionComparator() );

// assertThat( instance.getNewerVersions( "1.0.0-SNAPSHOT", of( SUBINCREMENTAL )))
assertThat( instance.getNewerVersions( "1.0.0-SNAPSHOT", of( SUBINCREMENTAL ), false, false ),
arrayContaining( new DefaultArtifactVersion( "1.0.0" ) ) );
}
}

0 comments on commit e328768

Please sign in to comment.