use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactVersionsMultipleArtifactsSingleVersion.
@Test
public void testGetArtifactVersionsMultipleArtifactsSingleVersion() throws Exception {
ArtifactMetadata artifact1 = createArtifact();
artifact1.setId(TEST_PROJECT + "-" + TEST_PROJECT_VERSION + ".jar");
ArtifactMetadata artifact2 = createArtifact();
artifact2.setId(TEST_PROJECT + "-" + TEST_PROJECT_VERSION + "-sources.jar");
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<String> versions = repository.getArtifactVersions(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
assertThat(versions).isNotNull().isNotEmpty().hasSize(1).containsExactly(TEST_PROJECT_VERSION);
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByDateRangeUpperBound.
@Test
public void testGetArtifactsByDateRangeUpperBound() throws Exception {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.save();
Date upper = new Date(artifact.getWhenGathered().getTime() + 10000);
List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange(TEST_REPO_ID, null, upper);
assertEquals(Collections.singletonList(artifact), artifacts);
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByMetadataAllRepositories.
@Test
public void testGetArtifactsByMetadataAllRepositories() throws Exception {
createArtifactWithMavenArtifactFacet();
tryAssert(() -> {
Collection<ArtifactMetadata> artifactsByMetadata = repository.getArtifactsByMetadata("foo", TEST_METADATA_VALUE, null);
assertThat(artifactsByMetadata).hasSize(1);
ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator().next();
assertThat(artifactMetadata.getId()).isEqualTo("projectId-1.0.jar");
assertThat(artifactMetadata.getSha1()).isEqualTo(TEST_SHA1);
assertThat(artifactMetadata.getRepositoryId()).isEqualTo(TEST_REPO_ID);
MetadataFacet facet = artifactMetadata.getFacet(TEST_FACET_ID);
assertThat(facet).isNotNull();
assertThat(facet.toProperties()).isEqualTo(Collections.singletonMap("foo", TEST_METADATA_VALUE));
});
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactOnly.
@Test
public void testGetArtifactOnly() throws Exception {
assertThat(new ArrayList<>(repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION))).isNotNull().isEmpty();
assertThat(repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION)).isNull();
assertThat(repository.getProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT)).isNull();
assertThat(repository.getRootNamespaces(TEST_REPO_ID)).isNotNull().isEmpty();
ArtifactMetadata metadata = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
Collection<ArtifactMetadata> artifacts = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
// assertEquals( Collections.singletonList( metadata ), new ArrayList<ArtifactMetadata>( artifacts ) );
assertThat(artifacts).containsExactly(metadata);
// test that namespace, project and project version is also constructed
assertThat(repository.getRootNamespaces(TEST_REPO_ID)).isNotNull().isNotEmpty().contains(TEST_NAMESPACE).hasSize(1);
ProjectMetadata projectMetadata = repository.getProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
assertEquals(TEST_PROJECT, projectMetadata.getId());
assertEquals(TEST_NAMESPACE, projectMetadata.getNamespace());
ProjectVersionMetadata projectVersionMetadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
assertEquals(TEST_PROJECT_VERSION, projectVersionMetadata.getId());
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByRepoId.
@Test
public void testGetArtifactsByRepoId() throws Exception {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.save();
tryAssert(() -> {
List<ArtifactMetadata> artifacts = repository.getArtifacts(TEST_REPO_ID);
assertEquals(Collections.singletonList(artifact), artifacts);
});
}
Aggregations