use of org.sonar.updatecenter.common.PluginUpdate in project sonarqube by SonarSource.
the class UpdatesAction method writeUpdates.
private void writeUpdates(JsonWriter jsonWriter, Collection<PluginUpdate> pluginUpdates) {
jsonWriter.name(ARRAY_UPDATES).beginArray();
for (PluginUpdate pluginUpdate : ImmutableSortedSet.copyOf(PLUGIN_UPDATE_BY_VERSION_ORDERING, pluginUpdates)) {
jsonWriter.beginObject();
pluginWSCommons.writeRelease(jsonWriter, pluginUpdate.getRelease());
pluginWSCommons.writeUpdateProperties(jsonWriter, pluginUpdate);
jsonWriter.endObject();
}
jsonWriter.endArray();
}
use of org.sonar.updatecenter.common.PluginUpdate in project sonarqube by SonarSource.
the class InstallAction method findAvailablePluginByKey.
private PluginUpdate findAvailablePluginByKey(String key) {
PluginUpdate pluginUpdate = MISSING_PLUGIN;
Optional<UpdateCenter> updateCenter = updateCenterFactory.getUpdateCenter(false);
if (updateCenter.isPresent()) {
pluginUpdate = Iterables.find(updateCenter.get().findAvailablePlugins(), hasKey(key), MISSING_PLUGIN);
}
if (pluginUpdate == MISSING_PLUGIN) {
throw new IllegalArgumentException(format("No plugin with key '%s' or plugin '%s' is already installed in latest version", key, key));
}
return pluginUpdate;
}
use of org.sonar.updatecenter.common.PluginUpdate in project sonarqube by SonarSource.
the class PluginUpdateAggregator method aggregate.
public Collection<PluginUpdateAggregate> aggregate(@Nullable Collection<PluginUpdate> pluginUpdates) {
if (pluginUpdates == null || pluginUpdates.isEmpty()) {
return Collections.emptyList();
}
Map<Plugin, PluginUpdateAggregateBuilder> builders = Maps.newHashMap();
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(), BuilderToPluginUpdateAggregate.INSTANCE));
}
use of org.sonar.updatecenter.common.PluginUpdate in project sonarqube by SonarSource.
the class PluginUpdateAggregatorTest method aggregate_put_pluginUpdates_with_same_plugin_in_the_same_PluginUpdateAggregate.
@Test
public void aggregate_put_pluginUpdates_with_same_plugin_in_the_same_PluginUpdateAggregate() {
PluginUpdate pluginUpdate1 = createPluginUpdate("key1");
PluginUpdate pluginUpdate2 = createPluginUpdate("key1");
PluginUpdate pluginUpdate3 = createPluginUpdate("key1");
Collection<PluginUpdateAggregator.PluginUpdateAggregate> aggregates = underTest.aggregate(ImmutableList.of(pluginUpdate1, pluginUpdate2, pluginUpdate3));
assertThat(aggregates).hasSize(1);
Collection<PluginUpdate> releases = aggregates.iterator().next().getUpdates();
assertThat(releases).hasSize(3);
assertThat(releases).contains(pluginUpdate1);
assertThat(releases).contains(pluginUpdate2);
assertThat(releases).contains(pluginUpdate3);
}
use of org.sonar.updatecenter.common.PluginUpdate in project sonarqube by SonarSource.
the class PluginWSCommonsTest method writeUpdate_renders_key_name_and_description_of_requirements.
@Test
public void writeUpdate_renders_key_name_and_description_of_requirements() {
PluginUpdate pluginUpdate = new PluginUpdate();
pluginUpdate.setRelease(new Release(newPlugin(), version("1.0")).addOutgoingDependency(newRelease()));
jsonWriter.beginObject();
underTest.writeUpdate(jsonWriter, pluginUpdate);
jsonWriter.endObject();
jsonWriter.close();
assertJson(response.outputAsString()).isSimilarTo("{" + " \"update\": {" + " \"requires\": [" + " {" + " \"key\": \"pkey\"," + " \"name\": \"p_name\"," + " \"description\": \"p_description\"" + " }" + " ]" + " }" + "}");
}
Aggregations