package org.octoprint.api.test;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.octoprint.api.JobCommand;
import org.octoprint.api.OctoPrintInstance;
import org.octoprint.api.OctoPrintJob;
import org.octoprint.api.OctoPrintJob.JobProgress;
import org.octoprint.api.test.util.JSONAnswer;

public class JobCommandTest {
	private JobCommand command = null;
	
	public JobCommandTest() {
		// TODO Auto-generated constructor stub
	}

	@Before
	public void beforeTest(){
		//create a fake instance for http simulation
		OctoPrintInstance i = Mockito.mock(OctoPrintInstance.class,new JSONAnswer("job.json"));
		
		command = new JobCommand(i);
	}
	
	@Test
	public void getNameTest(){
		
		assertEquals("Job Name Correct",command.getJobDetails().getName(),"whistle_v2.gcode");
	}
	
	@Test
	public void getEstimatedTimeTest(){
		
		assertEquals("Estimated Time Remaining",8811,(long)command.getJobDetails().getEstimatedPrintTime().longValue());
	}
	
	public void getPercentCompleteTest(){
		JobProgress p = command.getJobDetails().getJobProgress();
		assertEquals("Percent Complete",.23,p.percentComplete(),1);
	}
	
	public void getElaspedTimeTest(){
		JobProgress p = command.getJobDetails().getJobProgress();
		assertEquals("Elapsed Time",(long)276,p.elapsedTime().longValue());
	}
	
	public void getTimeRemainingTest(){
		JobProgress p = command.getJobDetails().getJobProgress();
		assertEquals("Time Remaining",(long)912,p.timeRemaining().longValue());
	}
}

@@ -61,16 +61,17 @@
 ert.*;%0A%0A
+%0A
 import o
@@ -223,47 +223,8 @@
 ce;%0A
-import org.octoprint.api.OctoPrintJob;%0A
 impo
@@ -318,16 +318,93 @@
 nswer;%0A%0A
+/**%0A * %0A * Test aspects of the JobCommand class%0A * %0A * @author rweber%0A *%0A */%0A
 public c
@@ -768,20 +768,17 @@
 ic void 
-getN
+n
 ameTest(
@@ -897,20 +897,17 @@
 ic void 
-getE
+e
 stimated
@@ -967,19 +967,19 @@
 ng%22,
-8811,
 (long)
+8811,
 comm
@@ -1033,32 +1033,39 @@
 gValue());%0A%09%7D%0A%09%0A
+%09@Test%0A
 %09public void get
@@ -1065,12 +1065,9 @@
 oid 
-getP
+p
 erce
@@ -1203,32 +1203,39 @@
 lete(),1);%0A%09%7D%0A%09%0A
+%09@Test%0A
 %09public void get
@@ -1231,20 +1231,17 @@
 ic void 
-getE
+e
 laspedTi
@@ -1385,16 +1385,23 @@
 );%0A%09%7D%0A%09%0A
+%09@Test%0A
 %09public 
@@ -1409,12 +1409,9 @@
 oid 
-getT
+t
 imeR

update test methods