Search in sources :

Example 1 with EventListenerReflectionRegistrator

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));
}
Also used : EventListenerReflectionRegistrator(com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator) Test(org.junit.Test)

Example 2 with EventListenerReflectionRegistrator

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));
}
Also used : EventListenerReflectionRegistrator(com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator) Test(org.junit.Test)

Example 3 with EventListenerReflectionRegistrator

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));
}
Also used : EventListenerReflectionRegistrator(com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator) Test(org.junit.Test)

Example 4 with EventListenerReflectionRegistrator

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));
}
Also used : EventListenerReflectionRegistrator(com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator) Test(org.junit.Test)

Example 5 with EventListenerReflectionRegistrator

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));
}
Also used : EventListenerReflectionRegistrator(com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator) Test(org.junit.Test)

Aggregations

EventListenerReflectionRegistrator (com.gemserk.commons.artemis.events.reflection.EventListenerReflectionRegistrator)9 Test (org.junit.Test)9 ScriptJavaImpl (com.gemserk.commons.artemis.scripts.ScriptJavaImpl)1