use of org.commonjava.maven.galley.maven.model.view.meta.VersioningView 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"));
}
use of org.commonjava.maven.galley.maven.model.view.meta.VersioningView 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));
}
}
Aggregations