Search in sources :

Example 1 with SnapshotArtifactView

use of org.commonjava.maven.galley.maven.model.view.meta.SnapshotArtifactView in project indy by Commonjava.

the class MavenMetadataGeneratorTest method generateFileContent_SnapshotMetadataWith2Versions.

@Test
public void generateFileContent_SnapshotMetadataWith2Versions() throws Exception {
    final StoreResource resource = setupSnapshotDirWith2Snapshots();
    final EventMetadata emd = new EventMetadata();
    final Transfer transfer = generator.generateFileContent(stores.getArtifactStore(resource.getStoreKey()), resource.getChild("maven-metadata.xml").getPath(), emd);
    assertThat(transfer, notNullValue());
    final MavenMetadataView metadata = metadataReader.readMetadata(new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT"), Collections.singletonList(transfer), emd);
    assertThat(metadata, notNullValue());
    final VersioningView versioning = metadata.getVersioning();
    final LatestSnapshotView latestSnapshot = versioning.getLatestSnapshot();
    assertThat(latestSnapshot.isLocalCopy(), equalTo(false));
    assertThat(latestSnapshot.getTimestamp(), equalTo(SnapshotUtils.parseSnapshotTimestamp("20140828.225800")));
    assertThat(latestSnapshot.getBuildNumber(), equalTo(1));
    final List<SnapshotArtifactView> snapshots = versioning.getSnapshotArtifacts();
    assertThat(snapshots.size(), equalTo(4));
    for (final SnapshotArtifactView snap : snapshots) {
        final String extension = snap.getExtension();
        assertThat(extension.equals("jar") || extension.equals("pom"), equalTo(true));
        final String version = snap.getVersion();
        System.out.println(version);
        final SingleVersion parsed = VersionUtils.createSingleVersion(version);
        assertThat(parsed.isSnapshot(), equalTo(true));
        assertThat(parsed.isLocalSnapshot(), equalTo(false));
        final SnapshotPart part = parsed.getSnapshotPart();
        final String tstamp = SnapshotUtils.generateSnapshotTimestamp(part.getTimestamp());
        assertThat(tstamp.equals("20140828.225800") || tstamp.equals("20140828.221400"), equalTo(true));
    }
}
Also used : MavenMetadataView(org.commonjava.maven.galley.maven.model.view.meta.MavenMetadataView) VersioningView(org.commonjava.maven.galley.maven.model.view.meta.VersioningView) StoreResource(org.commonjava.indy.content.StoreResource) SnapshotPart(org.commonjava.maven.atlas.ident.version.part.SnapshotPart) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) LatestSnapshotView(org.commonjava.maven.galley.maven.model.view.meta.LatestSnapshotView) SingleVersion(org.commonjava.maven.atlas.ident.version.SingleVersion) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) SnapshotArtifactView(org.commonjava.maven.galley.maven.model.view.meta.SnapshotArtifactView) Test(org.junit.Test)

Aggregations

StoreResource (org.commonjava.indy.content.StoreResource)1 SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)1 SingleVersion (org.commonjava.maven.atlas.ident.version.SingleVersion)1 SnapshotPart (org.commonjava.maven.atlas.ident.version.part.SnapshotPart)1 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)1 LatestSnapshotView (org.commonjava.maven.galley.maven.model.view.meta.LatestSnapshotView)1 MavenMetadataView (org.commonjava.maven.galley.maven.model.view.meta.MavenMetadataView)1 SnapshotArtifactView (org.commonjava.maven.galley.maven.model.view.meta.SnapshotArtifactView)1 VersioningView (org.commonjava.maven.galley.maven.model.view.meta.VersioningView)1 Transfer (org.commonjava.maven.galley.model.Transfer)1 Test (org.junit.Test)1