@Test @SuppressWarnings({"unchecked", "rawtypes"}) public void testPublishToParentScope() { StringListener stringListener = mock(StringListener.class); applicationEventBus.subscribe(stringListener); sessionEventBus.publish(EventScope.APPLICATION, this, "Hello World"); ArgumentCaptor<Event> event = ArgumentCaptor.forClass(Event.class); verify(stringListener).onEvent(event.capture()); assertEquals("Hello World", event.getValue().getPayload()); }
@Test public void testPropagateToChildWithListenerMethods() { MultipleListeners listener = new MultipleListeners(); applicationEventBus.subscribe(listener); applicationEventBus.publish(this, "Hello World"); assertNull(listener.theIntegerEvent); assertNull(listener.theIntegerPayload); assertNotNull(listener.theStringEvent); assertEquals("Hello World", listener.theStringEvent.getPayload()); assertEquals("Hello World", listener.theStringPayload); }
@Test public void testPublishToParentScopeWithListenerMethods() { MultipleListeners listener = new MultipleListeners(); applicationEventBus.subscribe(listener); sessionEventBus.publish(EventScope.APPLICATION, this, "Hello World"); assertNull(listener.theIntegerEvent); assertNull(listener.theIntegerPayload); assertNotNull(listener.theStringEvent); assertEquals("Hello World", listener.theStringEvent.getPayload()); assertEquals("Hello World", listener.theStringPayload); }