From 49e9ba8d5f808abedd4913d8fec455ae7cfd53f7 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Fri, 13 Mar 2020 23:21:01 +0100 Subject: [PATCH] Adding additional tests for new content API --- .../ManagedDefaultRepositoryContentTest.java | 43 ++++++++++++++++--- .../1.0/testproj1-1.0.pom} | 4 +- .../1.0/testproj1-1.0.pom.md5} | 0 .../1.0/testproj1-1.0.pom.sha256} | 0 .../testproj2/1.0/testproj2-1.0.pom} | 6 +-- .../testproj2/1.0/testproj2-1.0.pom.md5} | 0 .../testproj2/1.0/testproj2-1.0.pom.sha256} | 0 7 files changed, 43 insertions(+), 10 deletions(-) rename archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/{test/1.0/test-1.0.pom => testproj1/1.0/testproj1-1.0.pom} (98%) rename archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/{1.0/mulitlevel-1.0.pom.md5 => testproj1/1.0/testproj1-1.0.pom.md5} (100%) rename archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/{1.0/mulitlevel-1.0.pom.sha256 => testproj1/1.0/testproj1-1.0.pom.sha256} (100%) rename archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/{1.0/mulitlevel-1.0.pom => testproj1/testproj2/1.0/testproj2-1.0.pom} (97%) rename archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/{test/1.0/test-1.0.pom.md5 => testproj1/testproj2/1.0/testproj2-1.0.pom.md5} (100%) rename archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/{test/1.0/test-1.0.pom.sha256 => testproj1/testproj2/1.0/testproj2-1.0.pom.sha256} (100%) 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 a0dbbd22f..4f1d936b2 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 @@ -648,28 +648,28 @@ public class ManagedDefaultRepositoryContentTest @Test - public void testArtifactListWithProjectSelector1() { + public void testArtifactListWithProjectSelector() { ItemSelector selector = ArchivaItemSelector.builder( ) .withNamespace( "org.apache.maven.shared" ) .withProjectId( "maven-downloader" ) .build( ); List results = repoContent.getArtifacts( selector ); - checkArtifactListWithProjectSelector1( results ); + checkArtifactListWithProjectSelector( results ); } @Test - public void testArtifactStreamWithProjectSelector1() { + public void testArtifactStreamWithProjectSelector() { ItemSelector selector = ArchivaItemSelector.builder( ) .withNamespace( "org.apache.maven.shared" ) .withProjectId( "maven-downloader" ) .build( ); Stream results = repoContent.newArtifactStream( selector ); - checkArtifactListWithProjectSelector1( results.collect( Collectors.toList()) ); + checkArtifactListWithProjectSelector( results.collect( Collectors.toList()) ); } - private void checkArtifactListWithProjectSelector1( List results ) + private void checkArtifactListWithProjectSelector( List results ) { assertNotNull( results ); assertEquals( 27, results.size( ) ); @@ -696,4 +696,37 @@ public class ManagedDefaultRepositoryContentTest assertEquals( ".jar.sha1", artifact.getRemainder( ) ); } + @Test + public void testArtifactListWithNamespaceSelector() { + ItemSelector selector = ArchivaItemSelector.builder( ) + .withNamespace( "org.multilevel" ) + .build( ); + List results = repoContent.getArtifacts( selector ); + assertNotNull( results ); + assertEquals( 3, results.size( ) ); + assertTrue( results.get( 0 ).getFileName( ).startsWith( "testproj1" ) ); + } + + @Test + public void testArtifactListWithNamespaceSelectorRecursive() { + ItemSelector selector = ArchivaItemSelector.builder( ) + .withNamespace( "org.multilevel" ) + .recurse() + .build( ); + List results = repoContent.getArtifacts( selector ); + assertNotNull( results ); + assertEquals( 6, results.size( ) ); + + Artifact artifact = results.stream( ).filter( a -> a.getFileName( ).equalsIgnoreCase( "testproj2-1.0.pom" ) ) + .findFirst( ).get( ); + assertNotNull( artifact ); + assertEquals( 6, artifact.getAsset( ).getParent( ).getPath( ).split( "/" ).length ); + + artifact = results.stream( ).filter( a -> a.getFileName( ).equalsIgnoreCase( "testproj1-1.0.pom" ) ) + .findFirst( ).get( ); + assertNotNull( artifact ); + assertEquals( 5, artifact.getAsset( ).getParent( ).getPath( ).split( "/" ).length ); + + } + } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom similarity index 98% rename from archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom rename to archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom index 734987350..bcfea0a04 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom @@ -3,8 +3,8 @@ 4.0.0 org.multilevel - test - Multilevel Test Sub 1 + testproj1 + Multilevel Test 1 1.0 pom diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom.md5 b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom.md5 rename to archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom.md5 diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom.sha256 b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom.sha256 similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom.sha256 rename to archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/1.0/testproj1-1.0.pom.sha256 diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom similarity index 97% rename from archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom rename to archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom index ecc1a93b7..9605c2bd1 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/1.0/mulitlevel-1.0.pom +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom @@ -2,9 +2,9 @@ 4.0.0 - org - multilevel - Multilevel Test + org.multilevel.testproj1 + testproj2 + Multilevel Test Sub 2 1.0 pom diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom.md5 b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom.md5 similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom.md5 rename to archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom.md5 diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom.sha256 b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom.sha256 similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/test/1.0/test-1.0.pom.sha256 rename to archiva-modules/archiva-maven/archiva-maven-repository/src/test/resources/repositories/default-repository/org/multilevel/testproj1/testproj2/1.0/testproj2-1.0.pom.sha256 -- 2.39.5