@Test
  public void testEventDispatcherAdapterDetached() {
    // test#1
    MockEventDispatcher eventDispatcher = new MockEventDispatcher();
    MockEventHandler eventHandler = new MockEventHandler();
    MockEventDispatcherAdapter eventDispatcherAdapter = new MockEventDispatcherAdapter();

    eventDispatcher.getHandlers().add(eventHandler);
    eventDispatcher.eAdapters().add(eventDispatcherAdapter);

    Adapter adapter = EMFUtils.getAdapterOfTypeFor(eventHandler, MockEventHandlerAdapter.class);
    assertTrue(adapter instanceof MockEventHandlerAdapter);
    assertEquals(
        eventDispatcherAdapter, ((MockEventHandlerAdapter) adapter).getAttachedDispatcherAdapter());
    adapter = EMFUtils.getAdapterOfTypeFor(eventHandler, MockEventHandlerAdapter.class);
    assertTrue(adapter instanceof MockEventHandlerAdapter);
    assertEquals(
        eventDispatcherAdapter, ((MockEventHandlerAdapter) adapter).getAttachedDispatcherAdapter());
    eventDispatcher.getHandlers().remove(eventHandler);
    assertEquals(null, ((MockEventHandlerAdapter) adapter).getAttachedDispatcherAdapter());
  }
  @Test
  public void testEventRemoved() {
    MockEventHandlerAdapter eventHandlerAdapter = new MockEventHandlerAdapter();
    MockEventHandler eventHandler = new MockEventHandler();

    PropertyChangedEvent event1 = EDPEventsFactory.eINSTANCE.createPropertyChangedEvent();
    PropertyChangedEvent event2 = EDPEventsFactory.eINSTANCE.createPropertyChangedEvent();

    eventHandler.getEvents().add(event1);
    eventHandler.getEvents().add(event2);
    eventHandler.eAdapters().add(eventHandlerAdapter);
    assertEquals(1, eventHandlerAdapter.getManagedEventCount(event1));
    assertEquals(1, eventHandlerAdapter.getManagedEventCount(event2));

    assertEquals(1, EMFUtils.coundAdaptersOfTypeFor(event1, EventAdapter.class));
    assertEquals(1, EMFUtils.coundAdaptersOfTypeFor(event2, EventAdapter.class));

    eventHandler.getEvents().remove(event2);

    assertEquals(1, eventHandlerAdapter.getManagedEventCount(event1));
    assertEquals(0, eventHandlerAdapter.getManagedEventCount(event2));
  }
  @Test
  public void testAdaptEvent() {
    MockEventHandlerAdapter eventHandlerAdapter = new MockEventHandlerAdapter();
    MockEventHandler eventHandler = new MockEventHandler();

    PropertyChangedEvent event1 = EDPEventsFactory.eINSTANCE.createPropertyChangedEvent();
    PropertyChangedEvent event2 = EDPEventsFactory.eINSTANCE.createPropertyChangedEvent();

    eventHandler.getEvents().add(event1);
    assertEquals(0, EMFUtils.coundAdaptersOfTypeFor(event1, EventAdapter.class));
    assertEquals(0, EMFUtils.coundAdaptersOfTypeFor(event2, EventAdapter.class));
    eventHandler.eAdapters().add(eventHandlerAdapter);
    assertEquals(1, EMFUtils.coundAdaptersOfTypeFor(event1, EventAdapter.class));
    assertEquals(0, EMFUtils.coundAdaptersOfTypeFor(event2, EventAdapter.class));

    assertNotNull(EMFUtils.getAdapterOfTypeFor(event1, MockEventAdapter.class));
    assertEquals(
        eventHandlerAdapter,
        ((MockEventAdapter) EMFUtils.getAdapterOfTypeFor(event1, MockEventAdapter.class))
            .getEventHandlerAdapter());
    assertNull(EMFUtils.getAdapterOfTypeFor(event2, MockEventAdapter.class));
    eventHandler.getEvents().add(event2);
    assertNotNull(EMFUtils.getAdapterOfTypeFor(event2, MockEventAdapter.class));
    assertEquals(
        eventHandlerAdapter,
        ((MockEventAdapter) EMFUtils.getAdapterOfTypeFor(event2, MockEventAdapter.class))
            .getEventHandlerAdapter());

    assertEquals(1, EMFUtils.coundAdaptersOfTypeFor(event1, EventAdapter.class));
    assertEquals(1, EMFUtils.coundAdaptersOfTypeFor(event2, EventAdapter.class));
  }