Don't print null values in DefaultArtifact.toString

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@373073 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Carlos Sanchez Gonzalez 2006-01-28 02:39:17 +00:00
parent e46a983a42
commit 016c8e31b5
2 changed files with 13 additions and 10 deletions

View File

@ -273,8 +273,11 @@ public class DefaultArtifact
public String toString()
{
StringBuffer sb = new StringBuffer();
if ( getGroupId() != null )
{
sb.append( getGroupId() );
sb.append( ":" );
}
appendArtifactTypeClassifierString( sb );
sb.append( ":" );
if ( version != null || baseVersion != null )
@ -285,8 +288,11 @@ public class DefaultArtifact
{
sb.append( versionRange.toString() );
}
if ( scope != null )
{
sb.append( ":" );
sb.append( scope );
}
return sb.toString();
}

View File

@ -75,22 +75,19 @@ public class DefaultArtifactTest
public void testToStringNullGroupId()
{
artifact.setGroupId( null );
assertEquals( null + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact
.toString() );
assertEquals( artifactId + ":" + type + ":" + classifier + ":" + version + ":" + scope, artifact.toString() );
}
public void testToStringNullClassifier()
{
artifact = new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, artifactHandler );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact
.toString() );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + version + ":" + scope, artifact.toString() );
}
public void testToStringNullScope()
{
artifact.setScope( null );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version + ":" + null, artifact
.toString() );
assertEquals( groupId + ":" + artifactId + ":" + type + ":" + classifier + ":" + version, artifact.toString() );
}
}