use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testEmptyEventListRegistration.
@Test
public void testEmptyEventListRegistration() throws NoSuchFieldException {
List<String> subjects = new ArrayList<String>();
EventListener sel = new SampleEventListener();
EventListenerTree mockTree = mock(EventListenerTree.class);
PrivateAccessor.setField(registry, "listenerTree", mockTree);
registry.registerListener(sel, subjects);
verify(mockTree, times(0)).addListener(Matchers.<EventListener>anyObject(), anyString());
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testRegisterSingleListener.
@Test
public void testRegisterSingleListener() {
EventListener sel = new SampleEventListener();
registry.registerListener(sel, "org.motechproject.server.someevent");
Set<EventListener> listeners = registry.getListeners("org.motechproject.server.someevent");
assertNotNull(listeners);
assertTrue(listeners.size() == 1);
assertEquals(listeners.iterator().next(), sel);
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testRegisterTwice.
@Test
public void testRegisterTwice() {
EventListener sel = new SampleEventListener();
registry.registerListener(sel, "org.motechproject.server.someevent");
registry.registerListener(sel, "org.motechproject.server.someevent");
Set<EventListener> el = registry.getListeners("org.motechproject.server.someevent");
assertNotNull(el);
assertTrue(el.size() == 1);
assertTrue(el.contains(sel));
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerTreeTest method testAddListener_UniversalListener.
@Test
public void testAddListener_UniversalListener() {
EventListener listener1 = new SampleEventListener();
EventListener listener2 = new SampleEventListener();
tree.addListener(listener1, "*");
tree.addListener(listener2, "org.test");
Set<EventListener> listeners = tree.getListeners("*");
assertTrue(listeners.size() == 1);
assertTrue(listeners.contains(listener1));
listeners = tree.getListeners("org.test");
assertTrue(listeners.size() == 2);
assertTrue(listeners.contains(listener1));
assertTrue(listeners.contains(listener2));
listeners = tree.getListeners("com.pqr.xyz");
assertTrue(listeners.size() == 1);
assertTrue(listeners.contains(listener1));
}
use of org.motechproject.event.listener.SampleEventListener in project motech by motech.
the class EventListenerRegistryTest method testGetListeners.
@Test
public void testGetListeners() {
List<String> et = new ArrayList<String>();
et.add("org.motechproject.server.someevent");
EventListener sel = new SampleEventListener();
registry.registerListener(sel, et);
Set<EventListener> el = registry.getListeners("org.motechproject.server.someevent");
assertNotNull(el);
assertEquals(1, el.size());
assertEquals(el.iterator().next(), sel);
}
Aggregations