package fireTester.messages;
import java.io.Serializable;

import com.dragonsoft.tryapp.common.SubmissionObj;

/**
 * TestUnitResults are the results of a single test unit.
 * 
 * Serializable implemented to transfer test from the client
 * machine back to the server.
 */
public class TestUnitResults implements Serializable {
	private SubmissionObj _submission;
	private boolean _passed, _complete;
	private int _next_unit_id;
	
	/**
	 * Constructor.
	 * 
	 * @param submission the submission to test
	 * @param passed true if test unit passed
	 * @param complete true if test unit execution is complete
	 * @param next_unit_id the next unit id.  ignored if complete=true
	 */
	public TestUnitResults( SubmissionObj submission, boolean passed, boolean complete,
		int next_unit_id) {
		assert submission != null;
		assert complete || next_unit_id > 0;
				
		this._submission = submission;
		this._passed = passed;
		this._complete = complete;
		this._next_unit_id = next_unit_id;
	}
	
	/**
	 * @return the Submission being tested.
	 */
	public SubmissionObj get_submission() {
		return this._submission;
	}
	
	/**
	 * @return True if test passed.
	 */
	public boolean passed() {
		return this._passed;
	}
	
	/**
	 * @return true if test execution is complete
	 */
	public boolean complete() {
		return this._complete;
	}
	
	/**
	 * @return the ID of the next ID, -1 if complete=true
	 */
	public int getNextUnitID() {
		if(!complete())
			return this._next_unit_id;
		
		return -1;
	}
	
}
