@Test
public void testUpdateProjectVersionMetadataWithAllElements()
throws Exception
{
ProjectVersionMetadata metadata = new ProjectVersionMetadata();
metadata.setId( TEST_PROJECT_VERSION );
metadata.setName( "project name" );
metadata.setDescription( "project description" );
metadata.setUrl( "the url" );
MailingList mailingList = new MailingList();
mailingList.setName( "Foo List" );
mailingList.setUnsubscribeAddress( "UnsubscribeAddress" );
mailingList.setSubscribeAddress( "SubscribeAddress" );
mailingList.setPostAddress( "PostAddress" );
mailingList.setMainArchiveUrl( "MainArchiveUrl" );
mailingList.setOtherArchives( Arrays.asList( "other archive" ) );
metadata.setMailingLists( Arrays.asList( mailingList ) );
Scm scm = new Scm();
scm.setConnection( "connection" );
scm.setDeveloperConnection( "dev conn" );
scm.setUrl( "url" );
metadata.setScm( scm );
CiManagement ci = new CiManagement();
ci.setSystem( "system" );
ci.setUrl( "ci url" );
metadata.setCiManagement( ci );
IssueManagement tracker = new IssueManagement();
tracker.setSystem( "system" );
tracker.setUrl( "issue tracker url" );
metadata.setIssueManagement( tracker );
Organization org = new Organization();
org.setName( "org name" );
org.setUrl( "url" );
metadata.setOrganization( org );
License l = new License();
l.setName( "license name" );
l.setUrl( "license url" );
metadata.addLicense( l );
Dependency d = new Dependency();
d.setArtifactId( "artifactId" );
d.setClassifier( "classifier" );
d.setGroupId( "groupId" );
d.setScope( "scope" );
d.setSystemPath( "system path" );
d.setType( "type" );
d.setVersion( "version" );
d.setOptional( true );
metadata.addDependency( d );
repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
assertEquals( TEST_PROJECT_VERSION, metadata.getId() );
assertEquals( TEST_PROJECT_VERSION, metadata.getVersion() );
assertEquals( "project name", metadata.getName() );
assertEquals( "project description", metadata.getDescription() );
assertEquals( "the url", metadata.getUrl() );
assertEquals( "connection", metadata.getScm().getConnection() );
assertEquals( "dev conn", metadata.getScm().getDeveloperConnection() );
assertEquals( "url", metadata.getScm().getUrl() );
assertEquals( "system", metadata.getCiManagement().getSystem() );
assertEquals( "ci url", metadata.getCiManagement().getUrl() );
assertEquals( "system", metadata.getIssueManagement().getSystem() );
assertEquals( "issue tracker url", metadata.getIssueManagement().getUrl() );
assertEquals( "org name", metadata.getOrganization().getName() );
assertEquals( "url", metadata.getOrganization().getUrl() );
assertEquals( 1, metadata.getMailingLists().size() );
MailingList retrievedMailingList = metadata.getMailingLists().get( 0 );
assertEquals( mailingList.getName(), retrievedMailingList.getName() );
assertEquals( mailingList.getMainArchiveUrl(), retrievedMailingList.getMainArchiveUrl() );
assertEquals( mailingList.getPostAddress(), retrievedMailingList.getPostAddress() );
assertEquals( mailingList.getSubscribeAddress(), retrievedMailingList.getSubscribeAddress() );
assertEquals( mailingList.getUnsubscribeAddress(), retrievedMailingList.getUnsubscribeAddress() );
assertThat( retrievedMailingList.getOtherArchives() ) //
.isNotNull() //
.isNotEmpty() //
.hasSize( 1 ) //
.contains( "other archive" );
assertEquals( 1, metadata.getLicenses().size() );
l = metadata.getLicenses().get( 0 );
assertEquals( "license name", l.getName() );
assertEquals( "license url", l.getUrl() );
assertEquals( 1, metadata.getDependencies().size() );
d = metadata.getDependencies().get( 0 );
assertEquals( "artifactId", d.getArtifactId() );
assertEquals( "classifier", d.getClassifier() );
assertEquals( "groupId", d.getGroupId() );
assertEquals( "scope", d.getScope() );
assertEquals( "system path", d.getSystemPath() );