buildDef.setId( 1 );
buildDef.setSchedule( getSchedule( 1, 1, 2 ) );
recordBuildProjectBuildQueuesAreEmpty();
buildsManager.buildProject( 1, buildDef, "continuum-project-test-1", new BuildTrigger( 1, "test-user" ), null, 1 );
context.assertIsSatisfied();
//queue second project - 1st queue is not empty, 2nd queue is empty
recordStartOfBuildProjectSequence();
// the first build queue already has a task queued
final List<Task> tasks = new ArrayList<Task>();
final List<Task> tasksOfFirstBuildQueue = new ArrayList<Task>();
tasksOfFirstBuildQueue.add(
new BuildProjectTask( 2, 1, new BuildTrigger( 1, "test-user" ), "continuum-project-test-2", buildDef.getDescription(), null, 2 ) );
context.checking( new Expectations()
{
{
one( buildQueue ).getQueueSnapshot();
will( returnValue( tasksOfFirstBuildQueue ) );
// the second build queue has no tasks queued, so it should return 0
one( buildQueue ).getQueueSnapshot();
will( returnValue( tasks ) );
exactly( 2 ).of( buildTaskQueueExecutor ).getCurrentTask();
will( returnValue( null ) );
one( overallBuildQueue ).getName();
will( returnValue( "BUILD_QUEUE_3" ) );
}} );
recordAddToBuildQueue();
buildsManager.buildProject( 2, buildDef, "continuum-project-test-2", new BuildTrigger( 1, "test-user" ), null, 2 );
context.assertIsSatisfied();
// queue third project - both queues have 1 task queued each
recordStartOfBuildProjectSequence();
// both queues have 1 task each
context.checking( new Expectations()
{
{
exactly( 2 ).of( buildQueue ).getQueueSnapshot();
will( returnValue( tasksOfFirstBuildQueue ) );
exactly( 2 ).of( buildTaskQueueExecutor ).getCurrentTask();
will( returnValue( null ) );
one( overallBuildQueue ).getName();
will( returnValue( "BUILD_QUEUE_2" ) );
}} );
recordAddToBuildQueue();
buildsManager.buildProject( 3, buildDef, "continuum-project-test-3", new BuildTrigger( 1, "test-user" ), null, 3 );
context.assertIsSatisfied();
}