Search in sources :

Example 1 with Edition

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;
}
Also used : PluginDownloader(org.sonar.server.plugins.PluginDownloader) PlatformEditionProvider(org.sonar.core.platform.PlatformEditionProvider) PLUGINS_RISK_CONSENT(org.sonar.core.config.CorePropertyDefinitions.PLUGINS_RISK_CONSENT) EditionBundledPlugins.isEditionBundled(org.sonar.server.plugins.edition.EditionBundledPlugins.isEditionBundled) PluginRiskConsent(org.sonar.core.extension.PluginRiskConsent) UpdateCenterMatrixFactory(org.sonar.server.plugins.UpdateCenterMatrixFactory) String.format(java.lang.String.format) Objects(java.util.Objects) Request(org.sonar.api.server.ws.Request) WebService(org.sonar.api.server.ws.WebService) Edition(org.sonar.core.platform.EditionProvider.Edition) UpdateCenter(org.sonar.updatecenter.common.UpdateCenter) Configuration(org.sonar.api.config.Configuration) Response(org.sonar.api.server.ws.Response) Optional(java.util.Optional) UserSession(org.sonar.server.user.UserSession) PluginUpdate(org.sonar.updatecenter.common.PluginUpdate) UpdateCenter(org.sonar.updatecenter.common.UpdateCenter) Objects(java.util.Objects) PluginUpdate(org.sonar.updatecenter.common.PluginUpdate)

Example 2 with Edition

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));
}
Also used : FACETS(org.sonar.api.server.ws.WebService.Param.FACETS) Arrays(java.util.Arrays) PermissionIndexerTester(org.sonar.server.permission.index.PermissionIndexerTester) SORT(org.sonar.api.server.ws.WebService.Param.SORT) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DataProviderRunner(com.tngtech.java.junit.dataprovider.DataProviderRunner) DbSession(org.sonar.db.DbSession) RequestBuilder(org.sonar.server.component.ws.SearchProjectsAction.RequestBuilder) Collections.singletonList(java.util.Collections.singletonList) NEW_SECURITY_RATING_KEY(org.sonar.api.measures.CoreMetrics.NEW_SECURITY_RATING_KEY) PAGE(org.sonar.api.server.ws.WebService.Param.PAGE) Param(org.sonar.api.server.ws.WebService.Param) WebService(org.sonar.api.server.ws.WebService) ProjectsInWarning(org.sonar.server.qualitygate.ProjectsInWarning) Arrays.asList(java.util.Arrays.asList) NEW_MAINTAINABILITY_RATING_KEY(org.sonar.api.measures.CoreMetrics.NEW_MAINTAINABILITY_RATING_KEY) PARAM_FILTER(org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_FILTER) DateUtils.formatDateTime(org.sonar.api.utils.DateUtils.formatDateTime) FILTER_LANGUAGES(org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_LANGUAGES) RELIABILITY_RATING_KEY(org.sonar.api.measures.CoreMetrics.RELIABILITY_RATING_KEY) MoreCollectors.toList(org.sonar.core.util.stream.MoreCollectors.toList) DbTester(org.sonar.db.DbTester) System2(org.sonar.api.utils.System2) Set(java.util.Set) NEW_DUPLICATED_LINES_DENSITY_KEY(org.sonar.api.measures.CoreMetrics.NEW_DUPLICATED_LINES_DENSITY_KEY) LEVEL(org.sonar.api.measures.Metric.ValueType.LEVEL) FILTER_QUALIFIER(org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_QUALIFIER) Common(org.sonarqube.ws.Common) DbClient(org.sonar.db.DbClient) NEW_RELIABILITY_RATING_KEY(org.sonar.api.measures.CoreMetrics.NEW_RELIABILITY_RATING_KEY) List(java.util.List) ComponentDto(org.sonar.db.component.ComponentDto) ALERT_STATUS_KEY(org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY) Stream(java.util.stream.Stream) SQALE_RATING_KEY(org.sonar.api.measures.CoreMetrics.SQALE_RATING_KEY) ProjectDto(org.sonar.db.project.ProjectDto) Optional(java.util.Optional) PAGE_SIZE(org.sonar.api.server.ws.WebService.Param.PAGE_SIZE) FIELDS(org.sonar.api.server.ws.WebService.Param.FIELDS) PropertyDto(org.sonar.db.property.PropertyDto) Component(org.sonarqube.ws.Components.Component) Joiner(com.google.common.base.Joiner) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) NCLOC_LANGUAGE_DISTRIBUTION_KEY(org.sonar.api.measures.CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION_KEY) EsTester(org.sonar.server.es.EsTester) RunWith(org.junit.runner.RunWith) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) ProjectMeasuresIndexer(org.sonar.server.measure.index.ProjectMeasuresIndexer) HashSet(java.util.HashSet) ProjectMeasuresIndex(org.sonar.server.measure.index.ProjectMeasuresIndex) WebAuthorizationTypeSupport(org.sonar.server.permission.index.WebAuthorizationTypeSupport) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SearchProjectsRequest(org.sonar.server.component.ws.SearchProjectsAction.SearchProjectsRequest) DATA(org.sonar.api.measures.Metric.ValueType.DATA) Nullable(javax.annotation.Nullable) Before(org.junit.Before) UserSessionRule(org.sonar.server.tester.UserSessionRule) SECURITY_RATING_KEY(org.sonar.api.measures.CoreMetrics.SECURITY_RATING_KEY) NEW_LINES_KEY(org.sonar.api.measures.CoreMetrics.NEW_LINES_KEY) Assertions.tuple(org.assertj.core.api.Assertions.tuple) PlatformEditionProvider(org.sonar.core.platform.PlatformEditionProvider) Optional.ofNullable(java.util.Optional.ofNullable) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider) DUPLICATED_LINES_DENSITY_KEY(org.sonar.api.measures.CoreMetrics.DUPLICATED_LINES_DENSITY_KEY) TestRequest(org.sonar.server.ws.TestRequest) JsonAssert.assertJson(org.sonar.test.JsonAssert.assertJson) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) WsActionTester(org.sonar.server.ws.WsActionTester) SearchProjectsWsResponse(org.sonarqube.ws.Components.SearchProjectsWsResponse) Consumer(java.util.function.Consumer) Rule(org.junit.Rule) MetricDto(org.sonar.db.metric.MetricDto) Qualifiers(org.sonar.api.resources.Qualifiers) Edition(org.sonar.core.platform.EditionProvider.Edition) LiveMeasureDto(org.sonar.db.measure.LiveMeasureDto) INT(org.sonar.api.measures.Metric.ValueType.INT) IssueIndexSyncProgressChecker(org.sonar.server.issue.index.IssueIndexSyncProgressChecker) ASCENDING(org.sonar.api.server.ws.WebService.Param.ASCENDING) KEY_PROJECT_EXAMPLE_002(org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_002) KEY_PROJECT_EXAMPLE_001(org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001) KEY_PROJECT_EXAMPLE_003(org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_003) FILTER_TAGS(org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_TAGS) Metric(org.sonar.api.measures.Metric) SearchProjectsWsResponse(org.sonarqube.ws.Components.SearchProjectsWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

Optional (java.util.Optional)2 WebService (org.sonar.api.server.ws.WebService)2 Edition (org.sonar.core.platform.EditionProvider.Edition)2 PlatformEditionProvider (org.sonar.core.platform.PlatformEditionProvider)2 Joiner (com.google.common.base.Joiner)1 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)1 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 String.format (java.lang.String.format)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Set (java.util.Set)1 Consumer (java.util.function.Consumer)1 IntStream (java.util.stream.IntStream)1