### Question:
BuildProjectTaskExecutor implements TaskExecutor { public void executeTask( Task task ) throws TaskExecutionException { BuildProjectTask buildProjectTask = (BuildProjectTask) task; int projectId = buildProjectTask.getProjectId(); try { log.info( "Initializing build (projectId={})", projectId ); BuildContext context = buildContextManager.getBuildContext( projectId ); initializeBuildContext( context ); if ( !checkScmResult( context ) ) { return; } log.info( "Checking if project '{}' should build", context.getProjectName() ); if ( !shouldBuild( context ) ) { return; } log.info( "Starting build of {}", context.getProjectName() ); startBuild( context ); try { try { performAction( "update-project-from-agent-working-directory", context ); } catch ( TaskExecutionException e ) { updateBuildResult( context, ContinuumBuildAgentUtil.throwableToString( e ) ); log.error( "Error executing action update-project-from-agent-working-directory '", e ); } performAction( "execute-agent-builder", context ); log.info( "Updating build result of project '{}'", context.getProjectName() ); updateBuildResult( context, null ); } finally { log.info( "End build of project '{}'", context.getProjectName() ); endBuild( context ); } } catch ( TaskExecutionException e ) { log.error( "Error while trying to build the project {}: {}", projectId, e.getMessage() ); } }  void executeTask( Task task ); void setBuildContextManager( BuildContextManager buildContextManager ); void setActionManager( ActionManager actionManager ); void setBuildAgentConfigurationService( BuildAgentConfigurationService buildAgentConfigurationService ); void setBuildAgentManager( BuildAgentManager buildAgentManager ); void setBuildAgentBuildExecutorManager( BuildAgentBuildExecutorManager buildAgentBuildExecutorManager );  }### Answer:
@Test public void testBuildProjectLocalRepository() throws Exception { try { buildProjectExecutor.executeTask( createBuildProjectTask() ); } catch ( Exception e ) { fail( "An exception should not have been thrown!" ); } assertBuilt(); }
@Test public void testBuildProjectWithConfiguredInstallationsFromBuildAgent() throws Exception { Installation slaveBuildEnvironment = createInstallation( "M2_HOME", "/home/user/apache-maven-2.2.1" ); slaveBuildEnvironments.add( slaveBuildEnvironment ); slaveBuildEnvironment = createInstallation( "EXTRA_VAR", "/home/user/extra" ); slaveBuildEnvironments.add( slaveBuildEnvironment ); try { buildProjectExecutor.executeTask( createBuildProjectTask() ); Map<String, String> environments = (Map<String, String>) buildContext.getActionContext().get( ContinuumBuildAgentUtil.KEY_ENVIRONMENTS ); assertEquals( 2, environments.size() ); assertTrue( environments.containsKey( "M2_HOME" ) ); assertTrue( environments.containsKey( "EXTRA_VAR" ) ); assertEquals( "/home/user/apache-maven-2.2.1", environments.get( "M2_HOME" ) ); assertEquals( "/home/user/extra", environments.get( "EXTRA_VAR" ) ); } catch ( Exception e ) { fail( "An exception should not have been thrown!" ); } assertBuilt(); }
@Test public void testBuildProjectWithNoConfiguredInstallationsFromBuildAgent() throws Exception { try { buildProjectExecutor.executeTask( createBuildProjectTask() ); Map<String, String> environments = (Map<String, String>) buildContext.getActionContext().get( ContinuumBuildAgentUtil.KEY_ENVIRONMENTS ); assertEquals( 1, environments.size() ); assertTrue( environments.containsKey( "M2_HOME" ) ); assertEquals( "/tmp/apache-maven-2.2.1", environments.get( "M2_HOME" ) ); } catch ( Exception e ) { fail( "An exception should not have been thrown!" ); } assertBuilt(); }