Search in sources :

Example 61 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testGetProjects.

@Test
public void testGetProjects() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").build();
    Namespace ns = repoContent.getNamespace(selector);
    assertNotNull(ns);
    List<? extends Project> projects = repoContent.getProjects(ns);
    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) Namespace(org.apache.archiva.repository.content.Namespace) Test(org.junit.Test)

Example 62 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testGetItemWithProjectSelector.

@Test
public void testGetItemWithProjectSelector() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("shared").build();
    ContentItem item = repoContent.getItem(selector);
    assertNotNull(item);
    assertTrue(item instanceof Project);
}
Also used : Project(org.apache.archiva.repository.content.Project) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) ContentItem(org.apache.archiva.repository.content.ContentItem) ArchivaContentItem(org.apache.archiva.repository.content.base.ArchivaContentItem) Test(org.junit.Test)

Example 63 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testNewItemStreamWithNamespace1.

@Test
public void testNewItemStreamWithNamespace1() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").build();
    Stream<? extends ContentItem> stream = repoContent.newItemStream(selector, false);
    List<? extends ContentItem> result = stream.collect(Collectors.toList());
    assertEquals(41, result.size());
    ContentItem item = result.get(39);
    Version version = item.adapt(Version.class);
    assertNotNull(version);
    assertEquals("1.3-SNAPSHOT", version.getId());
    Project project = result.get(40).adapt(Project.class);
    assertNotNull(project);
    assertEquals("axis2", project.getId());
    assertTrue(result.stream().anyMatch(a -> "axis2-1.3-20070725.210059-1.pom".equals(a.getAsset().getName())));
}
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) Project(org.apache.archiva.repository.content.Project) ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) Version(org.apache.archiva.repository.content.Version) ContentItem(org.apache.archiva.repository.content.ContentItem) ArchivaContentItem(org.apache.archiva.repository.content.base.ArchivaContentItem) Test(org.junit.Test)

Example 64 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testGetItemWithArtifactSelector.

@Test
public void testGetItemWithArtifactSelector() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("samplejar").withVersion("2.0").withArtifactId("samplejar").build();
    ContentItem item = repoContent.getItem(selector);
    assertNotNull(item);
    assertTrue(item instanceof Artifact);
}
Also used : ArchivaItemSelector(org.apache.archiva.repository.content.base.ArchivaItemSelector) ItemSelector(org.apache.archiva.repository.content.ItemSelector) ContentItem(org.apache.archiva.repository.content.ContentItem) ArchivaContentItem(org.apache.archiva.repository.content.base.ArchivaContentItem) Artifact(org.apache.archiva.repository.content.Artifact) Test(org.junit.Test)

Example 65 with ItemSelector

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

the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelectorVersionPattern.

@Test
public void testArtifactListWithArtifactSelectorVersionPattern() {
    ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withArtifactVersion("1.0-*").build();
    List<? extends Artifact> results = repoContent.getArtifacts(selector);
    assertNotNull(results);
    assertEquals(5, results.size());
    Artifact artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("wrong-artifactId-1.0-20050611.112233-1.jar")).findFirst().get();
    assertNotNull(artifact);
}
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)

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