ServiceComponentObserver { void register(@Observes final ServiceComponentFoundEvent event) { LOGGER.info("Registering {} handlers in class {} for component {}", event.getLocation(), event.getHandlerBean().getBeanClass().getSimpleName(), event.getComponentName()); dispatcherCache.dispatcherFor(event) .register(beanInstantiater.instantiate(event.getHandlerBean())); }    }
@Test public void shouldRegisterHandler() throws Exception { final ServiceComponentFoundEvent foundEvent = new ServiceComponentFoundEvent("COMMAND_API", bean, LOCAL); doReturn(Object.class).when(bean).getBeanClass(); when(dispatcherCache.dispatcherFor(foundEvent)).thenReturn(dispatcher); when(beanInstantiater.instantiate(bean)).thenReturn(handler); serviceComponentObserver.register(foundEvent); verify(dispatcher).register(handler); }