EventService { public void subscribe(EventSubscriber<?> subscriber) { final Class<?> eventType = getEventType(subscriber); doSubscribe(subscriber, eventType); } @SuppressWarnings("unchecked")  EventService(); @SuppressWarnings("unchecked") T publish(T event); void subscribe(EventSubscriber<?> subscriber); void subscribe(EventSubscriber<? extends T> subscriber, Class<T> eventType); void unsubscribe(EventSubscriber<?> subscriber); void unsubscribe(EventSubscriber<T> subscriber, Class<T> eventType);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void shouldNotDetermineTheTypeOfEventOnSubscribe() { bus.subscribe(new CustomEventSubscriber<>()); }
@Test public void shouldSubscribeOnCustomEventSubscriber() { bus.subscribe(new CustomEventSubscriber<>(), CustomEventImpl.class); }