### Question:
IncrementalSimonsPurger { public synchronized void cancel() { if (scheduledFuture != null) { scheduledFuture.cancel(false); scheduledFuture = null; } else { throw new IllegalStateException("IncrementSimonPurger is either cancelled or was not started"); } } IncrementalSimonsPurger(Manager manager);   IncrementalSimonsPurger(Manager manager, ScheduledExecutorService executorService); synchronized void start(long period, TimeUnit timeUnit); synchronized void cancel();  }### Answer:
@Test public void testCancel() { EnabledManager manager = new EnabledManager(); IncrementalSimonsPurger incrementalSimonsPurger = new IncrementalSimonsPurger(manager, executorService); long duration = 1; TimeUnit timeUnit = TimeUnit.SECONDS; incrementalSimonsPurger.start(duration, timeUnit); incrementalSimonsPurger.cancel(); verify(scheduledFuture).cancel(false); }
@Test(expectedExceptions = IllegalStateException.class) public void testCancelWithoutStart() { EnabledManager manager = new EnabledManager(); IncrementalSimonsPurger incrementalSimonsPurger = new IncrementalSimonsPurger(manager, executorService); incrementalSimonsPurger.cancel(); }