Search in sources :

Example 1 with SimpleProjectVersionRef

use of org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef in project indy by Commonjava.

the class MavenMetadataGeneratorTest method generateFileContent_VersionsMetadataWith2Versions.

@Test
public void generateFileContent_VersionsMetadataWith2Versions() throws Exception {
    final StoreResource resource = setupVersionsStructureWith2Versions();
    final ConcreteResource metadataFile = resource.getChild("maven-metadata.xml");
    final Transfer transfer = generator.generateFileContent(stores.getArtifactStore(resource.getStoreKey()), metadataFile.getPath(), new EventMetadata());
    assertThat(transfer, notNullValue());
    final MavenMetadataView metadata = metadataReader.readMetadata(new SimpleProjectVersionRef("org.group", "artifact", "1.0-SNAPSHOT"), Collections.singletonList(transfer), new EventMetadata());
    assertThat(metadata, notNullValue());
    final VersioningView versioning = metadata.getVersioning();
    final List<SingleVersion> versions = versioning.getVersions();
    assertThat(versions, notNullValue());
    assertThat(versions.get(0).renderStandard(), equalTo("1.0"));
    assertThat(versions.get(1).renderStandard(), equalTo("1.1"));
    assertThat(versioning.getReleaseVersion().renderStandard(), equalTo("1.1"));
    assertThat(versioning.getLatestVersion().renderStandard(), equalTo("1.1"));
}
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) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleProjectVersionRef(org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef) SingleVersion(org.commonjava.atlas.maven.ident.version.SingleVersion) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 2 with SimpleProjectVersionRef

use of org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef 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.atlas.maven.ident.version.part.SnapshotPart) Transfer(org.commonjava.maven.galley.model.Transfer) SimpleProjectVersionRef(org.commonjava.atlas.maven.ident.ref.SimpleProjectVersionRef) LatestSnapshotView(org.commonjava.maven.galley.maven.model.view.meta.LatestSnapshotView) SingleVersion(org.commonjava.atlas.maven.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

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