]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17115 Migrate Multiple ALM feature
authorJeremy Davis <jeremy.davis@sonarsource.com>
Fri, 23 Sep 2022 15:15:08 +0000 (17:15 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 27 Sep 2022 20:03:17 +0000 (20:03 +0000)
28 files changed:
server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeature.java [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeatureProvider.java [deleted file]
server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureProviderTest.java [deleted file]
server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureTest.java [new file with mode: 0644]
server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap
server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/SettingsAppRenderer-test.tsx.snap
server/sonar-web/src/main/js/apps/settings/components/almIntegration/AlmIntegration.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx
server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegration-test.tsx.snap
server/sonar-web/src/main/js/types/appstate.ts
server/sonar-web/src/main/js/types/features.ts
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CountBindingActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateAzureActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketCloudActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGithubActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGitlabActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/DeleteActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateAzureActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGithubActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGitlabActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/ValidateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java
server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java

diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeature.java b/server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeature.java
new file mode 100644 (file)
index 0000000..a4ceb3d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.almsettings;
+
+import org.sonar.api.SonarRuntime;
+import org.sonar.api.ce.ComputeEngineSide;
+import org.sonar.api.server.ServerSide;
+import org.sonar.server.feature.SonarQubeFeature;
+
+import static org.sonar.api.SonarEdition.DATACENTER;
+import static org.sonar.api.SonarEdition.ENTERPRISE;
+
+@ServerSide
+@ComputeEngineSide
+public class MultipleAlmFeature implements SonarQubeFeature {
+
+  private final SonarRuntime sonarRuntime;
+
+  public MultipleAlmFeature(SonarRuntime sonarRuntime) {
+    this.sonarRuntime = sonarRuntime;
+  }
+
+  @Override
+  public String getName()  {
+    return "multiple-alm";
+  }
+
+  @Override
+  public boolean isEnabled() {
+    return sonarRuntime.getEdition() == ENTERPRISE || sonarRuntime.getEdition() == DATACENTER;
+  }
+
+}
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeatureProvider.java b/server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeatureProvider.java
deleted file mode 100644 (file)
index 82cfe76..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.almsettings;
-
-import java.util.Optional;
-import org.sonar.core.platform.EditionProvider;
-import org.sonar.core.platform.PlatformEditionProvider;
-
-public class MultipleAlmFeatureProvider {
-
-  private PlatformEditionProvider editionProvider;
-
-  public MultipleAlmFeatureProvider(PlatformEditionProvider editionProvider) {
-    this.editionProvider = editionProvider;
-  }
-
-  public boolean enabled() {
-    Optional<EditionProvider.Edition> edition = editionProvider.get();
-    if (!edition.isPresent()) {
-      return false;
-    }
-    switch (edition.get()) {
-      case ENTERPRISE:
-      case DATACENTER:
-        return true;
-      default:
-        return false;
-    }
-  }
-
-}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureProviderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureProviderTest.java
deleted file mode 100644 (file)
index 9bba39e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2022 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.almsettings;
-
-import java.util.Optional;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
-import org.sonar.core.platform.EditionProvider;
-import org.sonar.core.platform.PlatformEditionProvider;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MultipleAlmFeatureProviderTest {
-
-  private PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
-  private final MultipleAlmFeatureProvider underTest = new MultipleAlmFeatureProvider(editionProvider);
-
-  @Test
-  public void is_enabled_on_CE() {
-    when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.COMMUNITY));
-    Assertions.assertThat(underTest.enabled()).isFalse();
-  }
-
-  @Test
-  public void is_enabled_on_DE() {
-    when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DEVELOPER));
-    Assertions.assertThat(underTest.enabled()).isFalse();
-  }
-
-  @Test
-  public void is_enabled_on_EE() {
-    when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.ENTERPRISE));
-    Assertions.assertThat(underTest.enabled()).isTrue();
-  }
-
-  @Test
-  public void is_enabled_on_DCE() {
-    when(editionProvider.get()).thenReturn(Optional.of(EditionProvider.Edition.DATACENTER));
-    Assertions.assertThat(underTest.enabled()).isTrue();
-  }
-}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureTest.java
new file mode 100644 (file)
index 0000000..7a9c04d
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.almsettings;
+
+import com.tngtech.java.junit.dataprovider.DataProvider;
+import com.tngtech.java.junit.dataprovider.DataProviderRunner;
+import com.tngtech.java.junit.dataprovider.UseDataProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.sonar.api.SonarEdition;
+import org.sonar.api.SonarRuntime;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith(DataProviderRunner.class)
+public class MultipleAlmFeatureTest {
+
+  private final SonarRuntime sonarRuntime = mock(SonarRuntime.class);
+  private final MultipleAlmFeature underTest = new MultipleAlmFeature(sonarRuntime);
+
+  @Test
+  public void getName_nameShouldBeCorrect() {
+    assertEquals("multiple-alm",underTest.getName());
+  }
+
+  @Test
+  @UseDataProvider("editionsAndMultipleAlmAvailability")
+  public void isEnabled_shouldOnlyBeEnabledInEnterpriseEditionPlus(SonarEdition edition, boolean shouldBeEnabled) {
+    when(sonarRuntime.getEdition()).thenReturn(edition);
+
+    boolean isEnabled = underTest.isEnabled();
+
+    assertThat(isEnabled).isEqualTo(shouldBeEnabled);
+  }
+
+  @DataProvider
+  public static Object[][] editionsAndMultipleAlmAvailability() {
+    return new Object[][] {
+      {SonarEdition.COMMUNITY, false},
+      {SonarEdition.DEVELOPER, false},
+      {SonarEdition.ENTERPRISE, true},
+      {SonarEdition.DATACENTER, true}
+    };
+  }
+}
index 8a48cd3c24df9e0d30d80cb1e8fa53971d6df0e6..e9f366fc6fe99e7f779adba5c2525670ef289591 100644 (file)
@@ -63,7 +63,7 @@ exports[`should render additional categories component correctly 3`] = `
 `;
 
 exports[`should render additional categories component correctly 4`] = `
-<withRouter(withAppStateContext(AlmIntegration))
+<withRouter(withAppStateContext(withAvailableFeaturesContext(AlmIntegration)))
   categories={Array []}
   component={
     Object {
index 7de14af9ca2c980ef5d4122e5251b26a0a471734..d251c34105f56beddfc0cd752511d29f63ca9b31 100644 (file)
@@ -51,7 +51,7 @@ exports[`should render almintegration correctly 1`] = `
           className="big-padded"
           key="almintegration"
         >
