TimerRetriesDecrementedListenerDelegate implements ActivitiEventListener { @Override public void onEvent(ActivitiEvent event) { converter.from(event) .ifPresent(convertedEvent -> { for (BPMNElementEventListener<BPMNTimerRetriesDecrementedEvent> listener : processRuntimeEventListeners) { listener.onEvent(convertedEvent); } }); } TimerRetriesDecrementedListenerDelegate(List<BPMNElementEventListener<BPMNTimerRetriesDecrementedEvent>> processRuntimeEventListeners,
                                                   ToTimerRetriesDecrementedConverter converter); @Override void onEvent(ActivitiEvent event); @Override boolean isFailOnException();  }
@Test public void shouldCallRegisteredListenersWhenConvertedEventIsNotEmpty() { ActivitiEntityEvent internalEvent = mock(ActivitiEntityEvent.class); BPMNTimerRetriesDecrementedEventImpl convertedEvent = new BPMNTimerRetriesDecrementedEventImpl(); given(converter.from(internalEvent)).willReturn(Optional.of(convertedEvent)); listenerDelegate.onEvent(internalEvent); verify(listener).onEvent(convertedEvent); }
@Test public void shouldDoNothingWhenConvertedEventIsEmpty() { ActivitiEntityEvent internalEvent = mock(ActivitiEntityEvent.class); given(converter.from(internalEvent)).willReturn(Optional.empty()); listenerDelegate.onEvent(internalEvent); verify(listener, never()).onEvent(any()); }