// Path: src/main/java/com/cobalt/bamboo/plugin/pipeline/cdresult/Build.java
// public class Build {
// 	private ChainResultsSummary buildResult;
// 	private ProgressBar progressBar;
// 
// 	/**
// 	 * Constructs a Build object
// 	 * 
// 	 * @param buildResult from Bamboo to construct off of
// 	 * @param progressBar for builds that are currently building
// 	 */
// 	public Build(ChainResultsSummary buildResult, ProgressBar progressBar){
// 		this.buildResult = buildResult;
// 		this.progressBar = progressBar;
// 	}
// 
// 	/**
// 	 * Returns the build key of this build.
// 	 * Returns null when there are no build yet.
// 	 * 
// 	 * @return build key
// 	 */
// 	public String getBuildKey() {
// 		if (buildResult == null) {
// 			return null;
// 		} else {
// 			return buildResult.getBuildResultKey();
// 		}
// 	}
// 
// 	/**
// 	 * Returns the build number of this build.
// 	 * Returns -1 when there are no build yet.
// 	 * 
// 	 * @return build number
// 	 */
// 	public int getBuildNumber() {
// 		if (buildResult == null) {
// 			return -1;
// 		} else {
// 			return buildResult.getBuildNumber();
// 		}
// 	}
// 
// 	/**
// 	 * Get the CDPipelineState based on the state of buildResult, but only
// 	 * includes the states that are to the interest of our users, of this pipeline stage.
// 	 * 
// 	 * @return the CDPipelineState, which can be CD_SUCCESS, CD_FAILED, CD_IN_PROGRESS, 
// 	 * 			CD_NOT_BUILT, CD_MANUALLY_PAUSED
// 	 */
// 	public CDPipelineState getCDPipelineState() {
// 		if (buildResult == null) {
// 			return CDPipelineState.CD_NOT_BUILT;
// 		} else {
// 			if (buildResult.isSuccessful()) {
// 				if (buildResult.isContinuable()) {
// 					return CDPipelineState.CD_MANUALLY_PAUSED;
// 				} else {
// 					return CDPipelineState.CD_SUCCESS;
// 				}
// 			} else if (buildResult.isFailed()) {
// 				return CDPipelineState.CD_FAILED;
// 			} else if (buildResult.isInProgress() || getPercentageCompleted() > 0) {
// 				return CDPipelineState.CD_IN_PROGRESS;
// 			} else if (buildResult.isQueued()) {
// 				return CDPipelineState.CD_QUEUED;
// 			} else {
// 				return CDPipelineState.CD_NOT_BUILT;
// 			}
// 		}
// 	}
// 	
// 	/**
// 	 * Get the percentage completed if this Build is currently building.
// 	 * 
// 	 * @return percentage completed in double format if this Build is currently building,
// 	 *         -1 otherwise.
// 	 */
// 	public double getPercentageCompleted() {
// 		if (progressBar != null) {
// 			return progressBar.getPercentageCompleted();
// 		}
// 		return -1;
// 	}
// 	
// 	/**
// 	 * Get the time remaining if this Build is currently building.
// 	 * 
// 	 * @return time remaining in pretty string format if this Build is currently building,
// 	 *         null otherwise.
// 	 */
// 	public String getTimeRemaining() {
// 		if (progressBar != null) {
// 			return progressBar.getPrettyTimeRemaining(false);
// 		}
// 		return null;
// 	}
// 	
// 	/**
// 	 * Get the completed date of this build.
// 	 * 
// 	 * @return the completed Date of this build.
// 	 */
// 	public Date getBuildCompletedDate() {
// 		if(buildResult == null){
// 			return null;
// 		}
// 		return buildResult.getBuildCompletedDate();
// 	}
// 	
// 	/**
// 	 * Return whether this build is successful.
// 	 * 
// 	 * @return true if this build is successful, false otherwise.
// 	 */
// 	public boolean isSuccessful() {
// 		if(buildResult == null){
// 			return false;
// 		}
// 		return buildResult.isSuccessful();
// 	}
// }


