use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class MavenRepositoryRequestInfoTest method assertValid.
private void assertValid(String path, String groupId, String artifactId, String version, String artifactVersion, String classifier, String type) throws Exception {
String expectedId = "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + (classifier != null ? classifier + ":" : "") + type;
ItemSelector reference = repoRequest.toItemSelector(path);
assertNotNull(expectedId + " - Should not be null.", reference);
assertEquals(expectedId + " - Group ID", groupId, reference.getNamespace());
assertEquals(expectedId + " - Artifact ID", artifactId, reference.getArtifactId());
assertEquals(expectedId + " - Artifact Version", artifactVersion, reference.getArtifactVersion());
if (StringUtils.isNotBlank(classifier)) {
assertEquals(expectedId + " - Classifier", classifier, reference.getClassifier());
}
assertEquals(expectedId + " - Version ID", version, reference.getVersion());
assertEquals(expectedId + " - Type", type, reference.getType());
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetArtifactListWithArtifactSelector1.
@Test
public void testGetArtifactListWithArtifactSelector1() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.axis2").withProjectId("axis2").withVersion("1.3-SNAPSHOT").withArtifactVersion("1.3-20070731.113304-21").withExtension("pom").build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
checkArtifactListWithArtifactSelector1(results);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetItemWithVersionSelector.
@Test
public void testGetItemWithVersionSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("samplejar").withVersion("2.0").build();
ContentItem item = repoContent.getItem(selector);
assertNotNull(item);
assertTrue(item instanceof Version);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelectorWrongArtifact.
@Test
public void testArtifactListWithArtifactSelectorWrongArtifact() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withArtifactId("wrong-artifactId").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("wrong-artifactId-1.0-20050611.112233-1.jar")).findFirst().get();
assertNotNull(artifact);
}
use of org.apache.archiva.repository.content.ItemSelector in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testGetVersionsWithIllegalSelector.
@Test
public void testGetVersionsWithIllegalSelector() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").build();
try {
List<? extends Version> versions = repoContent.getVersions(selector);
assertFalse("IllegalArgumentException expected, when project id not set", true);
} catch (IllegalArgumentException e) {
assertEquals("Project id not set, while retrieving versions.", e.getMessage());
}
}
Aggregations