use of org.sonar.core.platform.EditionProvider.Edition in project sonarqube by SonarSource.
the class InstallAction method findAvailablePluginByKey.
private PluginUpdate findAvailablePluginByKey(String key) {
PluginUpdate pluginUpdate = null;
Optional<UpdateCenter> updateCenter = updateCenterFactory.getUpdateCenter(false);
if (updateCenter.isPresent()) {
pluginUpdate = updateCenter.get().findAvailablePlugins().stream().filter(Objects::nonNull).filter(u -> key.equals(u.getPlugin().getKey())).findFirst().orElse(null);
}
if (pluginUpdate == null) {
throw new IllegalArgumentException(format("No plugin with key '%s' or plugin '%s' is already installed in latest version", key, key));
}
if (isEditionBundled(pluginUpdate.getPlugin())) {
throw new IllegalArgumentException(format("SonarSource commercial plugin with key '%s' can only be installed as part of a SonarSource edition", pluginUpdate.getPlugin().getKey()));
}
return pluginUpdate;
}
use of org.sonar.core.platform.EditionProvider.Edition in project sonarqube by SonarSource.
the class SearchProjectsActionTest method default_filter_projects_and_apps_by_editions.
@Test
@UseDataProvider("component_qualifiers_for_valid_editions")
public void default_filter_projects_and_apps_by_editions(String[] qualifiers, Edition edition) {
when(editionProviderMock.get()).thenReturn(Optional.of(edition));
userSession.logIn();
ComponentDto portfolio1 = insertPortfolio();
ComponentDto portfolio2 = insertPortfolio();
ComponentDto application1 = insertApplication();
ComponentDto application2 = insertApplication();
ComponentDto application3 = insertApplication();
ComponentDto project1 = insertProject();
ComponentDto project2 = insertProject();
ComponentDto project3 = insertProject();
index();
SearchProjectsWsResponse result = call(request);
assertThat(result.getComponentsCount()).isEqualTo(Stream.of(application1, application2, application3, project1, project2, project3).filter(c -> Stream.of(qualifiers).anyMatch(s -> s.equals(c.qualifier()))).count());
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(Stream.of(application1, application2, application3, project1, project2, project3).filter(c -> Stream.of(qualifiers).anyMatch(s -> s.equals(c.qualifier()))).map(ComponentDto::getDbKey).toArray(String[]::new));
}
Aggregations