use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method assertVersions.
private void assertVersions(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.getVersions(selector).stream().map(v -> v.getId()).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 getTestGetVersionWithIllegalArgs.
@Test
public void getTestGetVersionWithIllegalArgs() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withVersion("1.0").build();
try {
repoContent.getVersion(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"));
}
selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("shared").build();
try {
repoContent.getVersion(selector);
assertFalse("Should throw IllegalArgumentException if no version is given", true);
} catch (IllegalArgumentException e) {
// Everything fine
assertTrue(e.getMessage().contains("Version must be set"));
}
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelector1.
@Test
public void testArtifactListWithArtifactSelector1() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withArtifactId("test").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.jar")).findFirst().get();
assertNotNull(artifact);
assertEquals("", artifact.getClassifier());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelector2.
@Test
public void testArtifactListWithArtifactSelector2() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withClassifier("*").withArtifactId("test").withArtifactVersion("1.0-20050611.112233-1").build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
assertNotNull(results);
assertEquals(2, 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());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithNamespaceSelector.
@Test
public void testArtifactListWithNamespaceSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.multilevel").build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
assertNotNull(results);
assertEquals(3, results.size());
assertTrue(results.get(0).getFileName().startsWith("testproj1"));
}
Aggregations