public class OverloadDispatcherTest {
@Test
public void testDispatchWithEventHierarchies() throws Exception {
OverloadDispatcherGenerator gen = new OverloadDispatcherGenerator(A.class);
OverloadDispatcher dispatcher = (OverloadDispatcher) gen.generate().newInstance();
A a = new A();
// input events
dispatcher.dispatchEvent(a, new Event1());
Assert.assertEquals(Event1.class, a.processedEventClass);
dispatcher.dispatchEvent(a, new Event1a());
Assert.assertEquals(Event1a.class, a.processedEventClass);
dispatcher.dispatchEvent(a, new Event2());
Assert.assertEquals(Event2.class, a.processedEventClass);
// trigger events
dispatcher.dispatchTrigger(a, new Event2());
Assert.assertEquals(Event2.class, a.processedTriggerEventClass);
Assert.assertTrue(a.processedTriggerThroughGenericMethod);
dispatcher.dispatchTrigger(a, new Event1());
Assert.assertEquals(Event1.class, a.processedTriggerEventClass);
Assert.assertFalse(a.processedTriggerThroughGenericMethod);
}