package fireTester.interfaces;

import java.io.File;
import java.io.Serializable;

import com.dragonsoft.tryapp.common.SubmissionObj;

import fireTester.messages.MaxDirectorySizeExceededException;
import fireTester.messages.TimeoutExceededException;
import fireTester.messages.UnknownException;



/**
 * A SubmissionTest is the object that will be executed on a single client on the 
 * distributed network.  It may be comprised of multiple test units.  Each unit
 * must report TestUnitResults back to the server before executing the remaining units.
 * 
 * @author Nick Mancuso
 * 
 * Serializable implemented to transfer test from the server
 * to a client machine.
 */
public interface SubmissionTest extends Serializable {
	/**
	 * @return a unique identifier.  May be an Object of any type that is serializable.
	 */
	public SubmissionObj get_submission();
	
	/**
	 * @param unitID the unit to check
	 * 
	 * @return the maximum number of ms the specified unit is allowed to run
	 */
	public long getUnitTimeout(int unitID);
	
	/**
	 * Begins test execution.  This call will block until all test units
	 * have completed - or till the first required test fails.
	 * 
	 * @param resultsController the object needed to send results
	 * 
	 * @throws TimeoutExceededException the executing command was halted because 
	 * 	the timeout had been violated.
	 * @throws MaxDirectorySizeExceededException the executing command was halted
	 * 	because the max directory size had been violated.
	 * @throws UnknownException an unknown exception has occured.
	 */
	public void execute(ClientController resultsController) throws TimeoutExceededException, MaxDirectorySizeExceededException, UnknownException;
	
	/**
	 * The directory to save the results too.
	 * 
	 * @return directory.
	 */
	public File getSaveDir();
	
	/**
	 * @param submission The submission object.
	 * @param saveDir the directory to save the results too.
	 */
	public void set_submission(SubmissionObj submission, File saveDir);
}
