DefaultDataStoreEventListenerContext implements DataStoreEventListenerContext { @Override public void trigger(DataStoreEvent event) { if (event == null) { log.error("The data store event that was triggered was a null value"); throw new InvalidArgumentException("Cannot raise a null event"); } log.info("Triggering data store event of type " + event.getClass()); for (Class<? extends DataStoreEvent> eventType : listeners.keySet()) { if (eventType.isInstance(event)) { for (DataStoreEventListener listener : listeners.get(eventType)) { log.debug("Triggering event on listener " + ((SmartDataStoreEventListener) listener).getDelegate()); listener.onEvent(event); } } } if (parent != null) { log.info("Going to trigger the same event on the parent context"); parent.trigger(event); } } DefaultDataStoreEventListenerContext();  DefaultDataStoreEventListenerContext(DataStoreEventListenerContext parent); @Override void register(DataStoreEventListener<E> listener); @Override void trigger(DataStoreEvent event); @Override List<DataStoreEventListener<? extends E>> getListeners(Class<E> eventType);  }
@Test(expectedExceptions = InvalidArgumentException.class) public void testTriggeringNullEvent() { DefaultDataStoreEventListenerContext context = new DefaultDataStoreEventListenerContext(); context.trigger(null); }