use of org.commonjava.maven.galley.maven.model.view.meta.LatestSnapshotView 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