aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-maven
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-03-08 17:27:58 +0100
committerMartin Stockhammer <martin_s@apache.org>2020-03-08 17:27:58 +0100
commitc2f785a2099927f490d4883502e867b05e1ac745 (patch)
treed05eaff5d9799933ec9bc10002dc040560f3f054 /archiva-modules/archiva-maven
parent8befca5a495a82748f51c2c419f44e43bbd3af25 (diff)
downloadarchiva-c2f785a2099927f490d4883502e867b05e1ac745.tar.gz
archiva-c2f785a2099927f490d4883502e867b05e1ac745.zip
Adding version test
Diffstat (limited to 'archiva-modules/archiva-maven')
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java11
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java16
2 files changed, 24 insertions, 3 deletions
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java
index 417dab7d2..6970d0eb5 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java
@@ -260,6 +260,8 @@ public class ManagedDefaultRepositoryContent
+
+
public Artifact createArtifact(final StorageAsset artifactPath, final ItemSelector selector,
final String classifier, final String extension) {
Version version = getVersion(selector);
@@ -566,9 +568,14 @@ public class ManagedDefaultRepositoryContent
TBD
*/
@Override
- public List<? extends Version> getVersions( Project project )
+ public List<? extends Version> getVersions( final Project project )
{
- return null;
+ StorageAsset asset = getAsset( project.getNamespace( ).getNamespace( ), project.getId( ) );
+ return asset.list( ).stream( ).filter( a -> a.isContainer( ) )
+ .map( a -> ArchivaVersion.withAsset( a )
+ .withProject( project )
+ .withVersion( a.getName() ).build() )
+ .collect( Collectors.toList( ) );
}
/*
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java
index ba66d57aa..588bb4726 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java
@@ -31,6 +31,9 @@ import org.apache.archiva.repository.LayoutException;
import org.apache.archiva.repository.ManagedRepositoryContent;
import org.apache.archiva.repository.RepositoryContent;
import org.apache.archiva.repository.content.ItemSelector;
+import org.apache.archiva.repository.content.Project;
+import org.apache.archiva.repository.content.Version;
+import org.apache.archiva.repository.content.base.ArchivaItemSelector;
import org.apache.archiva.repository.maven.MavenManagedRepository;
import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider;
import org.apache.commons.io.FileUtils;
@@ -49,6 +52,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
import static org.junit.Assert.*;
@@ -213,12 +217,22 @@ public class ManagedDefaultRepositoryContentTest
Set<String> testedVersionSet = repoContent.getVersions( reference );
// Sort the list (for asserts)
+ VersionComparator comparator = new VersionComparator( );
List<String> testedVersions = new ArrayList<>();
testedVersions.addAll( testedVersionSet );
- Collections.sort( testedVersions, new VersionComparator() );
+ Collections.sort( testedVersions, comparator );
// Test the expected array of versions, to the actual tested versions
assertEquals( "available versions", expectedVersions, testedVersions );
+
+ ItemSelector selector = ArchivaItemSelector.builder( )
+ .withNamespace( "org.apache.archiva.metadata.tests" )
+ .withProjectId( artifactId )
+ .build( );
+ Project project = repoContent.getProject( selector );
+ assertNotNull( project );
+ List<String> versions = repoContent.getVersions( project ).stream().map(v -> v.getVersion()).sorted( comparator ).collect( Collectors.toList());
+ assertArrayEquals( expectedVersions.toArray(), versions.toArray( ) );
}
private void assertVersions( String artifactId, String version, String[] expectedVersions )