// TODO: eventually, move to just use the metadata directly, with minimal JSP changes, mostly for Maven specifics
model = new ArchivaProjectModel();
MavenProjectFacet projectFacet = (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
- model.setGroupId( projectFacet.getGroupId() );
- model.setArtifactId( projectFacet.getArtifactId() );
- model.setPackaging( projectFacet.getPackaging() );
- if ( projectFacet.getParent() != null )
+ if ( projectFacet != null )
{
- VersionedReference parent = new VersionedReference();
- parent.setGroupId( projectFacet.getParent().getGroupId() );
- parent.setArtifactId( projectFacet.getParent().getArtifactId() );
- parent.setVersion( projectFacet.getParent().getVersion() );
- model.setParentProject( parent );
+ model.setGroupId( projectFacet.getGroupId() );
+ model.setArtifactId( projectFacet.getArtifactId() );
+ model.setPackaging( projectFacet.getPackaging() );
+ if ( projectFacet.getParent() != null )
+ {
+ VersionedReference parent = new VersionedReference();
+ parent.setGroupId( projectFacet.getParent().getGroupId() );
+ parent.setArtifactId( projectFacet.getParent().getArtifactId() );
+ parent.setVersion( projectFacet.getParent().getVersion() );
+ model.setParentProject( parent );
+ }
}
model.setVersion( versionMetadata.getId() );
assertTrue( action.getSnapshotVersions().isEmpty() );
}
+ public void testGetArtifactNoMavenFacet()
+ {
+ ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
+ versionMetadata.setId( TEST_VERSION );
+ versionMetadata.setUrl( TEST_URL );
+ versionMetadata.setName( TEST_NAME );
+ versionMetadata.setDescription( TEST_DESCRIPTION );
+
+ metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+ setActionParameters();
+
+ String result = action.artifact();
+
+ assertActionSuccess( action, result );
+
+ assertActionParameters( action );
+ ArchivaProjectModel model = action.getModel();
+ assertEquals( TEST_VERSION, model.getVersion() );
+ assertEquals( TEST_URL, model.getUrl() );
+ assertEquals( TEST_NAME, model.getName() );
+ assertEquals( TEST_DESCRIPTION, model.getDescription() );
+
+ assertEquals( TEST_REPO, action.getRepositoryId() );
+
+ assertNull( action.getDependees() );
+ assertNull( action.getDependencies() );
+ assertNull( action.getMailingLists() );
+ assertTrue( action.getSnapshotVersions().isEmpty() );
+ }
+
private void assertNoOutputFields()
{
assertNull( action.getModel() );