@Test void cancelWorks() throws Exception { VelocityScheduler scheduler = new VelocityScheduler(new FakePluginManager()); AtomicInteger i = new AtomicInteger(3); ScheduledTask task = scheduler.buildTask(FakePluginManager.PLUGIN_A, i::decrementAndGet) .delay(100, TimeUnit.SECONDS) .schedule(); task.cancel(); Thread.sleep(200); assertEquals(3, i.get()); assertEquals(TaskStatus.CANCELLED, task.status()); }
@Override public TaskBuilder buildTask(Object plugin, Runnable runnable) { checkNotNull(plugin, "plugin"); checkNotNull(runnable, "runnable"); checkArgument(pluginManager.fromInstance(plugin).isPresent(), "plugin is not registered"); return new TaskBuilderImpl(plugin, runnable); }
VelocityScheduler implements Scheduler { @Override public TaskBuilder buildTask(Object plugin, Runnable runnable) { checkNotNull(plugin, "plugin"); checkNotNull(runnable, "runnable"); checkArgument(pluginManager.fromInstance(plugin).isPresent(), "plugin is not registered"); return new TaskBuilderImpl(plugin, runnable); } }
VelocityScheduler implements Scheduler { @Override public TaskBuilder buildTask(Object plugin, Runnable runnable) { checkNotNull(plugin, "plugin"); checkNotNull(runnable, "runnable"); checkArgument(pluginManager.fromInstance(plugin).isPresent(), "plugin is not registered"); return new TaskBuilderImpl(plugin, runnable); } VelocityScheduler(PluginManager pluginManager); }
VelocityScheduler implements Scheduler { @Override public TaskBuilder buildTask(Object plugin, Runnable runnable) { checkNotNull(plugin, "plugin"); checkNotNull(runnable, "runnable"); checkArgument(pluginManager.fromInstance(plugin).isPresent(), "plugin is not registered"); return new TaskBuilderImpl(plugin, runnable); } VelocityScheduler(PluginManager pluginManager); @Override TaskBuilder buildTask(Object plugin, Runnable runnable); boolean shutdown(); }
VelocityScheduler implements Scheduler { @Override public TaskBuilder buildTask(Object plugin, Runnable runnable) { checkNotNull(plugin, "plugin"); checkNotNull(runnable, "runnable"); checkArgument(pluginManager.fromInstance(plugin).isPresent(), "plugin is not registered"); return new TaskBuilderImpl(plugin, runnable); } VelocityScheduler(PluginManager pluginManager); @Override TaskBuilder buildTask(Object plugin, Runnable runnable); boolean shutdown();  }