import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Date;
import org.junit.Test;
import com.cobalt.bamboo.plugin.pipeline.cdresult.Build;
		Date currentBuildDate = new Date(current.getTime() - 100000);
		Date startDate = new Date(current.getTime() - 200000);
		UptimeGrade g = new UptimeGrade(startDate, 0, false, currentBuildDate);
		assertEquals("Uptime percentage is not as expected.", 0, g.getUptimePercentage(), 0.0001);
		assertEquals("Grade is not as expected.", "F", g.getGrade());
	}
	
	@Test
	public void testWithTotalUpTimeSuccess() {
		Date current = new Date();
		Date currentBuildDate = new Date(current.getTime() - 100000);
		Date startDate = new Date(current.getTime() - 200000);
		UptimeGrade g = new UptimeGrade(startDate, 50000, true, currentBuildDate);
		assertEquals("Uptime percentage is not as expected.", 0.75, g.getUptimePercentage(), 0.0001);
		assertEquals("Grade is not as expected.", "C", g.getGrade());
	}
	
	@Test
	public void testWithTotalUpTimeFail() {
		Date current = new Date();
		Date currentBuildDate = new Date(current.getTime() - 100000);
		Date startDate = new Date(current.getTime() - 200000);
		UptimeGrade g = new UptimeGrade(startDate, 50000, false, currentBuildDate);
		assertEquals("Uptime percentage is not as expected.", 0.25, g.getUptimePercentage(), 0.0001);
		assertEquals("Grade is not as expected.", "F", g.getGrade());
	}
	
	@Test
	public void testUpdateNoStartGradeWithIncompletedBuild() {
		UptimeGrade g = new UptimeGrade(null, 0, false, null);
// Path: src/main/java/com/cobalt/bamboo/plugin/pipeline/cdresult/Build.java
// public class Build {
// 	private ChainResultsSummary buildResult;
// 	private ProgressBar progressBar;
// 
// 	/**
// 	 * Constructs a Build object
// 	 * 
// 	 * @param buildResult from Bamboo to construct off of
// 	 * @param progressBar for builds that are currently building
// 	 */
// 	public Build(ChainResultsSummary buildResult, ProgressBar progressBar){
// 		this.buildResult = buildResult;
// 		this.progressBar = progressBar;
// 	}
// 
// 	/**
// 	 * Returns the build key of this build.
// 	 * Returns null when there are no build yet.
// 	 * 
// 	 * @return build key
// 	 */
// 	public String getBuildKey() {
// 		if (buildResult == null) {
// 			return null;
// 		} else {
// 			return buildResult.getBuildResultKey();
// 		}
// 	}
// 
// 	/**
// 	 * Returns the build number of this build.
// 	 * Returns -1 when there are no build yet.
// 	 * 
// 	 * @return build number
// 	 */
// 	public int getBuildNumber() {
// 		if (buildResult == null) {
// 			return -1;
// 		} else {
// 			return buildResult.getBuildNumber();
// 		}
// 	}
// 
// 	/**
// 	 * Get the CDPipelineState based on the state of buildResult, but only
// 	 * includes the states that are to the interest of our users, of this pipeline stage.
// 	 * 
// 	 * @return the CDPipelineState, which can be CD_SUCCESS, CD_FAILED, CD_IN_PROGRESS, 
// 	 * 			CD_NOT_BUILT, CD_MANUALLY_PAUSED
// 	 */
// 	public CDPipelineState getCDPipelineState() {
// 		if (buildResult == null) {
// 			return CDPipelineState.CD_NOT_BUILT;
// 		} else {
// 			if (buildResult.isSuccessful()) {
// 				if (buildResult.isContinuable()) {
// 					return CDPipelineState.CD_MANUALLY_PAUSED;
// 				} else {
// 					return CDPipelineState.CD_SUCCESS;
// 				}
// 			} else if (buildResult.isFailed()) {
// 				return CDPipelineState.CD_FAILED;
// 			} else if (buildResult.isInProgress() || getPercentageCompleted() > 0) {
// 				return CDPipelineState.CD_IN_PROGRESS;
// 			} else if (buildResult.isQueued()) {
// 				return CDPipelineState.CD_QUEUED;
// 			} else {
// 				return CDPipelineState.CD_NOT_BUILT;
// 			}
// 		}
// 	}
// 	
// 	/**
// 	 * Get the percentage completed if this Build is currently building.
// 	 * 
// 	 * @return percentage completed in double format if this Build is currently building,
// 	 *         -1 otherwise.
// 	 */
// 	public double getPercentageCompleted() {
// 		if (progressBar != null) {
// 			return progressBar.getPercentageCompleted();
// 		}
// 		return -1;
// 	}
// 	
// 	/**
// 	 * Get the time remaining if this Build is currently building.
// 	 * 
// 	 * @return time remaining in pretty string format if this Build is currently building,
// 	 *         null otherwise.
// 	 */
// 	public String getTimeRemaining() {
// 		if (progressBar != null) {
// 			return progressBar.getPrettyTimeRemaining(false);
// 		}
// 		return null;
// 	}
// 	
// 	/**
// 	 * Get the completed date of this build.
// 	 * 
// 	 * @return the completed Date of this build.
// 	 */
// 	public Date getBuildCompletedDate() {
// 		if(buildResult == null){
// 			return null;
// 		}
// 		return buildResult.getBuildCompletedDate();
// 	}
// 	
// 	/**
// 	 * Return whether this build is successful.
// 	 * 
// 	 * @return true if this build is successful, false otherwise.
// 	 */
// 	public boolean isSuccessful() {
// 		if(buildResult == null){
// 			return false;
// 		}
// 		return buildResult.isSuccessful();
// 	}
// }


// Path: src/test/java/com/cobalt/bamboo/plugin/pipeline/cdperformance/UptimeGradeTest.java
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Date;
import org.junit.Test;
import com.cobalt.bamboo.plugin.pipeline.cdresult.Build;

		Date currentBuildDate = new Date(current.getTime() - 100000);
		Date startDate = new Date(current.getTime() - 200000);
		UptimeGrade g = new UptimeGrade(startDate, 0, false, currentBuildDate);
		assertEquals("Uptime percentage is not as expected.", 0, g.getUptimePercentage(), 0.0001);
		assertEquals("Grade is not as expected.", "F", g.getGrade());
	}
	
	@Test
	public void testWithTotalUpTimeSuccess() {
		Date current = new Date();
		Date currentBuildDate = new Date(current.getTime() - 100000);
		Date startDate = new Date(current.getTime() - 200000);
		UptimeGrade g = new UptimeGrade(startDate, 50000, true, currentBuildDate);
		assertEquals("Uptime percentage is not as expected.", 0.75, g.getUptimePercentage(), 0.0001);
		assertEquals("Grade is not as expected.", "C", g.getGrade());
	}
	
	@Test
	public void testWithTotalUpTimeFail() {
		Date current = new Date();
		Date currentBuildDate = new Date(current.getTime() - 100000);
		Date startDate = new Date(current.getTime() - 200000);
		UptimeGrade g = new UptimeGrade(startDate, 50000, false, currentBuildDate);
		assertEquals("Uptime percentage is not as expected.", 0.25, g.getUptimePercentage(), 0.0001);
		assertEquals("Grade is not as expected.", "F", g.getGrade());
	}
	
	@Test
	public void testUpdateNoStartGradeWithIncompletedBuild() {
		UptimeGrade g = new UptimeGrade(null, 0, false, null);
		Build build = mock(Build.class);