ScheduledTaskImpl implements ScheduledTask { synchronized boolean setRunning(boolean running) { if (isDone()) { return false; } if (running) { if ((state != State.RUNNABLE) && (state != State.INTERRUPTED)) { return false; } state = State.RUNNING; } else { if (state != State.RUNNING) { return false; } state = State.RUNNABLE; notifyAll(); } return true; } private  ScheduledTaskImpl(Builder builder); KernelRunnable getTask(); Identity getOwner(); Priority getPriority(); long getStartTime(); long getPeriod(); int getTryCount(); long getTimeout(); Throwable getLastFailure(); void setPriority(Priority priority); boolean isRecurring(); RecurringTaskHandle getRecurringTaskHandle(); synchronized boolean isCancelled(); synchronized boolean cancel(boolean block); void setTimeout(long timeout); String toString();  }
@Test public void setRunningTrueWhenRunnable() throws Exception { setTaskState("RUNNABLE"); Assert.assertTrue(task.setRunning(true)); Assert.assertEquals("RUNNING", getTaskState()); }
@Test public void setRunningTrueWhenRunning() throws Exception { setTaskState("RUNNING"); Assert.assertFalse(task.setRunning(true)); Assert.assertEquals("RUNNING", getTaskState()); }
@Test public void setRunningTrueWhenInterrupted() throws Exception { setTaskState("INTERRUPTED"); Assert.assertTrue(task.setRunning(true)); Assert.assertEquals("RUNNING", getTaskState()); }
@Test public void setRunningTrueWhenCompleted() throws Exception { setTaskState("COMPLETED"); Assert.assertFalse(task.setRunning(true)); Assert.assertEquals("COMPLETED", getTaskState()); }
@Test public void setRunningTrueWhenCancelled() throws Exception { setTaskState("CANCELLED"); Assert.assertFalse(task.setRunning(true)); Assert.assertEquals("CANCELLED", getTaskState()); }
@Test public void setRunningFalseWhenRunnable() throws Exception { setTaskState("RUNNABLE"); Assert.assertFalse(task.setRunning(false)); Assert.assertEquals("RUNNABLE", getTaskState()); }
@Test public void setRunningFalseWhenRunning() throws Exception { setTaskState("RUNNING"); Assert.assertTrue(task.setRunning(false)); Assert.assertEquals("RUNNABLE", getTaskState()); }
@Test public void setRunningFalseWhenInterrupted() throws Exception { setTaskState("INTERRUPTED"); Assert.assertFalse(task.setRunning(false)); Assert.assertEquals("INTERRUPTED", getTaskState()); }
@Test public void setRunningFalseWhenCompleted() throws Exception { setTaskState("COMPLETED"); Assert.assertFalse(task.setRunning(false)); Assert.assertEquals("COMPLETED", getTaskState()); }
@Test public void setRunningFalseWhenCancelled() throws Exception { setTaskState("CANCELLED"); Assert.assertFalse(task.setRunning(false)); Assert.assertEquals("CANCELLED", getTaskState()); }