public Collection<PluginUpdateAggregate> aggregate(@Nullable Collection<PluginUpdate> pluginUpdates) {
    if (pluginUpdates == null || pluginUpdates.isEmpty()) {
      return Collections.emptyList();
    }

    Map<Plugin, PluginUpdateAggregateBuilder> builders = new HashMap<>();
    for (PluginUpdate pluginUpdate : pluginUpdates) {
      Plugin plugin = pluginUpdate.getPlugin();
      PluginUpdateAggregateBuilder builder = builders.get(plugin);
      if (builder == null) {
        builder = PluginUpdateAggregateBuilder.builderFor(plugin);
        builders.put(plugin, builder);
      }
      builder.add(pluginUpdate);
    }

    return Lists.newArrayList(transform(builders.values(), PluginUpdateAggregateBuilder::build));
  }
@Test
  public void aggregates_groups_pluginUpdate_per_plugin_key() {
    Collection<PluginUpdateAggregator.PluginUpdateAggregate> aggregates = underTest.aggregate(ImmutableList.of(
      createPluginUpdate("key1"),
      createPluginUpdate("key1"),
      createPluginUpdate("key0"),
      createPluginUpdate("key2"),
      createPluginUpdate("key0")));

    assertThat(aggregates).hasSize(3);
    assertThat(aggregates).extracting("plugin.key").containsOnlyOnce("key1", "key0", "key2");
  }