MessageBus { public static boolean listens(Class<?> messageType, MessageListener<?> toFindOut) { if (listeners == null) { return false; } if (!listeners.containsKey(messageType)) { return false; } for (@SuppressWarnings("rawtypes") MessageListener listener : listeners.get(messageType)) { if (listener == toFindOut) { return true; } } return false; } private  MessageBus(); static void sendMessage(Message<?> message); static void registerOnce(Class<?> messageType, MessageListener<?> listener); static void registerListener(Class<?> messageType, MessageListener<?> listener); static void unregisterListener(Class<?> messageType, MessageListener<?> listener); static void removeAllListeners(); static boolean listens(Class<?> messageType, MessageListener<?> toFindOut);  }
@Test public void listens() { MessageBus.registerListener(Message1.class, listener1); MessageBus.registerListener(Message2.class, listener1); assertThat(MessageBus.listens(Message1.class, listener1), is(true)); assertThat(MessageBus.listens(Message1.class, listener2), is(false)); }