PrintStreamMessageLogger implements MessageListener { @Override public Executor getListenedExecutor(Executor realExecutor) { return new LoggedExecutor(realExecutor); } PrintStreamMessageLogger(PrintStream out); @Override void onMessageSent(Object message); @Override void onProcessingStarted(Object actor, Object message); @Override void onProcessingFinished(); @Override Executor getListenedExecutor(Executor realExecutor);  }
@Test public void the_logged_executor_executes_the_command() { FakeExecutor realExecutor = new FakeExecutor(); Executor listenedExecutor = logger.getListenedExecutor(realExecutor); Runnable command = mock(Runnable.class, "DummyCommand"); listenedExecutor.execute(command); realExecutor.processCommands(); verify(command).run(); }