Ejemplo n.º 1
0
  @Test
  public void testUnregister() {
    TargetEventTriggered trigger = new TargetEventTriggered();
    eventManager.register(ObservesEvent.class, trigger);
    eventManager.unregister(trigger);

    eventManager.trigger(new ObservesEvent());

    assertFalse(trigger.isTriggered());
  }
Ejemplo n.º 2
0
 private void registerEvents() {
   eventManager.register(
       ObservesEvent.class,
       new EventObserver<ObservesEvent>() {
         @Override
         public void trigger(ObservesEvent event) {
           target.observes(event);
         }
       });
   eventManager.register(
       Object.class,
       new EventObserver<Object>() {
         @Override
         public void trigger(Object event) {
           target.observes(event);
         }
       });
 }
Ejemplo n.º 3
0
  @Test
  public void testEventHierarchyTrigger() {
    registerEvents();

    Object event = new Object();
    eventManager.trigger(event);

    assertNull(target.getEvent());
    assertEquals(event, target.getObjectEvent());
  }
Ejemplo n.º 4
0
  @Test
  public void testRegistration() {
    registerEvents();

    ObservesEvent event = new ObservesEvent();
    eventManager.trigger(event);

    assertEquals(event, target.getEvent());
    assertEquals(event, target.getObjectEvent());
  }