@Test public void onEvent_shouldNot_callListenersWhenItsFiltered() { ActivitiVariableEventImpl internalEvent = new ActivitiVariableEventImpl( ActivitiEventType.VARIABLE_UPDATED); given(variableEventFilter.shouldEmmitEvent(internalEvent)).willReturn(false); VariableUpdatedEvent apiEvent = mock(VariableUpdatedEvent.class); given(converter.from(internalEvent)).willReturn(Optional.of( apiEvent)); variableUpdatedListenerDelegate.onEvent(internalEvent); verifyNoInteractions(firstListener); verifyNoInteractions(secondListener); }
@Override public void onEvent(ActivitiEvent event) { if (event instanceof ActivitiVariableEvent) { ActivitiVariableEvent internalEvent = (ActivitiVariableEvent) event; if (variableEventFilter.shouldEmmitEvent(internalEvent)) { converter.from(internalEvent) .ifPresent(convertedEvent -> { if (listeners != null) { for (VariableEventListener<VariableUpdatedEvent> listener : listeners) { listener.onEvent(convertedEvent); } } }); } } }
VariableUpdatedListenerDelegate implements ActivitiEventListener { @Override public void onEvent(ActivitiEvent event) { if (event instanceof ActivitiVariableEvent) { ActivitiVariableEvent internalEvent = (ActivitiVariableEvent) event; if (variableEventFilter.shouldEmmitEvent(internalEvent)) { converter.from(internalEvent) .ifPresent(convertedEvent -> { if (listeners != null) { for (VariableEventListener<VariableUpdatedEvent> listener : listeners) { listener.onEvent(convertedEvent); } } }); } } } }
VariableUpdatedListenerDelegate implements ActivitiEventListener { @Override public void onEvent(ActivitiEvent event) { if (event instanceof ActivitiVariableEvent) { ActivitiVariableEvent internalEvent = (ActivitiVariableEvent) event; if (variableEventFilter.shouldEmmitEvent(internalEvent)) { converter.from(internalEvent) .ifPresent(convertedEvent -> { if (listeners != null) { for (VariableEventListener<VariableUpdatedEvent> listener : listeners) { listener.onEvent(convertedEvent); } } }); } } } VariableUpdatedListenerDelegate(
        List<VariableEventListener<VariableUpdatedEvent>> listeners,
        ToVariableUpdatedConverter converter,
        VariableEventFilter variableEventFilter); }
VariableUpdatedListenerDelegate implements ActivitiEventListener { @Override public void onEvent(ActivitiEvent event) { if (event instanceof ActivitiVariableEvent) { ActivitiVariableEvent internalEvent = (ActivitiVariableEvent) event; if (variableEventFilter.shouldEmmitEvent(internalEvent)) { converter.from(internalEvent) .ifPresent(convertedEvent -> { if (listeners != null) { for (VariableEventListener<VariableUpdatedEvent> listener : listeners) { listener.onEvent(convertedEvent); } } }); } } } VariableUpdatedListenerDelegate(
        List<VariableEventListener<VariableUpdatedEvent>> listeners,
        ToVariableUpdatedConverter converter,
        VariableEventFilter variableEventFilter); @Override void onEvent(ActivitiEvent event); @Override boolean isFailOnException(); }
VariableUpdatedListenerDelegate implements ActivitiEventListener { @Override public void onEvent(ActivitiEvent event) { if (event instanceof ActivitiVariableEvent) { ActivitiVariableEvent internalEvent = (ActivitiVariableEvent) event; if (variableEventFilter.shouldEmmitEvent(internalEvent)) { converter.from(internalEvent) .ifPresent(convertedEvent -> { if (listeners != null) { for (VariableEventListener<VariableUpdatedEvent> listener : listeners) { listener.onEvent(convertedEvent); } } }); } } } VariableUpdatedListenerDelegate(
        List<VariableEventListener<VariableUpdatedEvent>> listeners,
        ToVariableUpdatedConverter converter,
        VariableEventFilter variableEventFilter); @Override void onEvent(ActivitiEvent event); @Override boolean isFailOnException();  }