-          <withRouter(withAppStateContext(AlmIntegration))
+          <withRouter(withAppStateContext(withAvailableFeaturesContext(AlmIntegration)))
             categories={
               Array [
                 "foo category",
index bb471ee144e321edf53ba44771abfa5e66d19fd8..f92b709abca67efe7f60c0614dfd2de07b887fc0 100644 (file)
@@ -25,6 +25,7 @@ import {
   validateAlmSettings
 } from '../../../../api/alm-settings';
 import withAppStateContext from '../../../../app/components/app-state/withAppStateContext';
+import withAvailableFeatures from '../../../../app/components/available-features/withAvailableFeatures';
 import { Location, Router, withRouter } from '../../../../components/hoc/withRouter';
 import {
   AlmBindingDefinitionBase,
@@ -34,11 +35,13 @@ import {
   AlmSettingsBindingStatusType
 } from '../../../../types/alm-settings';
 import { AppState } from '../../../../types/appstate';
+import { Feature } from '../../../../types/features';
 import { Dict } from '../../../../types/types';
 import AlmIntegrationRenderer from './AlmIntegrationRenderer';
 
 interface Props {
   appState: AppState;
+  hasFeature: (feature: Feature) => boolean;
   location: Location;
   router: Router;
 }
@@ -210,7 +213,8 @@ export class AlmIntegration extends React.PureComponent<Props, State> {
 
   render() {
     const {
-      appState: { branchesEnabled, multipleAlmEnabled }
+      appState: { branchesEnabled },
+      hasFeature
     } = this.props;
     const {
       currentAlmTab,
@@ -225,7 +229,7 @@ export class AlmIntegration extends React.PureComponent<Props, State> {
     return (
       <AlmIntegrationRenderer
         branchesEnabled={Boolean(branchesEnabled)}
-        multipleAlmEnabled={Boolean(multipleAlmEnabled)}
+        multipleAlmEnabled={hasFeature(Feature.MultipleAlm)}
         onCancelDelete={this.handleCancelDelete}
         onConfirmDelete={this.handleConfirmDelete}
         onCheckConfiguration={this.handleCheck}
@@ -244,4 +248,4 @@ export class AlmIntegration extends React.PureComponent<Props, State> {
   }
 }
 
-export default withRouter(withAppStateContext(AlmIntegration));
+export default withRouter(withAppStateContext(withAvailableFeatures(AlmIntegration)));
index 4b3fad35c2494c46abca3a6e637fae119ee2ecb5..e8ec58bb592509a38458dd26dbbdcf49254a0520 100644 (file)
@@ -191,6 +191,7 @@ function shallowRender(props: Partial<AlmIntegration['props']> = {}) {
     <AlmIntegration
       appState={mockAppState({ branchesEnabled: true })}
       location={mockLocation()}
+      hasFeature={jest.fn()}
       router={mockRouter()}
       {...props}
     />
index 193dfaf0360d768bbfd942f1750a001248614f3c..c84b2fc9fc23ddec9edbc5b2e9582ffe2a612de9 100644 (file)
@@ -16,7 +16,6 @@ exports[`should render correctly 1`] = `
   }
   loadingAlmDefinitions={true}
   loadingProjectCount={false}
-  multipleAlmEnabled={false}
   onCancelDelete={[Function]}
   onCheckConfiguration={[Function]}
   onConfirmDelete={[Function]}
index 8124f143bb12b9f015c352a51bd9e12b35bd4ac3..d90558d00210166d767737ec5287d785243c16f1 100644 (file)
@@ -30,7 +30,6 @@ export interface AppState {
   edition?: EditionKey;
   globalPages?: Extension[];
   instanceUsesDefaultAdminCredentials?: boolean;
-  multipleAlmEnabled?: boolean;
   needIssueSync?: boolean;
   productionDatabase: boolean;
   qualifiers: string[];
index 87363ff5c2f18c41baaaa18d0cd556d66fb8863b..768e51e41ca62f68bd32fca6b08f4e7158330e7b 100644 (file)
@@ -21,5 +21,6 @@
 export enum Feature {
   MonoRepositoryPullRequestDecoration = 'monorepo',
   RegulatoryReport = 'regulatory-reports',
-  ProjectImport = 'project-import'
+  ProjectImport = 'project-import',
+  MultipleAlm = 'multiple-alm'
 }
index c4c82245c2bd0198c2fa2e5314bd1b6d1e09eaa6..4ce76e69e5780f6cba0e0af2264a3bd4473eefd5 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.alm.setting.ALM;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.project.ProjectDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -44,18 +44,18 @@ public class AlmSettingsSupport {
   private final DbClient dbClient;
   private final UserSession userSession;
   private final ComponentFinder componentFinder;
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider;
+  private final MultipleAlmFeature multipleAlmFeature;
 
   public AlmSettingsSupport(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder,
-    MultipleAlmFeatureProvider multipleAlmFeatureProvider) {
+    MultipleAlmFeature multipleAlmFeature) {
     this.dbClient = dbClient;
     this.userSession = userSession;
     this.componentFinder = componentFinder;
-    this.multipleAlmFeatureProvider = multipleAlmFeatureProvider;
+    this.multipleAlmFeature = multipleAlmFeature;
   }
 
-  public MultipleAlmFeatureProvider getMultipleAlmFeatureProvider() {
-    return multipleAlmFeatureProvider;
+  public MultipleAlmFeature getMultipleAlmFeatureProvider() {
+    return multipleAlmFeature;
   }
 
   public void checkAlmSettingDoesNotAlreadyExist(DbSession dbSession, String almSetting) {
@@ -67,7 +67,7 @@ public class AlmSettingsSupport {
 
   public void checkAlmMultipleFeatureEnabled(ALM alm) {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      if (!multipleAlmFeatureProvider.enabled() && !dbClient.almSettingDao().selectByAlm(dbSession, alm).isEmpty()) {
+      if (!multipleAlmFeature.isEnabled() && !dbClient.almSettingDao().selectByAlm(dbSession, alm).isEmpty()) {
         throw BadRequestException.create("A " + alm + " setting is already defined");
       }
     }
index 0eaf0ec4ac558b8cfe657f3ae98da7334abeff73..fa9bbb336702baeb9a70d2c7016e0d7a43e04187 100644 (file)
  */
 package org.sonar.server.ui.ws;
 
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import javax.annotation.Nullable;
 import org.sonar.api.Startable;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.platform.Server;
@@ -39,7 +37,6 @@ import org.sonar.core.platform.PlatformEditionProvider;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.dialect.H2;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
 import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
 import org.sonar.server.branch.BranchFeatureProxy;
 import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
@@ -55,9 +52,6 @@ import static org.sonar.core.config.WebConstants.SONAR_LF_ENABLE_GRAVATAR;
 import static org.sonar.core.config.WebConstants.SONAR_LF_GRAVATAR_SERVER_URL;
 import static org.sonar.core.config.WebConstants.SONAR_LF_LOGO_URL;
 import static org.sonar.core.config.WebConstants.SONAR_LF_LOGO_WIDTH_PX;
-import static org.sonar.core.platform.EditionProvider.Edition;
-import static org.sonar.core.platform.EditionProvider.Edition.DATACENTER;
-import static org.sonar.core.platform.EditionProvider.Edition.ENTERPRISE;
 import static org.sonar.process.ProcessProperties.Property.SONAR_UPDATECENTER_ACTIVATE;
 
 public class GlobalAction implements NavigationWsAction, Startable {
@@ -69,7 +63,7 @@ public class GlobalAction implements NavigationWsAction, Startable {
     SONAR_LF_GRAVATAR_SERVER_URL,
     RATING_GRID,
     DEVELOPER_AGGREGATED_INFO_DISABLED);
-  
+
   private final Map<String, String> systemSettingValuesByKey;
 
   private final PageRepository pageRepository;
@@ -81,14 +75,13 @@ public class GlobalAction implements NavigationWsAction, Startable {
   private final BranchFeatureProxy branchFeature;
   private final UserSession userSession;
   private final PlatformEditionProvider editionProvider;
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider;
   private final WebAnalyticsLoader webAnalyticsLoader;
   private final IssueIndexSyncProgressChecker issueIndexSyncChecker;
   private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier;
 
   public GlobalAction(PageRepository pageRepository, Configuration config, ResourceTypes resourceTypes, Server server,
     WebServer webServer, DbClient dbClient, BranchFeatureProxy branchFeature, UserSession userSession, PlatformEditionProvider editionProvider,
-    MultipleAlmFeatureProvider multipleAlmFeatureProvider, WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker,
+    WebAnalyticsLoader webAnalyticsLoader, IssueIndexSyncProgressChecker issueIndexSyncChecker,
     DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier) {
     this.pageRepository = pageRepository;
     this.config = config;
@@ -99,7 +92,6 @@ public class GlobalAction implements NavigationWsAction, Startable {
     this.branchFeature = branchFeature;
     this.userSession = userSession;
     this.editionProvider = editionProvider;
-    this.multipleAlmFeatureProvider = multipleAlmFeatureProvider;
     this.webAnalyticsLoader = webAnalyticsLoader;
     this.systemSettingValuesByKey = new HashMap<>();
     this.issueIndexSyncChecker = issueIndexSyncChecker;
@@ -139,7 +131,6 @@ public class GlobalAction implements NavigationWsAction, Startable {
       writeDatabaseProduction(json);
       writeBranchSupport(json);
       writeInstanceUsesDefaultAdminCredentials(json);
-      writeMultipleAlmEnabled(json);
       editionProvider.get().ifPresent(e -> json.prop("edition", e.name().toLowerCase(Locale.ENGLISH)));
       writeNeedIssueSync(json);
       json.prop("standalone", webServer.isStandalone());
@@ -202,10 +193,6 @@ public class GlobalAction implements NavigationWsAction, Startable {
     }
   }
 
-  private void writeMultipleAlmEnabled(JsonWriter json) {
-    json.prop("multipleAlmEnabled", multipleAlmFeatureProvider.enabled());
-  }
-
   private void writeNeedIssueSync(JsonWriter json) {
     try (DbSession dbSession = dbClient.openSession(false)) {
       json.prop("needIssueSync", issueIndexSyncChecker.isIssueSyncInProgress(dbSession));
@@ -215,8 +202,4 @@ public class GlobalAction implements NavigationWsAction, Startable {
   private void writeWebAnalytics(JsonWriter json) {
     webAnalyticsLoader.getUrlPathToJs().ifPresent(p -> json.prop("webAnalyticsJsPath", p));
   }
-
-  private static boolean isEditionEEorDCE(@Nullable Edition edition) {
-    return Arrays.asList(ENTERPRISE, DATACENTER).contains(edition);
-  }
 }
index 5304321981b837477b8c806f1a062941e05fb1ba..e241dc21fec372525e59701a25e368f1546affa5 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.project.ProjectDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -49,7 +49,7 @@ public class CountBindingActionTest {
 
   private WsActionTester ws = new WsActionTester(new CountBindingAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      mock(MultipleAlmFeatureProvider.class))));
+      mock(MultipleAlmFeature.class))));
 
   @Test
   public void count_github_binding() {
index 9814aac7ecc31923d63a7fa3d4e3387affcbbb6a..b820386c852b702d33c9ff0e440f84c185c2e098 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -48,15 +48,15 @@ public class CreateAzureActionTest {
   public DbTester db = DbTester.create();
 
   private final Encryption encryption = mock(Encryption.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
 
   private WsActionTester ws = new WsActionTester(new CreateAzureAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      multipleAlmFeatureProvider)));
+      multipleAlmFeature)));
 
   @Before
   public void before() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
   }
 
   @Test
@@ -79,7 +79,7 @@ public class CreateAzureActionTest {
 
   @Test
   public void fail_when_key_is_already_used() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+    when(multipleAlmFeature.isEnabled()).thenReturn(true);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     AlmSettingDto azureAlmSetting = db.almSettings().insertAzureAlmSetting();
@@ -95,7 +95,7 @@ public class CreateAzureActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     db.almSettings().insertAzureAlmSetting();
index 29281b77c2927b0c650c0a1556861aca79df26e2..ed083fd90a4df04013f08440652e30f5135729e7 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -48,15 +48,15 @@ public class CreateBitbucketActionTest {
   public DbTester db = DbTester.create();
 
   private final Encryption encryption = mock(Encryption.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
 
   private WsActionTester ws = new WsActionTester(new CreateBitBucketAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      multipleAlmFeatureProvider)));
+      multipleAlmFeature)));
 
   @Before
   public void before() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
   }
 
   @Test
@@ -77,7 +77,7 @@ public class CreateBitbucketActionTest {
 
   @Test
   public void fail_when_key_is_already_used() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+    when(multipleAlmFeature.isEnabled()).thenReturn(true);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
@@ -93,7 +93,7 @@ public class CreateBitbucketActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     db.almSettings().insertBitbucketAlmSetting();
@@ -109,7 +109,7 @@ public class CreateBitbucketActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed_and_bitbucket_cloud_exists() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     db.almSettings().insertBitbucketCloudAlmSetting();
index c2a6f93e228c9caf4a4357295a8fd357918fdc3c..4742b928656d715a0b4fd6440303e32817165d4d 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -50,15 +50,15 @@ public class CreateBitbucketCloudActionTest {
   public DbTester db = DbTester.create();
 
   private final Encryption encryption = mock(Encryption.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
 
   private WsActionTester ws = new WsActionTester(new CreateBitbucketCloudAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      multipleAlmFeatureProvider)));
+      multipleAlmFeature)));
 
   @Before
   public void before() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
   }
 
   @Test
@@ -80,7 +80,7 @@ public class CreateBitbucketCloudActionTest {
 
   @Test
   public void fail_when_key_is_already_used() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+    when(multipleAlmFeature.isEnabled()).thenReturn(true);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
@@ -97,7 +97,7 @@ public class CreateBitbucketCloudActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     db.almSettings().insertBitbucketCloudAlmSetting();
@@ -114,7 +114,7 @@ public class CreateBitbucketCloudActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed_and_bitbucket_server_exists() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     db.almSettings().insertBitbucketAlmSetting();
@@ -145,7 +145,7 @@ public class CreateBitbucketCloudActionTest {
 
   @Test
   public void fail_when_workspace_id_format_is_incorrect() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     String workspace = "workspace/name";
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
@@ -166,7 +166,7 @@ public class CreateBitbucketCloudActionTest {
 
   @Test
   public void do_not_fail_when_workspace_id_format_is_correct() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     String workspace = "work-space_123";
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
index 5d3b478838dd99041dcf973fbf8cd0af363a8e8b..52e262ec3b6f63331c5255c3406510c28219964c 100644 (file)
@@ -31,7 +31,7 @@ import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.ALM;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -55,15 +55,15 @@ public class CreateGithubActionTest {
   public DbTester db = DbTester.create();
 
   private final Encryption encryption = mock(Encryption.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
 
   private final WsActionTester ws = new WsActionTester(new CreateGithubAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)),
-      multipleAlmFeatureProvider)));
+      multipleAlmFeature)));
 
   @Before
   public void setUp() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
   }
@@ -120,7 +120,7 @@ public class CreateGithubActionTest {
 
   @Test
   public void fail_when_key_is_already_used() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+    when(multipleAlmFeature.isEnabled()).thenReturn(true);
     AlmSettingDto gitHubAlmSetting = db.almSettings().insertGitHubAlmSetting();
 
     TestRequest request = buildTestRequest().setParam("key", gitHubAlmSetting.getKey());
@@ -132,7 +132,7 @@ public class CreateGithubActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     db.almSettings().insertGitHubAlmSetting();
 
     TestRequest request = buildTestRequest();
index d87093c067a8f0f9bc80b167599e29a8b59bbf3c..6a1e25ef7c7890cef2847fbaf4d841e1b5eb19a6 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -52,14 +52,14 @@ public class CreateGitlabActionTest {
   private static String GITLAB_URL = "gitlab.com/api/v4";
 
   private final Encryption encryption = mock(Encryption.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
 
   private WsActionTester ws = new WsActionTester(new CreateGitlabAction(db.getDbClient(), userSession,
-    new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeatureProvider)));
+    new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeature)));
 
   @Before
   public void before() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
   }
 
   @Test
@@ -109,7 +109,7 @@ public class CreateGitlabActionTest {
 
   @Test
   public void fail_when_key_is_already_used() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+    when(multipleAlmFeature.isEnabled()).thenReturn(true);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     AlmSettingDto gitlabAlmSetting = db.almSettings().insertGitlabAlmSetting();
@@ -125,7 +125,7 @@ public class CreateGitlabActionTest {
 
   @Test
   public void fail_when_no_multiple_instance_allowed() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
+    when(multipleAlmFeature.isEnabled()).thenReturn(false);
     UserDto user = db.users().insertUser();
     userSession.logIn(user).setSystemAdministrator();
     db.almSettings().insertGitlabAlmSetting();
index d89cbdcf663769dfd150d3e1fffc83d67c0266c3..5f2fe5af070462fd5e5afb02ce725c54a818b157 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.db.alm.pat.AlmPatDto;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.project.ProjectDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -48,7 +48,7 @@ public class DeleteActionTest {
 
   private WsActionTester ws = new WsActionTester(new DeleteAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      mock(MultipleAlmFeatureProvider.class))));
+      mock(MultipleAlmFeature.class))));
 
   @Test
   public void delete() {
index 99c77e27f4b45efa7fb0710dc1f1faefdd2171e3..e53840f2a5173b22f37ebeca6fc1b9159af6e90c 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -52,7 +52,7 @@ public class UpdateAzureActionTest {
 
   private WsActionTester ws = new WsActionTester(new UpdateAzureAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      mock(MultipleAlmFeatureProvider.class))));
+      mock(MultipleAlmFeature.class))));
 
   @Test
   public void update() {
index 49abdc085f61ef0504ce85922aa029f4e089c50d..88f62e419931e32577c8901cc043c6912928365d 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -50,7 +50,7 @@ public class UpdateBitbucketActionTest {
 
   private WsActionTester ws = new WsActionTester(new UpdateBitbucketAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null),
-      mock(MultipleAlmFeatureProvider.class))));
+      mock(MultipleAlmFeature.class))));
 
   @Test
   public void update() {
index 754ce105ebbdbff2cd4c7bdf6e146c9db02cadac..36e4961491b08df75ec1f2cc44ac9c9257e6a4c3 100644 (file)
@@ -27,7 +27,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -55,7 +55,7 @@ public class UpdateBitbucketCloudActionTest {
 
   private final WsActionTester ws = new WsActionTester(new UpdateBitbucketCloudAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)),
-      mock(MultipleAlmFeatureProvider.class))));
+      mock(MultipleAlmFeature.class))));
 
   @Test
   public void update() {
index 1546a24be1866124711be32d9e194d2735035bfd..14039eeb7bc35a403fb333aa1afe15dcb20be5cf 100644 (file)
@@ -39,7 +39,7 @@ import org.sonar.db.audit.AuditPersister;
 import org.sonar.db.audit.model.DevOpsPlatformSettingNewValue;
 import org.sonar.db.audit.model.SecretNewValue;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -71,7 +71,7 @@ public class UpdateGithubActionTest {
 
   private final WsActionTester ws = new WsActionTester(new UpdateGithubAction(db.getDbClient(), userSession,
     new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class)),
-      mock(MultipleAlmFeatureProvider.class))));
+      mock(MultipleAlmFeature.class))));
 
   private AlmSettingDto almSettingDto;
 
index c7a8df54604d85805cf3e1b543ad148c81cbf17f..0499738e5f8f1ffe94773749e8cae6bdecabe724 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -53,14 +53,14 @@ public class UpdateGitlabActionTest {
   private static String GITLAB_URL = "gitlab.com/api/v4";
 
   private final Encryption encryption = mock(Encryption.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
 
   private WsActionTester ws = new WsActionTester(new UpdateGitlabAction(db.getDbClient(), userSession,
-    new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeatureProvider)));
+    new AlmSettingsSupport(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), null), multipleAlmFeature)));
 
   @Before
   public void before() {
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
+    when(multipleAlmFeature.isEnabled()).thenReturn(true);
   }
 
   @Test
index 7135180a04173941a6b1de08d4c25bac6ed4f106..169d28d28cc9751d48942be83a5800fbe342b7f6 100644 (file)
@@ -38,7 +38,7 @@ import org.sonar.db.user.UserDto;
 import org.sonar.alm.client.bitbucketserver.BitbucketServerSettingsValidator;
 import org.sonar.alm.client.github.GithubGlobalSettingsValidator;
 import org.sonar.alm.client.gitlab.GitlabGlobalSettingsValidator;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.exceptions.ForbiddenException;
 import org.sonar.server.exceptions.NotFoundException;
@@ -64,9 +64,9 @@ public class ValidateActionTest {
   @Rule
   public DbTester db = DbTester.create();
 
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
+  private final MultipleAlmFeature multipleAlmFeature = mock(MultipleAlmFeature.class);
   private final ComponentFinder componentFinder = new ComponentFinder(db.getDbClient(), mock(ResourceTypes.class));
-  private final AlmSettingsSupport almSettingsSupport = new AlmSettingsSupport(db.getDbClient(), userSession, componentFinder, multipleAlmFeatureProvider);
+  private final AlmSettingsSupport almSettingsSupport = new AlmSettingsSupport(db.getDbClient(), userSession, componentFinder, multipleAlmFeature);
   private final AzureDevOpsHttpClient azureDevOpsHttpClient = mock(AzureDevOpsHttpClient.class);
   private final BitbucketCloudRestClient bitbucketCloudRestClient = mock(BitbucketCloudRestClient.class);
   private final GitlabGlobalSettingsValidator gitlabSettingsValidator = mock(GitlabGlobalSettingsValidator.class);
index efa3d9568eca6d7c8366043f0175660e9c6fab68..f23616f3b7648b2a74bb2d760617669a10738dda 100644 (file)
@@ -37,7 +37,6 @@ import org.sonar.core.platform.PluginRepository;
 import org.sonar.db.DbClient;
 import org.sonar.db.dialect.H2;
 import org.sonar.db.dialect.PostgreSql;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
 import org.sonar.server.authentication.DefaultAdminCredentialsVerifier;
 import org.sonar.server.issue.index.IssueIndexSyncProgressChecker;
 import org.sonar.server.platform.WebServer;
@@ -67,7 +66,6 @@ public class GlobalActionTest {
   private final IssueIndexSyncProgressChecker indexSyncProgressChecker = mock(IssueIndexSyncProgressChecker.class);
   private final BranchFeatureRule branchFeature = new BranchFeatureRule();
   private final PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class);
-  private final MultipleAlmFeatureProvider multipleAlmFeatureProvider = mock(MultipleAlmFeatureProvider.class);
   private final WebAnalyticsLoader webAnalyticsLoader = mock(WebAnalyticsLoader.class);
   private final DefaultAdminCredentialsVerifier defaultAdminCredentialsVerifier = mock(DefaultAdminCredentialsVerifier.class);
 
@@ -226,17 +224,6 @@ public class GlobalActionTest {
     assertJson(call()).isSimilarTo("{\"branchesEnabled\":false}");
   }
 
-  @Test
-  public void multiple_alm_enabled() {
-    init();
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(true);
-    assertJson(call()).isSimilarTo("{\"multipleAlmEnabled\":true}");
-
-    when(multipleAlmFeatureProvider.enabled()).thenReturn(false);
-    assertJson(call()).isSimilarTo("{\"multipleAlmEnabled\":false}");
-
-  }
-
   @Test
   public void return_need_issue_sync() {
     init();
@@ -366,7 +353,7 @@ public class GlobalActionTest {
     }});
     pageRepository.start();
     GlobalAction wsAction = new GlobalAction(pageRepository, settings.asConfig(), new ResourceTypes(resourceTypeTrees), server,
-      webServer, dbClient, branchFeature, userSession, editionProvider, multipleAlmFeatureProvider, webAnalyticsLoader,
+      webServer, dbClient, branchFeature, userSession, editionProvider, webAnalyticsLoader,
       indexSyncProgressChecker, defaultAdminCredentialsVerifier);
     ws = new WsActionTester(wsAction);
     wsAction.start();
index 96ae215c715002d512139de7d5eca8d55d8d7bf7..f7057896da95b19c606cf8f925d0316f76809f10 100644 (file)
@@ -57,7 +57,7 @@ import org.sonar.server.almintegration.ws.AlmIntegrationsWSModule;
 import org.sonar.server.almintegration.ws.CredentialsEncoderHelper;
 import org.sonar.server.almintegration.ws.ImportHelper;
 import org.sonar.server.almintegration.ws.ProjectKeyGenerator;
-import org.sonar.server.almsettings.MultipleAlmFeatureProvider;
+import org.sonar.server.almsettings.MultipleAlmFeature;
 import org.sonar.server.almsettings.ws.AlmSettingsWsModule;
 import org.sonar.server.authentication.AuthenticationModule;
 import org.sonar.server.authentication.DefaultAdminCredentialsVerifierImpl;
@@ -563,7 +563,7 @@ public class PlatformLevel4 extends PlatformLevel {
       CoreExtensionBootstraper.class,
       CoreExtensionStopper.class,
 
-      MultipleAlmFeatureProvider.class,
+      MultipleAlmFeature.class,
 
       // ServerPush endpoints
       new ServerPushModule(),