37 lines
703 B
Java
37 lines
703 B
Java
package dev.kske.eventbus.core;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
/**
|
|
* Tests whether event handlers correctly handle inheritance.
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @since 1.2.0
|
|
*/
|
|
class InheritanceTest extends SimpleEventListenerBase implements SimpleEventListenerInterface {
|
|
|
|
EventBus bus;
|
|
boolean hit;
|
|
|
|
@Test
|
|
void test() {
|
|
bus = new EventBus();
|
|
bus.registerListener(this);
|
|
bus.dispatch(new SimpleEvent());
|
|
assertTrue(hit);
|
|
}
|
|
|
|
@Override
|
|
@Event(SimpleEvent.class)
|
|
public void onSimpleEventAbstractHandler() {
|
|
System.out.println("Subclass!");
|
|
}
|
|
|
|
@Override
|
|
public void onSimpleEventInterfaceHandler() {
|
|
hit = true;
|
|
}
|
|
}
|