use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldRegisterEventListenerForMethodWithEventNameOnAnonymousClass.
@Test
public void shouldRegisterEventListenerForMethodWithEventNameOnAnonymousClass() {
EventManagerImpl eventManager = new EventManagerImpl();
anonymousWasCalled = false;
Object myScript = new ScriptJavaImpl() {
@SuppressWarnings("unused")
public void customEvent(Event e) {
anonymousWasCalled = true;
}
};
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListener("customEvent", myScript);
Event event = new Event();
event.setId("customEvent");
eventManager.process(event);
assertThat(anonymousWasCalled, IsEqual.equalTo(true));
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldNotRegisterEventListenerIfNoMethodForEvent.
@Test
public void shouldNotRegisterEventListenerIfNoMethodForEvent() {
EventManagerImpl eventManager = new EventManagerImpl();
MyScript myScript = new MyScript();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListener("customEvent2", myScript);
Event event = new Event();
event.setId("customEvent");
eventManager.process(event);
assertThat(myScript.wasCalled, IsEqual.equalTo(false));
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method bugArrayOutOfBoundsWhenRegisterOneIdsButMultipleMethodsWithHandes.
@Test
public void bugArrayOutOfBoundsWhenRegisterOneIdsButMultipleMethodsWithHandes() {
EventManager eventManager = new EventManagerImpl();
MyScript4 o = new MyScript4();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListeners(o);
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method bugArrayOutOfBoundsWhenUnregisterOneIdsButMultipleMethodsWithHandes.
@Test
public void bugArrayOutOfBoundsWhenUnregisterOneIdsButMultipleMethodsWithHandes() {
EventManager eventManager = new EventManagerImpl();
MyScript4 o = new MyScript4();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListeners(o);
eventListenerReflectionRegistrator.unregisterEventListeners(o);
}
Aggregations