Search in sources :

Example 36 with ReadMetadataRequest

use of org.apache.archiva.metadata.repository.storage.ReadMetadataRequest in project archiva by apache.

the class Maven2RepositoryMetadataResolverTest method testGetArtifactMetadataSnapshots.

@Test
public void testGetArtifactMetadataSnapshots() throws Exception {
    Collection<ArtifactMetadata> testArtifacts = storage.readArtifactsMetadata(new ReadMetadataRequest(TEST_REPO_ID, "com.example.test", "test-artifact", "1.0-SNAPSHOT", ALL));
    List<ArtifactMetadata> artifacts = new ArrayList<>(testArtifacts);
    Collections.sort(artifacts, new Comparator<ArtifactMetadata>() {

        @Override
        public int compare(ArtifactMetadata o1, ArtifactMetadata o2) {
            return o1.getId().compareTo(o2.getId());
        }
    });
    assertEquals(6, artifacts.size());
    ArtifactMetadata artifactMetadata = artifacts.get(0);
    assertEquals("test-artifact-1.0-20100308.230825-1.jar", artifactMetadata.getId());
    MavenArtifactFacet facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
    assertEquals(1, facet.getBuildNumber());
    assertEquals("20100308.230825", facet.getTimestamp());
    assertNull(facet.getClassifier());
    assertEquals("jar", facet.getType());
    artifactMetadata = artifacts.get(1);
    assertEquals("test-artifact-1.0-20100308.230825-1.pom", artifactMetadata.getId());
    facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
    assertEquals(1, facet.getBuildNumber());
    assertEquals("20100308.230825", facet.getTimestamp());
    assertNull(facet.getClassifier());
    assertEquals("pom", facet.getType());
    artifactMetadata = artifacts.get(2);
    assertEquals("test-artifact-1.0-20100310.014828-2-javadoc.jar", artifactMetadata.getId());
    facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
    assertEquals(2, facet.getBuildNumber());
    assertEquals("20100310.014828", facet.getTimestamp());
    assertEquals("javadoc", facet.getClassifier());
    assertEquals("javadoc", facet.getType());
    artifactMetadata = artifacts.get(3);
    assertEquals("test-artifact-1.0-20100310.014828-2-sources.jar", artifactMetadata.getId());
    facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
    assertEquals(2, facet.getBuildNumber());
    assertEquals("20100310.014828", facet.getTimestamp());
    assertEquals("sources", facet.getClassifier());
    assertEquals("java-source", facet.getType());
    artifactMetadata = artifacts.get(4);
    assertEquals("test-artifact-1.0-20100310.014828-2.jar", artifactMetadata.getId());
    facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
    assertEquals(2, facet.getBuildNumber());
    assertEquals("20100310.014828", facet.getTimestamp());
    assertNull(facet.getClassifier());
    assertEquals("jar", facet.getType());
    artifactMetadata = artifacts.get(5);
    assertEquals("test-artifact-1.0-20100310.014828-2.pom", artifactMetadata.getId());
    facet = (MavenArtifactFacet) artifactMetadata.getFacet(MavenArtifactFacet.FACET_ID);
    assertEquals(2, facet.getBuildNumber());
    assertEquals("20100310.014828", facet.getTimestamp());
    assertNull(facet.getClassifier());
    assertEquals("pom", facet.getType());
}
Also used : ReadMetadataRequest(org.apache.archiva.metadata.repository.storage.ReadMetadataRequest) ArrayList(java.util.ArrayList) MavenArtifactFacet(org.apache.archiva.metadata.model.maven2.MavenArtifactFacet) ArtifactMetadata(org.apache.archiva.metadata.model.ArtifactMetadata) Test(org.junit.Test)

Aggregations

ReadMetadataRequest (org.apache.archiva.metadata.repository.storage.ReadMetadataRequest)36 Test (org.junit.Test)31 ProjectVersionMetadata (org.apache.archiva.metadata.model.ProjectVersionMetadata)20 ArrayList (java.util.ArrayList)16 RepositoryStorageMetadataNotFoundException (org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException)8 ArtifactMetadata (org.apache.archiva.metadata.model.ArtifactMetadata)7 Dependency (org.apache.archiva.metadata.model.Dependency)7 RepositoryStorageMetadataInvalidException (org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException)6 RepositoryStorageRuntimeException (org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException)6 MavenArtifactFacet (org.apache.archiva.metadata.model.maven2.MavenArtifactFacet)3 Path (java.nio.file.Path)2 ProjectMetadata (org.apache.archiva.metadata.model.ProjectMetadata)2 RepositoryListener (org.apache.archiva.repository.events.RepositoryListener)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 URL (java.net.URL)1 Charset (java.nio.charset.Charset)1 Files (java.nio.file.Files)1 NoSuchFileException (java.nio.file.NoSuchFileException)1