*/
private PrepareBuildProjectsTask createTask( String pomResource, boolean singleCheckout, boolean buildFresh )
throws Exception
{
ProjectGroup projectGroup = getProjectGroup( pomResource, singleCheckout );
BuildDefinition buildDefinition = new BuildDefinition();
buildDefinition.setId( 0 );
buildDefinition.setGoals( "clean" );
buildDefinition.setBuildFresh( buildFresh );
projectGroup.addBuildDefinition( buildDefinition );
Map<String, Object> pgContext = new HashMap<String, Object>();
AbstractContinuumAction.setWorkingDirectory( pgContext, configurationService.getWorkingDirectory().getAbsolutePath() );
AbstractContinuumAction.setUnvalidatedProjectGroup( pgContext, projectGroup );
actionManager.lookup( "validate-project-group" ).execute( pgContext );
actionManager.lookup( "store-project-group" ).execute( pgContext );
int projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext );
projectGroup = getProjectGroupDao().getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
String scmRootUrl = getScmRootUrl( projectGroup );
assertNotNull( scmRootUrl );
ProjectScmRoot scmRoot = getProjectScmRoot( projectGroup, scmRootUrl );
assertNotNull( scmRoot );
buildDefinition = (BuildDefinition) projectGroup.getBuildDefinitions().get( 0 );
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
Project rootProject = null;
List<Project> projects = (List<Project>) projectGroup.getProjects();
for ( Project project : projects )
{
assertFalse( project.getId() == 0 );
map.put( project.getId(), buildDefinition.getId() );
if ( rootProject == null || rootProject.getId() > project.getId() )
{
rootProject = project;
}
}
assertEquals( 3, map.size() );
PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( map, 1,
projectGroupId, projectGroup.getName(),
scmRoot.getScmRootAddress(), scmRoot.getId() );
return task;
}