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());
}
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);
}
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"));
}
}
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 */
}
}
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);
}
Aggregations