EventDeliveryExceptionHandlerManagerImpl implements EventDeliveryExceptionHandlerManager { @Override public EventDeliveryExceptionHandlerWithState getEventHandler(Throwable t) { EventDeliveryExceptionHandler eh = exceptionHandlers.stream() .filter(eh1 -> eh1.handles(t)) .findFirst() .orElseGet(FailEventDeliveryExceptionHandler::new); return new EventDeliveryExceptionHandlerWithState(eh, eh.makeState(t)); } EventDeliveryExceptionHandlerManagerImpl(List<EventDeliveryExceptionHandler> exceptionHandlers); @Override EventDeliveryExceptionHandlerWithState getEventHandler(Throwable t);  }
@Test public void shouldRetryAfterTimeout() { EventDeliveryExceptionHandlerWithState rh = manager.getEventHandler(throwable); rh.handle(throwable, redo, fail, ignore); verify(scheduler).setTimer(eq(retryIntervalMillis), any()); verify(redo).run(); verifyNoMoreInteractions(fail); }
@Test public void shouldFailForUnsupportedException() { Throwable t = new RuntimeException(); EventDeliveryExceptionHandlerWithState rh = manager.getEventHandler(t); rh.handle(t, redo, fail, ignore); verify(fail).accept(t); verifyNoMoreInteractions(scheduler, redo); }