### Question:
PrefilteringLiveNotificationEmailListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { if (this.notificationConfiguration.isEnabled() && this.notificationConfiguration.areEmailsEnabled() && this.notificationConfiguration.isEventPrefilteringEnabled()) { if (event instanceof MailEntityAddedEvent) { if (!this.remoteState.isRemoteState()) { this.manager.addEvent((EntityEvent) source); } } else if (event instanceof ApplicationReadyEvent) { this.manager.addEvents(this.wikis.getMainWikiId()); } else if (event instanceof WikiReadyEvent) { this.manager.addEvents(this.wikis.getMainWikiId()); } } } PrefilteringLiveNotificationEmailListener(); @Override void onEvent(Event event, Object source, Object data); static final String NAME; }### Answer:
@Test void onEvent() { EntityEvent event = mock(EntityEvent.class); when(this.remoteState.isRemoteState()).thenReturn(false); when(this.notificationConfiguration.isEnabled()).thenReturn(true); when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(true); when(this.notificationConfiguration.isEventPrefilteringEnabled()).thenReturn(true); this.listener.onEvent(EVENT, event, null); verify(this.manager, times(1)).addEvent(event); when(this.remoteState.isRemoteState()).thenReturn(true); when(this.notificationConfiguration.isEnabled()).thenReturn(true); when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(true); when(this.notificationConfiguration.isEventPrefilteringEnabled()).thenReturn(true); this.listener.onEvent(EVENT, event, null); verify(this.manager, times(1)).addEvent(event); when(this.remoteState.isRemoteState()).thenReturn(false); when(this.notificationConfiguration.isEnabled()).thenReturn(false); when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(true); when(this.notificationConfiguration.isEventPrefilteringEnabled()).thenReturn(true); this.listener.onEvent(EVENT, event, null); verify(this.manager, times(1)).addEvent(event); when(this.remoteState.isRemoteState()).thenReturn(false); when(this.notificationConfiguration.isEnabled()).thenReturn(true); when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(false); when(this.notificationConfiguration.isEventPrefilteringEnabled()).thenReturn(true); this.listener.onEvent(EVENT, event, null); verify(this.manager, times(1)).addEvent(event); when(this.remoteState.isRemoteState()).thenReturn(false); when(this.notificationConfiguration.isEnabled()).thenReturn(true); when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(true); when(this.notificationConfiguration.isEventPrefilteringEnabled()).thenReturn(false); }