use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByDateRangeLowerAndUpperBound.
@Test
public void testGetArtifactsByDateRangeLowerAndUpperBound() throws Exception {
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.save();
Date lower = new Date(artifact.getWhenGathered().getTime() - 10000);
Date upper = new Date(artifact.getWhenGathered().getTime() + 10000);
List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange(TEST_REPO_ID, lower, upper);
assertEquals(Collections.singletonList(artifact), artifacts);
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method deleteProject.
@Test
public void deleteProject() throws Exception {
ArtifactMetadata artifact = createArtifact();
artifact.addFacet(new TestMetadataFacet("value"));
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
assertEquals(1, repository.getProjectVersions(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT).size());
repository.removeProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
Collection<String> versions = repository.getProjectVersions(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
assertThat(versions).isNotNull().isEmpty();
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method deleteArtifact.
@Test
public void deleteArtifact() throws Exception {
ArtifactMetadata artifact = createArtifact();
artifact.addFacet(new TestMetadataFacet("value"));
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact);
Collection<ArtifactMetadata> artifacts = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
assertEquals(Collections.singletonList(artifact), new ArrayList<>(artifacts));
repository.removeArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId());
artifacts = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
assertThat(artifacts).isNotNull().isEmpty();
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testGetArtifactsByDateRangeUpperBoundOutOfRange.
@Test
public void testGetArtifactsByDateRangeUpperBoundOutOfRange() 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);
assertThat(artifacts).isNotNull().isEmpty();
}
use of org.apache.archiva.metadata.model.ArtifactMetadata in project archiva by apache.
the class AbstractMetadataRepositoryTest method testUpdateArtifactMetadataWithExistingFacets.
@Test
public void testUpdateArtifactMetadataWithExistingFacets() throws Exception {
ArtifactMetadata metadata = createArtifact();
MetadataFacet facet = new TestMetadataFacet("baz");
metadata.addFacet(facet);
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
metadata = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION).iterator().next();
assertEquals(Collections.singleton(TEST_FACET_ID), metadata.getFacetIds());
metadata = createArtifact();
repository.updateArtifact(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, metadata);
metadata = repository.getArtifacts(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION).iterator().next();
assertEquals(Collections.singleton(TEST_FACET_ID), metadata.getFacetIds());
TestMetadataFacet testFacet = (TestMetadataFacet) metadata.getFacet(TEST_FACET_ID);
assertEquals("baz", testFacet.getValue());
}
Aggregations