package org.cloudcoder.builder2.model;

import java.util.ArrayList;
import java.util.List;

/**
 * A Tester executes a series of {@link IBuildStep}s on a
 * {@link BuilderSubmission}.
 * 
 * @author David Hovemeyer
 */
public class Tester {
	private List<IBuildStep> buildStepList;
	
	/**
	 * Constructor.
	 */
	public Tester() {
		buildStepList = new ArrayList<IBuildStep>();
	}
	
	/**
	 * Add an {@link IBuildStep}.
	 * 
	 * @param buildStep the {@link IBuildStep} to add
	 */
	public void addBuildStep(IBuildStep buildStep) {
		buildStepList.add(buildStep);
	}
	
	/**
	 * Execute the Tester on a {@link BuilderSubmission}.
	 * 
	 * @param submission the {@link BuilderSubmission} to build/test
	 */
	public void execute(BuilderSubmission submission) {
		for (IBuildStep buildStep : buildStepList) {
			buildStep.execute(submission);
			if (submission.isComplete()) {
				break;
			}
		}
		
		if (!submission.isComplete()) {
			throw new InternalBuilderException("Executed all build steps but submission is not complete");
		}
	}
}

@@ -1,8 +1,878 @@
+// CloudCoder - a web-based pedagogical programming environment%0A// Copyright (C) 2011-2012, Jaime Spacco %3Cjspacco@knox.edu%3E%0A// Copyright (C) 2011-2012, David H. Hovemeyer %3Cdavid.hovemeyer@gmail.com%3E%0A//%0A// This program is free software: you can redistribute it and/or modify%0A// it under the terms of the GNU Affero General Public License as published by%0A// the Free Software Foundation, either version 3 of the License, or%0A// (at your option) any later version.%0A//%0A// This program is distributed in the hope that it will be useful,%0A// but WITHOUT ANY WARRANTY; without even the implied warranty of%0A// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A// GNU Affero General Public License for more details.%0A//%0A// You should have received a copy of the GNU Affero General Public License%0A// along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0A
 package 

add copyright/license header