public void testMergeReleaseAndSnapshot()
throws Exception
{
Metadata release = getReleaseMetadata();
Metadata snapshot = getSnapshotMetadata();
NexusMergeOperation mergeOp = new NexusMergeOperation(new MetadataOperand(release));
mergeOp.perform(snapshot);
// check the snapshot metadata, which should now be merged
assertThat(snapshot.getArtifactId(), equalTo("test"));
assertThat(snapshot.getGroupId(), equalTo("test"));
assertThat(snapshot.getPlugins(), empty());
assertThat(snapshot.getVersion(), nullValue());
assertThat(snapshot.getVersioning(), notNullValue());
assertThat(snapshot.getVersioning().getLastUpdated(), equalTo("1234568"));
assertThat(snapshot.getVersioning().getLatest(), equalTo("1.2-SNAPSHOT"));
assertThat(snapshot.getVersioning().getRelease(), equalTo("1.1"));
assertThat(snapshot.getVersioning().getSnapshot(), nullValue());
assertThat(snapshot.getVersioning().getVersions(), notNullValue());
assertThat(snapshot.getVersioning().getVersions(), containsInAnyOrder("1.1", "1.1-SNAPSHOT", "1.2-SNAPSHOT"));
//now do the merge in reverse
release = getReleaseMetadata();
snapshot = getSnapshotMetadata();
mergeOp = new NexusMergeOperation(new MetadataOperand(snapshot));
mergeOp.perform(release);
// check the release metadata, which should now be merged
assertThat(release.getArtifactId(), equalTo("test"));
assertThat(release.getGroupId(), equalTo("test"));
assertThat(release.getPlugins(), empty());