Search in sources :

Example 16 with ItemSelector

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

the class AbstractBaseRepositoryContentLayoutTest method testGetArtifactOnEmptyPath.

@Test
public void testGetArtifactOnEmptyPath() throws LayoutException {
    ItemSelector selector = ArchivaItemSelector.builder().build();
    try {
        getManaged().getLayout(BaseRepositoryContentLayout.class).getArtifact(selector);
        fail("getArtifact(ItemSelector) with empty selector should throw IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    // Good
    }
}
Also used : ItemSelector(org.apache.archiva.repository.content.ItemSelector) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) BaseRepositoryContentLayout(org.apache.archiva.repository.content.BaseRepositoryContentLayout) Test(org.junit.Test)

Example 17 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelectorWithClassifier.

@Test
public void testArtifactListWithArtifactSelectorWithClassifier() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withArtifactId("test").withClassifier("javadoc").withArtifactVersion("1.0-20050611.112233-1").build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    assertNotNull(results);
    assertEquals(1, 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());
}
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 18 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testArtifactStreamWithProjectSelector.

@Test
public void testArtifactStreamWithProjectSelector() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").build();
    Stream<? extends Artifact> results = repoContent.newArtifactStream(selector);
    checkArtifactListWithProjectSelector(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 19 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testHasContent.

@Test
public void testHasContent() throws LayoutException {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").withVersion("1.1").withArtifactId("maven-downloader").withExtension("jar").build();
    assertTrue(repoContent.hasContent(selector));
    selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").withVersion("1.1").withArtifactId("maven-downloader").withExtension("zip").build();
    assertFalse(repoContent.hasContent(selector));
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 20 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testGetArtifactListWithVersionSelector.

@Test
public void testGetArtifactListWithVersionSelector() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("javax.sql").withProjectId("jdbc").withVersion("2.0").build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    checkArtifactListWithVersionSelector1(results);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) 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