use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetArtifactFromContentItem.
@Test
public void testGetArtifactFromContentItem() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").build();
Namespace ns = repoContent.getNamespace(selector);
List<? extends Artifact> artifacts = repoContent.getArtifacts(ns);
assertNotNull(artifacts);
assertEquals(39, artifacts.size());
List<? extends Artifact> artifacts2 = repoContent.getArtifacts((ContentItem) ns);
assertArrayEquals(artifacts.toArray(), artifacts2.toArray());
selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").build();
Project project = repoContent.getProject(selector);
artifacts = repoContent.getArtifacts(project);
assertNotNull(artifacts);
assertEquals(27, artifacts.size());
artifacts2 = repoContent.getArtifacts((ContentItem) project);
assertArrayEquals(artifacts.toArray(), artifacts2.toArray());
selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven.shared").withProjectId("maven-downloader").withVersion("1.1").build();
Version version = repoContent.getVersion(selector);
artifacts = repoContent.getArtifacts(version);
assertNotNull(artifacts);
assertEquals(12, artifacts.size());
artifacts2 = repoContent.getArtifacts((ContentItem) version);
assertArrayEquals(artifacts.toArray(), artifacts2.toArray());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method assertArtifactVersions.
private void assertArtifactVersions(String artifactId, String version, String[] expectedVersions) throws Exception {
// Use the test metadata-repository, which is already setup for
// These kind of version tests.
Path repoDir = getRepositoryPath("metadata-repository");
((EditableManagedRepository) repoContent.getRepository()).setLocation(repoDir.toAbsolutePath().toUri());
// Request the versions.
// Sort the list (for asserts later)
final VersionComparator comparator = new VersionComparator();
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.archiva.metadata.tests").withProjectId(artifactId).withVersion(version).build();
List<String> versions = repoContent.getArtifactVersions(selector).stream().sorted(comparator).collect(Collectors.toList());
assertArrayEquals(expectedVersions, versions.toArray());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetItemWithNamespaceSelector.
@Test
public void testGetItemWithNamespaceSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").build();
ContentItem item = repoContent.getItem(selector);
assertNotNull(item);
assertTrue(item instanceof Namespace);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetVersionsWithSelector.
@Test
public void testGetVersionsWithSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("samplejar").build();
List<? extends Version> versions = repoContent.getVersions(selector);
assertNotNull(versions);
assertEquals(2, versions.size());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetArtifactStreamWithVersionSelector.
@Test
public void testGetArtifactStreamWithVersionSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("javax.sql").withProjectId("jdbc").withVersion("2.0").build();
try (Stream<? extends Artifact> stream = repoContent.newArtifactStream(selector)) {
assertNotNull(stream);
List<? extends Artifact> results = stream.collect(Collectors.toList());
checkArtifactListWithVersionSelector1(results);
}
}
Aggregations