public void installExtensions(ExtensionContainer container) {
    ListMultimap<PluginInfo, Object> installedExtensionsByPlugin = ArrayListMultimap.create();
    for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
      try {
        String pluginKey = pluginInfo.getKey();
        Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
        container.addExtension(pluginInfo, plugin);

        Plugin.Context context = new PluginContextImpl.Builder()
          .setSonarRuntime(sonarRuntime)
          .setBootConfiguration(configuration)
          .build();
        plugin.define(context);
        for (Object extension : context.getExtensions()) {
          if (installExtension(container, pluginInfo, extension) != null) {
            installedExtensionsByPlugin.put(pluginInfo, extension);
          } else {
            container.declareExtension(pluginInfo, extension);
          }
        }
      } catch (Throwable e) {
        // catch Throwable because we want to catch Error too (IncompatibleClassChangeError, ...)
        throw new IllegalStateException(format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e);
      }
    }
  }
@Test
  public void add_plugin_to_container() {
    PluginInfo fooPluginInfo = newPlugin("foo", "Foo");
    Plugin fooPlugin = mock(Plugin.class);
    pluginRepository.add(fooPluginInfo, fooPlugin);
    ListContainer componentContainer = new ListContainer();

    underTest.installExtensions(componentContainer);

    assertThat(componentContainer.getAddedObjects()).contains(fooPlugin);
  }