use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelector4.
@Test
public void testArtifactListWithArtifactSelector4() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("test").withVersion("1.0-SNAPSHOT").withClassifier("").build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
assertNotNull(results);
assertEquals(5, 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());
artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("wrong-artifactId-1.0-20050611.1122x-1.jar")).findFirst().get();
assertNotNull(artifact);
assertEquals("", artifact.getClassifier());
assertEquals("wrong-artifactId", artifact.getId());
assertEquals("", artifact.getArtifactVersion());
artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("test-1.0-20050611.1122x-1.jar")).findFirst().get();
assertNotNull(artifact);
assertEquals("", artifact.getClassifier());
assertEquals("test", artifact.getId());
assertEquals("1.0-20050611.1122x-1", artifact.getArtifactVersion());
}
use of org.apache.archiva.repository.content.Artifact 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.Artifact in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method checkArtifactListWithArtifactSelector1.
private void checkArtifactListWithArtifactSelector1(List<? extends Artifact> results) {
assertNotNull(results);
assertEquals(1, results.size());
Artifact artifact = results.get(0);
assertEquals("pom", artifact.getExtension());
assertEquals(BaseArtifactTypes.MAIN, artifact.getDataType());
}
use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class ManagedDefaultRepositoryContentTest method testArtifactListWithArtifactSelectorAndRelated.
@Test
public void testArtifactListWithArtifactSelectorAndRelated() {
ItemSelector selector = ArchivaItemSelector.builder().withNamespace("org.apache.maven").withProjectId("samplejar").withVersion("1.0").withArtifactVersion("1.0").withArtifactId("samplejar").withExtension("jar").includeRelatedArtifacts().build();
List<? extends Artifact> results = repoContent.getArtifacts(selector);
assertNotNull(results);
assertEquals(3, results.size());
Artifact artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("samplejar-1.0.jar")).findFirst().get();
assertNotNull(artifact);
assertEquals(BaseArtifactTypes.MAIN, artifact.getDataType());
artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("samplejar-1.0.jar.md5")).findFirst().get();
assertNotNull(artifact);
assertEquals(BaseArtifactTypes.RELATED, artifact.getDataType());
assertEquals("md5", artifact.getExtension());
artifact = results.stream().filter(a -> a.getFileName().equalsIgnoreCase("samplejar-1.0.jar.sha1")).findFirst().get();
assertNotNull(artifact);
assertEquals(BaseArtifactTypes.RELATED, artifact.getDataType());
assertEquals("sha1", artifact.getExtension());
}
use of org.apache.archiva.repository.content.Artifact in project archiva by apache.
the class AbstractRepositoryContentTest method assertLayoutCi.
private void assertLayoutCi(String path, String groupId, String artifactId, String version, String artifactVersion, String classifier, String type) throws LayoutException {
ItemSelector expectedArtifact = createItemSelector(groupId, artifactId, version, artifactVersion, classifier, type);
// --- Artifact Tests.
// Artifact to Path
assertEquals("Artifact <" + expectedArtifact + "> to path:", path, toPath(expectedArtifact));
// --- Artifact Reference Tests
// Path to Artifact Reference.
ItemSelector testReference = toItemSelector(path);
assertItemSelector(testReference, groupId, artifactId, version, artifactVersion, classifier, type);
// And back again, using test Reference from previous step.
assertEquals("Artifact <" + expectedArtifact + "> to path:", path, toPath(testReference));
if (getManaged() != null) {
Namespace ns = null;
Project pr = null;
Version ver = null;
if (StringUtils.isNotEmpty(groupId)) {
ns = getManaged().getLayout(BaseRepositoryContentLayout.class).getNamespace(expectedArtifact);
assertNotNull(ns);
assertEquals(groupId, ns.getId());
}
if (StringUtils.isNotEmpty(artifactId)) {
pr = getManaged().getLayout(BaseRepositoryContentLayout.class).getProject(expectedArtifact);
assertNotNull(pr);
assertEquals(artifactId, pr.getId());
assertEquals(ns, pr.getNamespace());
}
if (StringUtils.isNotEmpty(version)) {
ver = getManaged().getLayout(BaseRepositoryContentLayout.class).getVersion(expectedArtifact);
assertNotNull(ver);
assertEquals(version, ver.getId());
assertEquals(pr, ver.getProject());
}
Artifact artifact = getManaged().getLayout(BaseRepositoryContentLayout.class).getArtifact(expectedArtifact);
assertNotNull(artifact);
assertEquals(artifactId, artifact.getId());
assertEquals(ver, artifact.getVersion());
}
}
Aggregations