@Test @SuppressWarnings("unchecked") public void add() { // IListener<IEvent<?, ?>>, String, String listenerManager.add(listener, IEvent.class.getSimpleName(), "real-time-search"); verify(listeners, times(1)).put(any(String.class), any(Map.class)); }
@Test public void fire() { when(event.getContext()).thenReturn(context); when(event.getContext().getName()).thenReturn("context-name"); when(listenersForType.get(any(String.class))).thenReturn(Arrays.asList(listener)); when(listeners.get(any(String.class))).thenReturn(listenersForType); listenerManager.fire(event, true); THREAD.sleep(100); verify(listener, times(1)).notify(any(IEvent.class)); verify(listenerManager, times(1)).notify(any(IEvent.class)); listenerManager.fire(event, false); THREAD.sleep(100); verify(clusterManager, times(1)).send(any(), any()); }
@Test public void get() { List<IConsumer<IEvent<?, ?>>> listeners = listenerManager.get("type", "name"); assertNotNull(listeners); }
@Test @SuppressWarnings("unchecked") public void addTopicListener() { listenerManager.addTopicListener(); verify(clusterManager, times(1)).addTopicListener(any(String.class), any(IConsumer.class)); }
@Test public void remove() { // IListener<IEvent<?, ?>>, String, String listenerManager.remove(listener, "event-type", "context-name"); verify(listeners, times(1)).get(any(Object.class)); }