### Question:
EventManager implements EventSource { @Override public <T extends Event> void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler) { Set<EventHandler> handlers = handlerMap.computeIfAbsent(type, t -> new LinkedHashSet<>()); if (!handlers.contains(eventHandler)) { handlers.add(eventHandler); } } EventManager(Object source); @Override void registerEventHandler(EventType<T> type, EventHandler<? super T> eventHandler); @Override void unregisterEventHandler(EventType<T> type, EventHandler<? super T> eventHandler); void fireEvent(Event fireEvent);  }### Answer:
@Test public void registerEventHandler( ) { EventManager eventManager = new EventManager( this ); TestHandler handler1 = new TestHandler( ); TestHandler handler2 = new TestHandler( ); TestHandler handler3 = new TestHandler( ); TestHandler handler4 = new TestHandler( ); eventManager.registerEventHandler( Event.ANY, handler1 ); eventManager.registerEventHandler( testType, handler2 ); eventManager.registerEventHandler( testTestType, handler3 ); eventManager.registerEventHandler( otherType, handler4 ); Event event1 = new Event( testType, this ); eventManager.fireEvent( event1 ); assertEquals( 1, handler1.eventList.size( ) ); assertEquals( 1, handler2.eventList.size( ) ); assertEquals( 0, handler3.eventList.size( ) ); assertEquals( 0, handler4.eventList.size( ) ); Event event2 = new Event( testTestType, event1 ); eventManager.fireEvent( event2 ); assertEquals( 2, handler1.eventList.size( ) ); assertEquals( 2, handler2.eventList.size( ) ); assertEquals( 1, handler3.eventList.size( ) ); assertEquals( 0, handler4.eventList.size( ) ); Event event3 = new Event( otherType, event1 ); eventManager.fireEvent( event3 ); assertEquals( 3, handler1.eventList.size( ) ); assertEquals( 2, handler2.eventList.size( ) ); assertEquals( 1, handler3.eventList.size( ) ); assertEquals( 1, handler4.eventList.size( ) ); }