SimpleSkippable implements Runnable { @Override public void run() { LOGGER.trace("Running {}.", this); try { toRun.run(); LOGGER.trace("Successfully finished {}.", this); } catch (final Throwable t) { if (isRecoverable(t)) { LOGGER.debug("Failed executing {}.", this, t); } else { shutdownCall.accept(t); throw t; } } } SimpleSkippable(final Runnable toRun, final Class<?> type, final Consumer<Throwable> shutdownCall);   SimpleSkippable(final Runnable toRun, final Consumer<Throwable> shutdownCall);   SimpleSkippable(final Runnable toRun); @Override void run(); @Override String toString();  }
@Test void fails() { final Runnable r = mock(Runnable.class); doThrow(IllegalStateException.class).when(r) .run(); final Runnable s = new SimpleSkippable(r); s.run(); assertThat(this.getEventsRequested()).isEmpty(); }
@Test void dies() { final Runnable r = mock(Runnable.class); doThrow(OutOfMemoryError.class).when(r) .run(); final Consumer<Throwable> c = mock(Consumer.class); final Runnable s = new SimpleSkippable(r, c); assertThatThrownBy(s::run).isInstanceOf(OutOfMemoryError.class); verify(c, only()).accept(any()); }