SmartDataStoreEventListener implements DataStoreEventListener<E> { @Override public void onEvent(E event) { delegate.onEvent(event); } SmartDataStoreEventListener(DataStoreEventListener<E> delegate); @Override void onEvent(E event); Class<E> getEventType(); DataStoreEventListener<E> getDelegate();  }
@Test public void testEventDelegation() { final SpyingEventListener<DataStoreEvent> spy = new AllCatchingEventListener(); final SmartDataStoreEventListener<DataStoreEvent> listener = new SmartDataStoreEventListener<>(spy); final AfterDeleteDataStoreEvent first = new AfterDeleteDataStoreEvent(null, null, null); final BeforeInsertDataStoreEvent second = new BeforeInsertDataStoreEvent(null, null, null); listener.onEvent(first); listener.onEvent(second); final List<DataStoreEvent> events = spy.getEvents(); assertThat(events, hasSize(2)); assertThat(events.get(0), Matchers.is(first)); assertThat(events.get(1), Matchers.is(second)); }