WorkflowLifecycle implements SmartLifecycle { @Override public void stop() { dispatcher.shutdown(); } @Inject  WorkflowLifecycle(WorkflowDispatcher dispatcher, @NFlow ThreadFactory nflowThreadFactory, Environment env); @Override int getPhase(); @Override boolean isAutoStartup(); @Override void start(); void pause(); void resume(); boolean isPaused(); @Override boolean isRunning(); @Override void stop(); @Override void stop(Runnable callback);  }
@Test public void stopStopsDispatcherThread() { lifecycle.stop(); verify(dispatcher).shutdown(); }
@Test public void stopWithCallbackStopsDispatcherThreadAndRunsCallback() { Runnable callback = mock(Runnable.class); lifecycle.stop(callback); verify(dispatcher).shutdown(); verify(callback).run(); }