@Override
  public void start() {
    Collection<ServerPluginInfo> loadedPlugins = pluginJarLoader.loadPlugins();
    logInstalledPlugins(loadedPlugins);
    Collection<ExplodedPlugin> explodedPlugins = extractPlugins(loadedPlugins);
    Map<String, Plugin> instancesByKey = pluginClassLoader.load(explodedPlugins);
    Map<String, PluginType> typesByKey = getTypesByKey(loadedPlugins);
    List<ServerPlugin> plugins = createServerPlugins(explodedPlugins, instancesByKey, typesByKey);
    pluginRepository.addPlugins(plugins);
  }
@Test
  public void load_plugins() throws IOException {
    ServerPluginInfo p1 = newPluginInfo("p1");
    ServerPluginInfo p2 = newPluginInfo("p2");
    when(jarLoader.loadPlugins()).thenReturn(Arrays.asList(p1, p2));
    when(jarExploder.explode(p1)).thenReturn(new ExplodedPlugin(p1, "p1", new File("p1Exploded.jar"), Collections.singletonList(new File("libP1.jar"))));
    when(jarExploder.explode(p2)).thenReturn(new ExplodedPlugin(p2, "p2", new File("p2Exploded.jar"), Collections.singletonList(new File("libP2.jar"))));

    Map<String, Plugin> instances = ImmutableMap.of("p1", mock(Plugin.class), "p2", mock(Plugin.class));
    when(pluginClassLoader.load(anyList())).thenReturn(instances);

    underTest.start();

    assertEquals(2, pluginRepository.getPlugins().size());

    assertEquals(p1, pluginRepository.getPlugin("p1").getPluginInfo());
    assertEquals(newFileAndMd5(p1.getNonNullJarFile()).getFile(), pluginRepository.getPlugin("p1").getJar().getFile());
    assertEquals(newFileAndMd5(p1.getNonNullJarFile()).getMd5(), pluginRepository.getPlugin("p1").getJar().getMd5());
    assertEquals(instances.get("p1"), pluginRepository.getPlugin("p1").getInstance());

    assertEquals(p2, pluginRepository.getPlugin("p2").getPluginInfo());
    assertEquals(newFileAndMd5(p2.getNonNullJarFile()).getFile(), pluginRepository.getPlugin("p2").getJar().getFile());
    assertEquals(newFileAndMd5(p2.getNonNullJarFile()).getMd5(), pluginRepository.getPlugin("p2").getJar().getMd5());
    assertEquals(instances.get("p2"), pluginRepository.getPlugin("p2").getInstance());

    assertThat(pluginRepository.getPlugins()).extracting(ServerPlugin::getPluginInfo)
      .allMatch(p -> logTester.logs().contains(String.format("Deploy %s / %s / %s", p.getName(), p.getVersion(), p.getImplementationBuild())));
  }