use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldUnregisterMethodWithAnnotationForEventWithSameName.
@Test
public void shouldUnregisterMethodWithAnnotationForEventWithSameName() {
EventManagerImpl eventManager = new EventManagerImpl();
MyScript3 o = new MyScript3();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListeners(o);
eventListenerReflectionRegistrator.unregisterEventListeners(o);
Event event = new Event();
event.setId("customEvent");
eventManager.process(event);
assertThat(o.wasCalled, IsEqual.equalTo(false));
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldRegisterMethodWithAnnotation.
@Test
public void shouldRegisterMethodWithAnnotation() {
EventManagerImpl eventManager = new EventManagerImpl();
MyScript2 myScript2 = new MyScript2();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListeners(myScript2);
Event event = new Event();
event.setId("customEvent");
eventManager.process(event);
assertThat(myScript2.wasCalled, IsEqual.equalTo(false));
assertThat(myScript2.wasCalled2, IsEqual.equalTo(false));
event = new Event();
event.setId("anotherEvent");
eventManager.process(event);
assertThat(myScript2.wasCalled, IsEqual.equalTo(true));
assertThat(myScript2.wasCalled2, IsEqual.equalTo(false));
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldRegisterEventListenerForMethodWithEventName.
@Test
public void shouldRegisterEventListenerForMethodWithEventName() {
EventManagerImpl eventManager = new EventManagerImpl();
MyScript myScript = new MyScript();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListener("customEvent", myScript);
Event event = new Event();
event.setId("customEvent");
eventManager.process(event);
assertThat(myScript.wasCalled, IsEqual.equalTo(true));
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldRegisterMethodWithAnnotationForEventWithSameName.
@Test
public void shouldRegisterMethodWithAnnotationForEventWithSameName() {
EventManagerImpl eventManager = new EventManagerImpl();
MyScript3 o = new MyScript3();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListeners(o);
Event event = new Event();
event.setId("customEvent");
eventManager.process(event);
assertThat(o.wasCalled, IsEqual.equalTo(true));
}
use of com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator in project commons-gdx by gemserk.
the class EventListenerReflectionRegistratorTest method shouldUnregisterMethodWithAnnotation.
@Test
public void shouldUnregisterMethodWithAnnotation() {
EventManagerImpl eventManager = new EventManagerImpl();
MyScript2 myScript2 = new MyScript2();
EventListenerReflectionRegistrator eventListenerReflectionRegistrator = new EventListenerReflectionRegistrator(eventManager);
eventListenerReflectionRegistrator.registerEventListeners(myScript2);
eventListenerReflectionRegistrator.unregisterEventListeners(myScript2);
Event event = new Event();
event.setId("anotherEvent");
eventManager.process(event);
assertThat(myScript2.wasCalled, IsEqual.equalTo(false));
assertThat(myScript2.wasCalled2, IsEqual.equalTo(false));
}
Aggregations