Search in sources :

Example 21 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testArtifactStreamWithNamespaceSelectorRecursive.

@Test
public void testArtifactStreamWithNamespaceSelectorRecursive() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.multilevel").recurse().build();
    Stream<? extends Artifact> results = repoContent.newArtifactStream(selector);
    checkArtifactListWithNamespaceSelectorRecursive(results.collect(Collectors.toList()));
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 22 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testGetRelatedArtifactsFromArtifact.

@Test
public void testGetRelatedArtifactsFromArtifact() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").withVersion("1.1").withExtension("jar").withArtifactId("maven-downloader").build();
    Artifact artifact = repoContent.getArtifact(selector);
    assertNotNull(artifact);
    List<? extends Artifact> artifacts = repoContent.getArtifacts(artifact);
    assertNotNull(artifacts);
    assertEquals(2, artifacts.size());
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 23 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testGetArtifactStreamWithVersionSelector2.

@Test
public void testGetArtifactStreamWithVersionSelector2() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").withProjectId("axis2").withVersion("1.3-SNAPSHOT").build();
    try (Stream<? extends Artifact> stream = repoContent.newArtifactStream(selector)) {
        assertNotNull(stream);
        List<? extends Artifact> results = stream.collect(Collectors.toList());
        checkArtifactListWithVersionSelector2(results);
    }
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 24 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testArtifactListWithProjectSelector.

@Test
public void testArtifactListWithProjectSelector() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    checkArtifactListWithProjectSelector(results);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 25 with ItemSelector

use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.

the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelector4.

@Test
public void testArtifactListWithArtifactSelector4() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withClassifier("").build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    assertNotNull(results);
    assertEquals(5, results.size());
    Artifact artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("test-1.0-20050611.112233-1-javadoc.jar")).findFirst().get();
    assertNotNull(artifact);
    assertEquals("javadoc", artifact.getClassifier());
    assertEquals("javadoc", artifact.getType());
    artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("wrong-artifactId-1.0-20050611.112233-1.jar")).findFirst().get();
    assertNotNull(artifact);
    assertEquals("", artifact.getClassifier());
    assertEquals("wrong-artifactId", artifact.getId());
    artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("wrong-artifactId-1.0-20050611.1122x-1.jar")).findFirst().get();
    assertNotNull(artifact);
    assertEquals("", artifact.getClassifier());
    assertEquals("wrong-artifactId", artifact.getId());
    assertEquals("", artifact.getArtifactVersion());
    artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("test-1.0-20050611.1122x-1.jar")).findFirst().get();
    assertNotNull(artifact);
    assertEquals("", artifact.getClassifier());
    assertEquals("test", artifact.getId());
    assertEquals("1.0-20050611.1122x-1", artifact.getArtifactVersion());
}
Also used : Artifact(org.apache.archiva.repository.content.Artifact) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ArtifactMappingProvider(org.apache.archiva.maven.repository.metadata.storage.ArtifactMappingProvider) RepositoryPathTranslator(org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator) MavenManagedRepository(org.apache.archiva.maven.repository.MavenManagedRepository) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) URISyntaxException(java.net.URISyntaxException) Namespace(org.apache.archiva.repository.content.Namespace) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) FileTime(java.nio.file.attribute.FileTime) Version(org.apache.archiva.repository.content.Version) FileType(org.apache.archiva.configuration.model.FileType) Inject(javax.inject.Inject) Charset(java.nio.charset.Charset) MavenMetadataReader(org.apache.archiva.maven.metadata.MavenMetadataReader) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Named(javax.inject.Named) VersionComparator(org.apache.archiva.common.utils.VersionComparator) Path(java.nio.file.Path) ContentItem(org.apache.archiva.repository.content.ContentItem) Before(org.junit.Before) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) OutputStream(java.io.OutputStream) FileTypes(org.apache.archiva.configuration.provider.FileTypes) Project(org.apache.archiva.repository.content.Project) ArchivaContentItem(org.apache.archiva.repository.content.base.ArchivaContentItem) Files(java.nio.file.Files) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) BaseArtifactTypes(org.apache.archiva.repository.content.BaseArtifactTypes) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) IOException(java.io.IOException) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) ManagedRepository(org.apache.archiva.repository.ManagedRepository) DataItem(org.apache.archiva.repository.content.DataItem) List(java.util.List) RepositoryContent(org.apache.archiva.repository.RepositoryContent) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) LayoutException(org.apache.archiva.repository.content.LayoutException) Assert(org.junit.Assert) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ItemNotFoundException(org.apache.archiva.repository.content.ItemNotFoundException) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Aggregations

ItemSelector (org.apache.archiva.repository.content.ItemSelector)76 ArchivaItemSelector (org.apache.archiva.repository.content.base.ArchivaItemSelector)74 Test (org.junit.Test)41 Path (java.nio.file.Path)16 Artifact (org.apache.archiva.repository.content.Artifact)16 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)13 ManagedRepositoryContent (org.apache.archiva.repository.ManagedRepositoryContent)12 BaseRepositoryContentLayout (org.apache.archiva.repository.content.BaseRepositoryContentLayout)12 LayoutException (org.apache.archiva.repository.content.LayoutException)12 IOException (java.io.IOException)11 ContentItem (org.apache.archiva.repository.content.ContentItem)11 Project (org.apache.archiva.repository.content.Project)11 ArchivaContentItem (org.apache.archiva.repository.content.base.ArchivaContentItem)10 Namespace (org.apache.archiva.repository.content.Namespace)9 Version (org.apache.archiva.repository.content.Version)9 VersionComparator (org.apache.archiva.common.utils.VersionComparator)8 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Stream (java.util.stream.Stream)6