From: Sébastien Lesaint Date: Fri, 9 Aug 2019 15:07:03 +0000 (+0200) Subject: remove some SonarCloud specific code X-Git-Tag: 8.0~237 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7cb612b6fb027fd6a5524df72c3934b67d0f680d;p=sonarqube.git remove some SonarCloud specific code --- diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DataChange.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DataChange.java index a6beab641fc..51e36e4c5f1 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DataChange.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DataChange.java @@ -21,7 +21,6 @@ package org.sonar.server.platform.db.migration.step; import java.sql.Connection; import java.sql.SQLException; -import org.sonar.api.config.Configuration; import org.sonar.db.Database; import org.sonar.db.dialect.Dialect; @@ -63,10 +62,6 @@ public abstract class DataChange implements MigrationStep { return res; } - protected static boolean isSonarCloud(Configuration configuration) { - return configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false); - } - public static class Context { private final Database db; private final Connection readConnection; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java index c4781d78094..c7722b1e28b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java @@ -19,14 +19,8 @@ */ package org.sonar.server.notification.ws; -import com.google.common.collect.ImmutableSet; import java.util.List; -import java.util.Set; -import java.util.function.Predicate; import org.sonar.api.Startable; -import org.sonar.api.config.Configuration; -import org.sonar.process.ProcessProperties; -import org.sonar.server.qualitygate.notification.QGChangeNotificationHandler; import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION; @@ -34,18 +28,13 @@ import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_P public class DispatchersImpl implements Dispatchers, Startable { - private static final Set GLOBAL_DISPATCHERS_TO_IGNORE_ON_SONAR_CLOUD = ImmutableSet.of( - QGChangeNotificationHandler.KEY); - private final NotificationCenter notificationCenter; - private final Configuration configuration; private List projectDispatchers; private List globalDispatchers; - public DispatchersImpl(NotificationCenter notificationCenter, Configuration configuration) { + public DispatchersImpl(NotificationCenter notificationCenter) { this.notificationCenter = notificationCenter; - this.configuration = configuration; } @Override @@ -60,10 +49,8 @@ public class DispatchersImpl implements Dispatchers, Startable { @Override public void start() { - boolean isOnSonarCloud = configuration.getBoolean(ProcessProperties.Property.SONARCLOUD_ENABLED.getKey()).orElse(false); this.globalDispatchers = notificationCenter.getDispatcherKeysForProperty(GLOBAL_NOTIFICATION, "true") .stream() - .filter(filterDispatcherForSonarCloud(isOnSonarCloud)) .sorted() .collect(toList()); this.projectDispatchers = notificationCenter.getDispatcherKeysForProperty(PER_PROJECT_NOTIFICATION, "true") @@ -72,10 +59,6 @@ public class DispatchersImpl implements Dispatchers, Startable { .collect(toList()); } - private static Predicate filterDispatcherForSonarCloud(boolean isOnSonarCloud) { - return dispatcher -> !(isOnSonarCloud && GLOBAL_DISPATCHERS_TO_IGNORE_ON_SONAR_CLOUD.contains(dispatcher)); - } - @Override public void stop() { // nothing to do diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java index 45a768fe24d..d8ef16a9604 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java @@ -19,23 +19,20 @@ */ package org.sonar.server.platform.ws; -import org.sonar.api.config.Configuration; import org.sonar.core.platform.Module; import org.sonar.server.platform.WebServer; public class ChangeLogLevelActionModule extends Module { private final WebServer webServer; - private final Configuration configuration; - public ChangeLogLevelActionModule(WebServer webServer, Configuration configuration) { + public ChangeLogLevelActionModule(WebServer webServer) { this.webServer = webServer; - this.configuration = configuration; } @Override protected void configureModule() { add(ChangeLogLevelAction.class); - if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false) || webServer.isStandalone()) { + if (webServer.isStandalone()) { add(ChangeLogLevelStandaloneService.class); } else { add(ChangeLogLevelClusterService.class); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java index e430a11d77f..276b14b8ac4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java @@ -42,17 +42,14 @@ import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider; import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoaderImpl; public class WebSystemInfoModule extends Module { - private final Configuration configuration; private final WebServer webServer; - public WebSystemInfoModule(Configuration configuration, WebServer webServer) { - this.configuration = configuration; + public WebSystemInfoModule(WebServer webServer) { this.webServer = webServer; } @Override protected void configureModule() { - boolean sonarcloud = configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false); boolean standalone = webServer.isStandalone(); add( @@ -67,7 +64,7 @@ public class WebSystemInfoModule extends Module { InfoAction.class ); - if (standalone || sonarcloud) { + if (standalone) { add( EsStateSection.class, StandaloneSystemSection.class, diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java index 0152044acc0..186e38c2d2f 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java @@ -20,7 +20,6 @@ package org.sonar.server.notification.ws; import org.junit.Test; -import org.sonar.api.config.internal.MapSettings; import org.sonar.api.notifications.NotificationChannel; import org.sonar.server.issue.notification.FPOrWontFixNotificationHandler; import org.sonar.server.issue.notification.MyNewIssuesNotificationHandler; @@ -50,9 +49,7 @@ public class DispatchersImplTest { }, new NotificationChannel[] {}); - private final MapSettings settings = new MapSettings(); - - private DispatchersImpl underTest = new DispatchersImpl(notificationCenter, settings.asConfig()); + private DispatchersImpl underTest = new DispatchersImpl(notificationCenter); @Test public void get_sorted_global_dispatchers() { @@ -62,15 +59,6 @@ public class DispatchersImplTest { QGChangeNotificationHandler.KEY, MyNewIssuesNotificationHandler.KEY); } - @Test - public void get_global_dispatchers_on_sonarcloud() { - settings.setProperty("sonar.sonarcloud.enabled", "true"); - - underTest.start(); - - assertThat(underTest.getGlobalDispatchers()).containsOnly(MyNewIssuesNotificationHandler.KEY); - } - @Test public void get_sorted_project_dispatchers() { underTest.start(); @@ -79,13 +67,4 @@ public class DispatchersImplTest { QGChangeNotificationHandler.KEY, FPOrWontFixNotificationHandler.KEY, MyNewIssuesNotificationHandler.KEY); } - @Test - public void get_project_dispatchers_on_sonarcloud() { - settings.setProperty("sonar.sonarcloud.enabled", "true"); - - underTest.start(); - - assertThat(underTest.getProjectDispatchers()).containsOnly( - MyNewIssuesNotificationHandler.KEY, QGChangeNotificationHandler.KEY, FPOrWontFixNotificationHandler.KEY); - } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java index 5f52cee93c1..d69daf028f5 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java @@ -19,15 +19,9 @@ */ package org.sonar.server.platform.ws; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; import java.util.Collection; -import javax.annotation.Nullable; import org.junit.Test; -import org.junit.runner.RunWith; import org.picocontainer.ComponentAdapter; -import org.sonar.api.config.internal.MapSettings; import org.sonar.core.platform.ComponentContainer; import org.sonar.server.platform.WebServer; @@ -36,19 +30,13 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER; -@RunWith(DataProviderRunner.class) public class ChangeLogLevelActionModuleTest { private WebServer webServer = mock(WebServer.class); - private MapSettings settings = new MapSettings(); - private ChangeLogLevelActionModule underTest = new ChangeLogLevelActionModule(webServer, settings.asConfig()); + private ChangeLogLevelActionModule underTest = new ChangeLogLevelActionModule(webServer); @Test - @UseDataProvider("notOnSonarCloud") - public void provide_returns_ChangeLogLevelClusterService_if_cluster_not_on_SonarCloud(@Nullable Boolean sonarcloudOrNot) { + public void provide_returns_ChangeLogLevelClusterService_if_cluster_not_on_SonarCloud() { when(webServer.isStandalone()).thenReturn(false); - if (sonarcloudOrNot != null) { - settings.setProperty("sonar.sonarcloud.enabled", sonarcloudOrNot); - } ComponentContainer container = new ComponentContainer(); underTest.configure(container); @@ -62,23 +50,8 @@ public class ChangeLogLevelActionModuleTest { } @Test - public void provide_returns_ChangeLogLevelStandaloneService_on_SonarCloud() { - when(webServer.isStandalone()).thenReturn(false); - settings.setProperty("sonar.sonarcloud.enabled", true); - ComponentContainer container = new ComponentContainer(); - - underTest.configure(container); - - verifyInStandaloneSQ(container); - } - - @Test - @UseDataProvider("notOnSonarCloud") - public void provide_returns_ChangeLogLevelStandaloneService_if_SQ_standalone(@Nullable Boolean sonarcloudOrNot) { + public void provide_returns_ChangeLogLevelStandaloneService_if_SQ_standalone() { when(webServer.isStandalone()).thenReturn(true); - if (sonarcloudOrNot != null) { - settings.setProperty("sonar.sonarcloud.enabled", sonarcloudOrNot); - } ComponentContainer container = new ComponentContainer(); underTest.configure(container); @@ -95,13 +68,4 @@ public class ChangeLogLevelActionModuleTest { .doesNotContain(ChangeLogLevelClusterService.class); } - @DataProvider - public static Object[][] notOnSonarCloud() { - return new Object[][] { - {null}, - {false} - }; - } - - } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java index b96d38d1cd2..fb6485a6cf3 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java @@ -19,15 +19,9 @@ */ package org.sonar.server.platform.ws; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; import java.util.Collection; -import javax.annotation.Nullable; import org.junit.Test; -import org.junit.runner.RunWith; import org.picocontainer.ComponentAdapter; -import org.sonar.api.config.internal.MapSettings; import org.sonar.core.platform.ComponentContainer; import org.sonar.server.platform.WebServer; @@ -36,19 +30,13 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER; -@RunWith(DataProviderRunner.class) public class WebSystemInfoModuleTest { private WebServer webServer = mock(WebServer.class); - private MapSettings settings = new MapSettings(); - private WebSystemInfoModule underTest = new WebSystemInfoModule(settings.asConfig(), webServer); + private WebSystemInfoModule underTest = new WebSystemInfoModule(webServer); @Test - @UseDataProvider("notOnSonarCloud") - public void verify_system_info_configuration_in_cluster_mode(@Nullable Boolean notOnSonarCloud) { + public void verify_system_info_configuration_in_cluster_mode() { when(webServer.isStandalone()).thenReturn(false); - if (notOnSonarCloud != null) { - settings.setProperty("sonar.sonarcloud.enabled", notOnSonarCloud); - } ComponentContainer container = new ComponentContainer(); underTest.configure(container); @@ -59,23 +47,8 @@ public class WebSystemInfoModuleTest { } @Test - @UseDataProvider("notOnSonarCloud") - public void verify_system_info_configuration_in_standalone_mode(@Nullable Boolean notOnSonarCloud) { + public void verify_system_info_configuration_in_standalone_mode() { when(webServer.isStandalone()).thenReturn(true); - if (notOnSonarCloud != null) { - settings.setProperty("sonar.sonarcloud.enabled", notOnSonarCloud); - } - ComponentContainer container = new ComponentContainer(); - - underTest.configure(container); - - verifyConfigurationStandaloneSQ(container); - } - - @Test - public void verify_system_info_configuration_on_SonarCloud() { - when(webServer.isStandalone()).thenReturn(false); - settings.setProperty("sonar.sonarcloud.enabled", true); ComponentContainer container = new ComponentContainer(); underTest.configure(container); @@ -89,11 +62,4 @@ public class WebSystemInfoModuleTest { .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12); } - @DataProvider - public static Object[][] notOnSonarCloud() { - return new Object[][] { - {null}, - {false} - }; - } }