mirror of https://github.com/apache/archiva.git
[MRM-1042]
o fix getting of other versions of the snapshot o added tests for getting other versions of the snapshot git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@745371 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e9b030ba0c
commit
ebe7941ce0
|
@ -180,9 +180,9 @@ public class DefaultRepositoryBrowsing
|
|||
}
|
||||
|
||||
/**
|
||||
* @see RepositoryBrowsing#getTimestampedSnapshots(List, String, String, String)
|
||||
* @see RepositoryBrowsing#getOtherSnapshotVersions(List, String, String, String)
|
||||
*/
|
||||
public List<String> getTimestampedSnapshots( List<String> observableRepositoryIds, String groupId,
|
||||
public List<String> getOtherSnapshotVersions( List<String> observableRepositoryIds, String groupId,
|
||||
String artifactId, String version )
|
||||
throws ObjectNotFoundException, ArchivaDatabaseException
|
||||
{
|
||||
|
@ -194,14 +194,15 @@ public class DefaultRepositoryBrowsing
|
|||
dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) );
|
||||
|
||||
for ( String uniqueVersion : versions )
|
||||
{
|
||||
if ( VersionUtil.getBaseVersion( uniqueVersion ).equals( version ) )
|
||||
{
|
||||
if ( VersionUtil.getBaseVersion( uniqueVersion ).equals( version ) ||
|
||||
VersionUtil.getBaseVersion( uniqueVersion ).equals( VersionUtil.getBaseVersion( version ) ) )
|
||||
{
|
||||
if ( !timestampedVersions.contains( uniqueVersion ) )
|
||||
{
|
||||
timestampedVersions.add( uniqueVersion );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ public interface RepositoryBrowsing
|
|||
throws ObjectNotFoundException, ArchivaDatabaseException;
|
||||
|
||||
/**
|
||||
* Get the timestamped versions or versions with build numbers of the given SNAPSHOT artifact.
|
||||
* Get the other versions of the given SNAPSHOT version.
|
||||
*
|
||||
* @param observableRepositoryIds
|
||||
* @param groupId
|
||||
|
@ -101,7 +101,7 @@ public interface RepositoryBrowsing
|
|||
* @throws ObjectNotFoundException
|
||||
* @throws ArchivaDatabaseException
|
||||
*/
|
||||
public List<String> getTimestampedSnapshots( List<String> observableRepositoryIds,
|
||||
public List<String> getOtherSnapshotVersions( List<String> observableRepositoryIds,
|
||||
String groupId, String artifactId, String version )
|
||||
throws ObjectNotFoundException, ArchivaDatabaseException;
|
||||
|
||||
|
|
|
@ -164,7 +164,37 @@ public class RepositoryBrowsingTest
|
|||
assertTrue( results.getVersions().contains( "2.1.1" ) );
|
||||
assertTrue( results.getVersions().contains( "2.1-alpha-1" ) );
|
||||
}
|
||||
|
||||
|
||||
public void testGetOtherSnapshotVersionsRequestedVersionIsGeneric()
|
||||
throws Exception
|
||||
{
|
||||
saveTestData();
|
||||
|
||||
RepositoryBrowsing browser = lookupBrowser();
|
||||
List<String> results =
|
||||
browser.getOtherSnapshotVersions( GUEST_REPO_IDS, "org.apache.maven.shared", "test-two", "2.1-SNAPSHOT" );
|
||||
assertNotNull( "Returned list of versions should not be null.", results );
|
||||
assertEquals( 3, results.size() );
|
||||
assertTrue( results.contains( "2.1-SNAPSHOT" ) );
|
||||
assertTrue( results.contains( "2.1-20070522.143249-1" ) );
|
||||
assertTrue( results.contains( "2.1-20070522.153141-2" ) );
|
||||
}
|
||||
|
||||
public void testGetOtherSnapshotVersionsRequestedVersionIsUnique()
|
||||
throws Exception
|
||||
{
|
||||
saveTestData();
|
||||
|
||||
RepositoryBrowsing browser = lookupBrowser();
|
||||
List<String> results =
|
||||
browser.getOtherSnapshotVersions( GUEST_REPO_IDS, "org.apache.maven.shared", "test-two", "2.1-20070522.143249-1" );
|
||||
assertNotNull( "Returned list of versions should not be null.", results );
|
||||
assertEquals( 3, results.size() );
|
||||
assertTrue( results.contains( "2.1-SNAPSHOT" ) );
|
||||
assertTrue( results.contains( "2.1-20070522.143249-1" ) );
|
||||
assertTrue( results.contains( "2.1-20070522.153141-2" ) );
|
||||
}
|
||||
|
||||
private void assertGroupIds( String msg, List actualGroupIds, String[] expectedGroupIds )
|
||||
{
|
||||
assertEquals( msg + ": groupIds.length", expectedGroupIds.length, actualGroupIds.size() );
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ShowArtifactAction
|
|||
repoBrowsing.selectVersion( getPrincipal(), getObservableRepos(), groupId, artifactId, version );
|
||||
|
||||
this.snapshotVersions =
|
||||
repoBrowsing.getTimestampedSnapshots( getObservableRepos(), groupId, artifactId, version );
|
||||
repoBrowsing.getOtherSnapshotVersions( getObservableRepos(), groupId, artifactId, version );
|
||||
if( this.snapshotVersions.contains( version ) )
|
||||
{
|
||||
this.snapshotVersions.remove( version );
|
||||
|
|
Loading…
Reference in New Issue