### Question:
EventBus { public void subscribe(Class<? extends Subscriber> subscriber) { try { monitor.lock(); if (subscriber.isAnnotationPresent(InterestedEvent.class)) { InterestedEvent ann = subscriber.getAnnotation(InterestedEvent.class); for (Class<? extends Event> interestedEvent : ann.events()) { if (!subscribers.containsKey(interestedEvent)) { subscribers.put(interestedEvent, new LinkedList<Class<? extends Subscriber>>()); } subscribers.get(interestedEvent).add(subscriber); } } } finally { monitor.unlock(); } }  void setEventPublisher(EventPublisher eventPublisher); void subscribe(Class<? extends Subscriber> subscriber); @SuppressWarnings("unchecked") void publish(Event event);  }### Answer:
@Test public void subscribeTest() { replay(this.consumerOne, this.consumerTwo, this.publisher); assertFalse(bus.subscribers.containsKey(EventOne.class)); assertFalse(bus.subscribers.containsKey(EventTwo.class)); bus.subscribe(SubscriberOne.class); bus.subscribe(SubscriberTwo.class); assertTrue(bus.subscribers.containsKey(EventOne.class)); assertEquals(1, bus.subscribers.get(EventOne.class).size()); assertTrue(bus.subscribers.containsKey(EventTwo.class)); assertEquals(2, bus.subscribers.get(EventTwo.class).size()); verify(this.consumerOne, this.consumerTwo, this.publisher); }