Search in sources :

Example 56 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelector3.

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

Example 57 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testGetProjectsWithSelector.

@Test
public void testGetProjectsWithSelector() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").build();
    List<? extends Project> projects = repoContent.getProjects(selector);
    assertEquals(12, projects.size());
    String[] expected = new String[] { "A", "B", "C", "archiva", "discovery", "maven-parent", "samplejar", "shared", "some-ejb", "test", "testing", "update" };
    Object[] actual = projects.stream().map(p -> p.getId()).sorted().toArray();
    assertArrayEquals(expected, actual);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 58 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method getTestGetProjectWithIllegalArgs.

@Test
public void getTestGetProjectWithIllegalArgs() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache").withVersion("1.0").build();
    try {
        repoContent.getProject(selector);
        assertFalse("Should throw IllegalArgumentException if no project id is given", true);
    } catch (IllegalArgumentException e) {
        // Everything fine
        assertTrue(e.getMessage().contains("Project id must be set"));
    }
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 59 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testToPathOnNullArtifactReference.

@Test
@Override
public void testToPathOnNullArtifactReference() {
    try {
        ItemSelector reference = null;
        repoContent.toPath(reference);
        fail("Should have failed due to null artifact reference.");
    } catch (IllegalArgumentException e) {
    /* expected path */
    }
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Test(org.junit.Test)

Example 60 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testGetArtifactListWithArtifactSelector2.

@Test
public void testGetArtifactListWithArtifactSelector2() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").withProjectId("axis2").withVersion("1.3-SNAPSHOT").withArtifactVersion("1.3-20070731.113304-21").withExtension("pom").includeRelatedArtifacts().build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    checkArtifactListWithArtifactSelector2(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