Search in sources :

Example 6 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class AbstractMetadataRepositoryTest method testUpdateProjectVersionMetadataWithNoOtherArchives.

@Test
public void testUpdateProjectVersionMetadataWithNoOtherArchives() throws Exception {
    ProjectVersionMetadata metadata = new ProjectVersionMetadata();
    metadata.setId(TEST_PROJECT_VERSION);
    MailingList mailingList = new MailingList();
    mailingList.setName("Foo List");
    mailingList.setOtherArchives(Collections.<String>emptyList());
    metadata.setMailingLists(Arrays.asList(mailingList));
    repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
    metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
    assertEquals(TEST_PROJECT_VERSION, metadata.getId());
    List<MailingList> mailingLists = metadata.getMailingLists();
    assertThat(mailingLists).isNotNull().isNotEmpty().hasSize(1);
    mailingList = metadata.getMailingLists().get(0);
    assertEquals("Foo List", mailingList.getName());
    List<String> others = mailingList.getOtherArchives();
    assertThat(others).isNotNull().isEmpty();
}
Also used : ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) MailingList(org.apache.archiva.metadata.model.MailingList) Test(org.junit.Test)

Example 7 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class AbstractMetadataRepositoryTest method testUpdateProjectVersionMetadataWithNoExistingFacets.

@Test
public void testUpdateProjectVersionMetadataWithNoExistingFacets() throws Exception {
    ProjectVersionMetadata metadata = new ProjectVersionMetadata();
    metadata.setId(TEST_PROJECT_VERSION);
    repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
    metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
    assertThat(metadata.getFacetIds()).isNotNull().isEmpty();
    metadata = new ProjectVersionMetadata();
    metadata.setId(TEST_PROJECT_VERSION);
    repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
    metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
    assertThat(metadata.getFacetIds()).isNotNull().isEmpty();
}
Also used : ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Test(org.junit.Test)

Example 8 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata in project archiva by apache.

the class AbstractMetadataRepositoryTest method testGetProjectVersionOnly.

@Test
public void testGetProjectVersionOnly() throws Exception {
    assertNull(repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION));
    assertNull(repository.getProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT));
    assertThat(repository.getRootNamespaces(TEST_REPO_ID)).isNotNull().isEmpty();
    ProjectVersionMetadata metadata = new ProjectVersionMetadata();
    metadata.setId(TEST_PROJECT_VERSION);
    repository.updateProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata);
    metadata = repository.getProjectVersion(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION);
    assertEquals(TEST_PROJECT_VERSION, metadata.getId());
    // test that namespace and project is also constructed
    Collection<String> namespaces = repository.getRootNamespaces(TEST_REPO_ID);
    assertThat(namespaces).isNotNull().isNotEmpty().hasSize(1).contains(TEST_NAMESPACE);
    ProjectMetadata projectMetadata = repository.getProject(TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT);
    assertNotNull(projectMetadata);
    assertEquals(TEST_PROJECT, projectMetadata.getId());
    assertEquals(TEST_NAMESPACE, projectMetadata.getNamespace());
}
Also used : ProjectMetadata(org.apache.archiva.metadata.model.ProjectMetadata) ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) Test(org.junit.Test)

Example 9 with ProjectVersionMetadata

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

Example 10 with ProjectVersionMetadata

use of org.apache.archiva.metadata.model.ProjectVersionMetadata 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));
}
Also used : ProjectVersionMetadata(org.apache.archiva.metadata.model.ProjectVersionMetadata) 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

ProjectVersionMetadata (org.apache.archiva.metadata.model.ProjectVersionMetadata)44 Test (org.junit.Test)29 ReadMetadataRequest (org.apache.archiva.metadata.repository.storage.ReadMetadataRequest)19 ArrayList (java.util.ArrayList)14 Dependency (org.apache.archiva.metadata.model.Dependency)11 MetadataFacet (org.apache.archiva.metadata.model.MetadataFacet)8 HashMap (java.util.HashMap)7 GenericMetadataFacet (org.apache.archiva.metadata.generic.GenericMetadataFacet)6 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)5 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)5 RepositoryStorageRuntimeException (org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException)5 CiManagement (org.apache.archiva.metadata.model.CiManagement)4 IssueManagement (org.apache.archiva.metadata.model.IssueManagement)4 MailingList (org.apache.archiva.metadata.model.MailingList)4 Scm (org.apache.archiva.metadata.model.Scm)4 MetadataResolutionException (org.apache.archiva.metadata.repository.MetadataResolutionException)4 RepositoryStorageMetadataInvalidException (org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException)4 RepositoryStorageMetadataNotFoundException (org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException)4 Path (java.nio.file.Path)3 License (org.apache.archiva.metadata.model.License)3