[MNG-4904] Make MavenExecutionResult.getTopologicallySortedProjects() return empty list instead of null

Submitted by: Basil James Whitehouse III

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1036585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2010-11-18 19:28:53 +00:00
parent 381f2ac253
commit 0bfec136db
3 changed files with 18 additions and 1 deletions

View File

@ -63,7 +63,7 @@ public class DefaultMavenExecutionResult
public List<MavenProject> getTopologicallySortedProjects() public List<MavenProject> getTopologicallySortedProjects()
{ {
return topologicallySortedProjects; return null == topologicallySortedProjects ? Collections.<MavenProject> emptyList() : topologicallySortedProjects;
} }
public DependencyResolutionResult getDependencyResolutionResult() public DependencyResolutionResult getDependencyResolutionResult()

View File

@ -33,6 +33,10 @@ public interface MavenExecutionResult
MavenProject getProject(); MavenProject getProject();
MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> projects ); MavenExecutionResult setTopologicallySortedProjects( List<MavenProject> projects );
/**
* @return the sorted list, or an empty list if there are no projects.
*/
List<MavenProject> getTopologicallySortedProjects(); List<MavenProject> getTopologicallySortedProjects();
MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult result ); MavenExecutionResult setDependencyResolutionResult( DependencyResolutionResult result );

View File

@ -19,6 +19,10 @@ package org.apache.maven.execution;
* under the License. * under the License.
*/ */
import org.apache.maven.project.MavenProject;
import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
/** /**
@ -35,5 +39,14 @@ public class DefaultMavenExecutionTest
assertNotNull( copy ); assertNotNull( copy );
assertNotSame( copy, original ); assertNotSame( copy, original );
} }
public void testResultWithNullTopologicallySortedProjectsIsEmptyList()
{
MavenExecutionResult result = new DefaultMavenExecutionResult();
result.setTopologicallySortedProjects( null );
List<MavenProject> projects = result.getTopologicallySortedProjects();
assertNotNull( projects );
assertTrue( projects.isEmpty() );
}
} }