Search in sources :

Example 76 with ArtifactMetadata

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);
}
Also used : ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Date(java.util.Date) Test(org.junit.Test)

Example 77 with ArtifactMetadata

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();
}
Also used : ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Test(org.junit.Test)

Example 78 with ArtifactMetadata

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();
}
Also used : ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Test(org.junit.Test)

Example 79 with ArtifactMetadata

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();
}
Also used : ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Date(java.util.Date) Test(org.junit.Test)

Example 80 with ArtifactMetadata

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());
}
Also used : MetadataFacet(org.apache.archiva.metadata.model.MetadataFacet) GenericMetadataFacet(org.apache.archiva.metadata.generic.GenericMetadataFacet) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Test(org.junit.Test)

Aggregations

ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)96 Test (org.junit.Test)53 ArrayList (java.util.ArrayList)23 Path (java.nio.file.Path)20 MetadataRepositoryException (org.apache.archiva.metadata.repository.MetadataRepositoryException)17 Date (java.util.Date)15 HashSet (java.util.HashSet)11 MetadataFacet (org.apache.archiva.metadata.model.MetadataFacet)10 MavenArtifactFacet (org.apache.archiva.metadata.model.maven2.MavenArtifactFacet)9 HashMap (java.util.HashMap)8 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)8 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)7 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)7 ReadMetadataRequest (org.apache.archiva.metadata.repository.storage.ReadMetadataRequest)7 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)7 ArchivaRestServiceException (org.apache.archiva.rest.api.services.ArchivaRestServiceException)7 Node (javax.jcr.Node)6 ProjectVersionMetadata (org.apache.archiva.metadata.model.ProjectVersionMetadata)6 IOException (java.io.IOException)5 RepositoryException (javax.jcr.RepositoryException)5