### Question:
LiveNotificationEmailListener extends AbstractEventListener { @Override public void onEvent(Event event, Object o, Object o1) { if (!this.remoteState.isRemoteState() && this.notificationConfiguration.isEnabled() && this.notificationConfiguration.areEmailsEnabled() && !this.notificationConfiguration.isEventPrefilteringEnabled()) { try { org.xwiki.eventstream.Event eventStreamEvent = (org.xwiki.eventstream.Event) o; List<RecordableEventDescriptor> descriptorList = this.recordableEventDescriptorManager.getRecordableEventDescriptors(true); for (RecordableEventDescriptor descriptor : descriptorList) { if (descriptor.getEventType().equals(eventStreamEvent.getType())) { this.liveNotificationEmailManager.addEvent(eventStreamEvent); this.startNotificationThread(); } } } catch (EventStreamException e) { logger.warn("Unable to retrieve a full list of RecordableEventDescriptor.", e); } } } LiveNotificationEmailListener(); @Override void onEvent(Event event, Object o, Object o1); static final String NAME; }### Answer:
@Test public void testOnEvent() throws Exception { Event eventStreamEvent = mock(Event.class); EventStreamAddedEvent event = mock(EventStreamAddedEvent.class); RecordableEventDescriptor eventDescriptor = mock(RecordableEventDescriptor.class); when(eventDescriptor.getEventType()).thenReturn("eventType"); when(this.recordableEventDescriptorManager.getRecordableEventDescriptors(true)) .thenReturn(Arrays.asList(eventDescriptor)); when(eventStreamEvent.getType()).thenReturn("eventType"); when(this.notificationConfiguration.areEmailsEnabled()).thenReturn(true); when(this.notificationConfiguration.isEnabled()).thenReturn(true); this.mocker.getComponentUnderTest().onEvent(event, eventStreamEvent, null); verify(this.liveNotificationEmailManager, times(1)).addEvent(eventStreamEvent); }