use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByChecksumDeepNamespace.
@Test
public void testGetArtifactsByChecksumDeepNamespace() throws Exception {
ArtifactMetadata artifact = createArtifact();
String namespace = "multi.level.ns";
artifact.setNamespace(namespace);
repository.updateArtifact(TEST_REPO_ID, namespace, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.save();
tryAssert(() -> assertEquals(Collections.singletonList(artifact), new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_SHA1))));
tryAssert(() -> assertEquals(Collections.singletonList(artifact), new ArrayList<>(repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_MD5))));
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method createArtifactWithFacet.
private void createArtifactWithFacet(int artifacts, MetadataFacet artifactFacet, MetadataFacet projectVersionMetadataFacet) throws MetadataRepositoryException, MetadataResolutionException {
for (int i = 0; i < artifacts; i++) {
ArtifactMetadata artifact = createArtifact();
if (artifactFacet != null) {
artifact.addFacet(artifactFacet);
}
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
}
if (projectVersionMetadataFacet != null) {
ProjectVersionMetadata metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
metadata.addFacet(projectVersionMetadataFacet);
metadata.setOrganization(TEST_ORGANIZATION);
metadata.setUrl(TEST_URL);
repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
}
repository.save();
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifacts.
@Test
public void testGetArtifacts() throws Exception {
ArtifactMetadata artifact1 = createArtifact();
ArtifactMetadata artifact2 = createArtifact("pom");
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact1);
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact2);
Collection<ArtifactMetadata> artifacts = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
ArrayList<ArtifactMetadata> actual = new ArrayList<>(artifacts);
Collections.sort(actual, (o1, o2) -> o1.getId().compareTo(o2.getId()));
assertEquals(Arrays.asList(artifact1, artifact2), actual);
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsDoesntReturnProjectVersionMetadataFacets.
@Test
public void testGetArtifactsDoesntReturnProjectVersionMetadataFacets() throws Exception {
ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
versionMetadata.setId(TEST_PROJECT_VERSION);
MetadataFacet facet = new TestMetadataFacet(TEST_FACET_ID, "baz");
versionMetadata.addFacet(facet);
repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, versionMetadata);
ArtifactMetadata artifactMetadata = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifactMetadata);
repository.save();
Collection<ArtifactMetadata> artifacts = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
artifacts = repository.getArtifacts(TEST_REPO_ID);
assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
artifacts = repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_SHA1);
assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
artifacts = repository.getArtifactsByChecksum(TEST_REPO_ID, TEST_MD5);
assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
artifacts = repository.getArtifactsByDateRange(TEST_REPO_ID, null, null);
assertEquals(Collections.singletonList(artifactMetadata), new ArrayList<>(artifacts));
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method createArtifactWithData.
private void createArtifactWithData() throws MetadataRepositoryException, MetadataResolutionException {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
ProjectVersionMetadata metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
metadata.setOrganization(TEST_ORGANIZATION);
metadata.setUrl(TEST_URL);
repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
repository.save();
}
Aggregations