ScheduledTaskImpl implements ScheduledTask { synchronized boolean setInterrupted() { if (state == State.RUNNING) { state = State.INTERRUPTED; return true; } return false; } 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 setInterruptedWhenRunnable() throws Exception { setTaskState("RUNNABLE"); Assert.assertFalse(task.setInterrupted()); Assert.assertEquals("RUNNABLE", getTaskState()); }
@Test public void setInterruptedWhenRunning() throws Exception { setTaskState("RUNNING"); Assert.assertTrue(task.setInterrupted()); Assert.assertEquals("INTERRUPTED", getTaskState()); }
@Test public void setInterruptedWhenInterrupted() throws Exception { setTaskState("INTERRUPTED"); Assert.assertFalse(task.setInterrupted()); Assert.assertEquals("INTERRUPTED", getTaskState()); }
@Test public void setInterruptedWhenCompleted() throws Exception { setTaskState("COMPLETED"); Assert.assertFalse(task.setInterrupted()); Assert.assertEquals("COMPLETED", getTaskState()); }
@Test public void setInterruptedWhenCancelled() throws Exception { setTaskState("CANCELLED"); Assert.assertFalse(task.setInterrupted()); Assert.assertEquals("CANCELLED", getTaskState()); }