]> source.dussan.org Git - sonarqube.git/commitdiff
remove some SonarCloud specific code
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 9 Aug 2019 15:07:03 +0000 (17:07 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 14 Aug 2019 18:21:13 +0000 (20:21 +0200)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/step/DataChange.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/notification/ws/DispatchersImplTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java

index a6beab641fc40f1bed45ee360a565e6dc18a0d20..51e36e4c5f12a8b2fb26c7daa3a1093362006b39 100644 (file)
@@ -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;
index c4781d7809446d8b199bc7c29ee49c0cf1d676e2..c7722b1e28ba854f3556d11af5933caee461af80 100644 (file)
  */
 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<String> GLOBAL_DISPATCHERS_TO_IGNORE_ON_SONAR_CLOUD = ImmutableSet.of(
-    QGChangeNotificationHandler.KEY);
-
   private final NotificationCenter notificationCenter;
-  private final Configuration configuration;
 
   private List<String> projectDispatchers;
   private List<String> 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<String> filterDispatcherForSonarCloud(boolean isOnSonarCloud) {
-    return dispatcher -> !(isOnSonarCloud && GLOBAL_DISPATCHERS_TO_IGNORE_ON_SONAR_CLOUD.contains(dispatcher));
-  }
-
   @Override
   public void stop() {
     // nothing to do
index 45a768fe24d1227341bafd0f11d7a5ff82134072..d8ef16a9604c5dc6d738881b6967a82c831e55f4 100644 (file)
  */
 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);
index e430a11d77f60df67977058bc83467d3840a3617..276b14b8ac4c54442f2814c13537da65b0bb7776 100644 (file)
@@ -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,
index 0152044acc0726a54e000e15e03562ca1a06caf1..186e38c2d2f3a014072aab0fdf88bcb68d054c71 100644 (file)
@@ -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);
-  }
 }
index 5f52cee93c1d30cdccc81772ddae95378a8d84d5..d69daf028f54a8cc81e5148fd38268fb996ead7f 100644 (file)
  */
 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}
-    };
-  }
-
-
 }
index b96d38d1cd26ed54fc05885a3f72bdf581d59087..fb6485a6cf39d9780c4561148e700982e42756d9 100644 (file)
  */
 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}
-    };
-  }
 }