From: Jeremy Davis Date: Fri, 23 Sep 2022 15:15:08 +0000 (+0200) Subject: SONAR-17115 Migrate Multiple ALM feature X-Git-Tag: 9.7.0.61563~162 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=57a8a41fa35a7949e9cb3582b60e368bd5253e2d;p=sonarqube.git SONAR-17115 Migrate Multiple ALM feature --- 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 index 00000000000..a4ceb3d2861 --- /dev/null +++ b/server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeature.java @@ -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 index 82cfe7665db..00000000000 --- a/server/sonar-server-common/src/main/java/org/sonar/server/almsettings/MultipleAlmFeatureProvider.java +++ /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 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 index 9bba39e71cb..00000000000 --- a/server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureProviderTest.java +++ /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 index 00000000000..7a9c04d9602 --- /dev/null +++ b/server/sonar-server-common/src/test/java/org/sonar/server/almsettings/MultipleAlmFeatureTest.java @@ -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} + }; + } +} diff --git a/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap index 8a48cd3c24d..e9f366fc6fe 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/__tests__/__snapshots__/AdditionalCategories-test.tsx.snap @@ -63,7 +63,7 @@ exports[`should render additional categories component correctly 3`] = ` `; exports[`should render additional categories component correctly 4`] = ` - - boolean; location: Location; router: Router; } @@ -210,7 +213,8 @@ export class AlmIntegration extends React.PureComponent { render() { const { - appState: { branchesEnabled, multipleAlmEnabled } + appState: { branchesEnabled }, + hasFeature } = this.props; const { currentAlmTab, @@ -225,7 +229,7 @@ export class AlmIntegration extends React.PureComponent { return ( { } } -export default withRouter(withAppStateContext(AlmIntegration)); +export default withRouter(withAppStateContext(withAvailableFeatures(AlmIntegration))); diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx index 4b3fad35c24..e8ec58bb592 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/AlmIntegration-test.tsx @@ -191,6 +191,7 @@ function shallowRender(props: Partial = {}) { diff --git a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegration-test.tsx.snap b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegration-test.tsx.snap index 193dfaf0360..c84b2fc9fc2 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegration-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/settings/components/almIntegration/__tests__/__snapshots__/AlmIntegration-test.tsx.snap @@ -16,7 +16,6 @@ exports[`should render correctly 1`] = ` } loadingAlmDefinitions={true} loadingProjectCount={false} - multipleAlmEnabled={false} onCancelDelete={[Function]} onCheckConfiguration={[Function]} onConfirmDelete={[Function]} diff --git a/server/sonar-web/src/main/js/types/appstate.ts b/server/sonar-web/src/main/js/types/appstate.ts index 8124f143bb1..d90558d0021 100644 --- a/server/sonar-web/src/main/js/types/appstate.ts +++ b/server/sonar-web/src/main/js/types/appstate.ts @@ -30,7 +30,6 @@ export interface AppState { edition?: EditionKey; globalPages?: Extension[]; instanceUsesDefaultAdminCredentials?: boolean; - multipleAlmEnabled?: boolean; needIssueSync?: boolean; productionDatabase: boolean; qualifiers: string[]; diff --git a/server/sonar-web/src/main/js/types/features.ts b/server/sonar-web/src/main/js/types/features.ts index 87363ff5c2f..768e51e41ca 100644 --- a/server/sonar-web/src/main/js/types/features.ts +++ b/server/sonar-web/src/main/js/types/features.ts @@ -21,5 +21,6 @@ export enum Feature { MonoRepositoryPullRequestDecoration = 'monorepo', RegulatoryReport = 'regulatory-reports', - ProjectImport = 'project-import' + ProjectImport = 'project-import', + MultipleAlm = 'multiple-alm' } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java index c4c82245c2b..4ce76e69e57 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/AlmSettingsSupport.java @@ -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"); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java index 0eaf0ec4ac5..fa9bbb33670 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/ws/GlobalAction.java @@ -19,12 +19,10 @@ */ 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 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); - } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CountBindingActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CountBindingActionTest.java index 5304321981b..e241dc21fec 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CountBindingActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CountBindingActionTest.java @@ -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() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateAzureActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateAzureActionTest.java index 9814aac7ecc..b820386c852 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateAzureActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateAzureActionTest.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketActionTest.java index 29281b77c29..ed083fd90a4 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketActionTest.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketCloudActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketCloudActionTest.java index c2a6f93e228..4742b928656 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketCloudActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateBitbucketCloudActionTest.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGithubActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGithubActionTest.java index 5d3b478838d..52e262ec3b6 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGithubActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGithubActionTest.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGitlabActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGitlabActionTest.java index d87093c067a..6a1e25ef7c7 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGitlabActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/CreateGitlabActionTest.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/DeleteActionTest.java index d89cbdcf663..5f2fe5af070 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/DeleteActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/DeleteActionTest.java @@ -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() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateAzureActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateAzureActionTest.java index 99c77e27f4b..e53840f2a51 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateAzureActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateAzureActionTest.java @@ -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() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketActionTest.java index 49abdc085f6..88f62e41993 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketActionTest.java @@ -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() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionTest.java index 754ce105ebb..36e4961491b 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateBitbucketCloudActionTest.java @@ -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() { diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGithubActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGithubActionTest.java index 1546a24be18..14039eeb7bc 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGithubActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGithubActionTest.java @@ -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; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGitlabActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGitlabActionTest.java index c7a8df54604..0499738e5f8 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGitlabActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/UpdateGitlabActionTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/ValidateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/ValidateActionTest.java index 7135180a041..169d28d28cc 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/ValidateActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almsettings/ws/ValidateActionTest.java @@ -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); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java index efa3d9568ec..f23616f3b76 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java @@ -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(); diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 96ae215c715..f7057896da9 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -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(),