From 82ed20a6d9aec68faf5bc99e78a25aba42c9fedb Mon Sep 17 00:00:00 2001 From: Jacek Date: Thu, 17 Dec 2020 09:46:33 +0100 Subject: [PATCH] SONAR-13999 drop leftovers of organization from QualityProfile WSs --- .../qualityprofile/ws/QProfileReference.java | 2 +- .../qualityprofile/ws/QProfileWsSupport.java | 2 +- .../QProfileBackuperImplTest.java | 12 ++- .../QProfileComparisonTest.java | 5 +- .../qualityprofile/QProfileCopierTest.java | 13 ++-- .../qualityprofile/QProfileExportersTest.java | 44 +++++------ .../qualityprofile/QProfileTesting.java | 73 ------------------- .../ws/ActivateRuleActionTest.java | 10 +-- .../qualityprofile/ws/AddGroupActionTest.java | 6 +- .../ws/AddProjectActionTest.java | 38 ++++------ .../qualityprofile/ws/AddUserActionTest.java | 16 ---- .../qualityprofile/ws/BackupActionTest.java | 8 +- .../ws/ChangelogActionTest.java | 38 +--------- .../qualityprofile/ws/CopyActionTest.java | 4 +- .../ws/DeactivateRuleActionTest.java | 12 +-- .../qualityprofile/ws/DeleteActionTest.java | 31 ++------ .../qualityprofile/ws/ExportActionTest.java | 10 +-- .../qualityprofile/ws/ProjectsActionTest.java | 12 ++- .../ws/QProfilesWsMediumTest.java | 25 +++---- .../ws/RemoveGroupActionTest.java | 18 +---- .../ws/RemoveProjectActionTest.java | 14 ++-- .../ws/RemoveUserActionTest.java | 2 +- .../qualityprofile/ws/RestoreActionTest.java | 48 +++--------- .../qualityprofile/ws/SearchActionTest.java | 24 ++---- .../ws/SearchGroupsActionTest.java | 4 +- .../ws/SearchUsersActionTest.java | 2 +- .../sonar/server/rule/RuleUpdaterTest.java | 44 +++++------ 27 files changed, 151 insertions(+), 366 deletions(-) delete mode 100644 server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileTesting.java diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java index 001576115b0..bb404d594bd 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileReference.java @@ -38,7 +38,7 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. * The two exclusive options to reference a profile are: * */ public class QProfileReference { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java index ce8eece577c..c262b55730c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/QProfileWsSupport.java @@ -58,7 +58,7 @@ public class QProfileWsSupport { /** * Get the Quality profile specified by the reference {@code ref}. * - * @throws org.sonar.server.exceptions.NotFoundException if the specified organization or profile do not exist + * @throws org.sonar.server.exceptions.NotFoundException if the specified profile do not exist */ public QProfileDto getProfile(DbSession dbSession, QProfileReference ref) { QProfileDto profile; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperImplTest.java index da9b72c4f17..fe515bba887 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperImplTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperImplTest.java @@ -38,7 +38,6 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.qualityprofile.ActiveRuleDto; import org.sonar.db.qualityprofile.ActiveRuleParamDto; import org.sonar.db.qualityprofile.QProfileDto; @@ -64,18 +63,18 @@ public class QProfileBackuperImplTest { "" + ""; - private System2 system2 = new AlwaysIncreasingSystem2(); + private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule public ExpectedException expectedException = none(); @Rule public DbTester db = DbTester.create(system2); - private DummyReset reset = new DummyReset(); - private QProfileFactory profileFactory = new DummyProfileFactory(); - private RuleCreator ruleCreator = mock(RuleCreator.class); + private final DummyReset reset = new DummyReset(); + private final QProfileFactory profileFactory = new DummyProfileFactory(); + private final RuleCreator ruleCreator = mock(RuleCreator.class); - private QProfileBackuper underTest = new QProfileBackuperImpl(db.getDbClient(), reset, profileFactory, ruleCreator, new QProfileParser()); + private final QProfileBackuper underTest = new QProfileBackuperImpl(db.getDbClient(), reset, profileFactory, ruleCreator, new QProfileParser()); @Test public void backup_generates_xml_file() { @@ -350,7 +349,6 @@ public class QProfileBackuperImplTest { @Test public void fail_to_restore_external_rule() { db.rules().insert(RuleKey.of("sonarjs", "s001"), r -> r.setIsExternal(true)); - OrganizationDto organization = db.organizations().getDefaultOrganization(); Reader backup = new StringReader("" + "foo" + "js" + diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java index 22be30aa93e..52a5645b3c5 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java @@ -33,6 +33,7 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.qualityprofile.QProfileDto; +import org.sonar.db.qualityprofile.QualityProfileTesting; import org.sonar.db.rule.RuleDefinitionDto; import org.sonar.db.rule.RuleParamDto; import org.sonar.db.rule.RuleTesting; @@ -86,8 +87,8 @@ public class QProfileComparisonTest { db.ruleDao().insertRuleParam(dbSession, xooRule1, RuleParamDto.createFor(xooRule1) .setName("min").setType(RuleParamType.INTEGER.type())); - left = QProfileTesting.newXooP1(); - right = QProfileTesting.newXooP2(); + left = QualityProfileTesting.newQualityProfileDto().setLanguage("xoo"); + right = QualityProfileTesting.newQualityProfileDto().setLanguage("xoo"); db.qualityProfileDao().insert(dbSession, left, right); dbSession.commit(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileCopierTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileCopierTest.java index 8289f7ec088..14026337365 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileCopierTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileCopierTest.java @@ -29,7 +29,6 @@ import org.sonar.api.impl.utils.JUnitTempFolder; import org.sonar.api.utils.System2; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.db.qualityprofile.QualityProfileTesting; @@ -44,7 +43,7 @@ import static org.mockito.Mockito.verifyZeroInteractions; public class QProfileCopierTest { private static final String BACKUP = ""; - private System2 system2 = new AlwaysIncreasingSystem2(); + private final System2 system2 = new AlwaysIncreasingSystem2(); @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -53,9 +52,9 @@ public class QProfileCopierTest { @Rule public JUnitTempFolder temp = new JUnitTempFolder(); - private DummyProfileFactory profileFactory = new DummyProfileFactory(); - private QProfileBackuper backuper = mock(QProfileBackuper.class); - private QProfileCopier underTest = new QProfileCopier(db.getDbClient(), profileFactory, backuper); + private final DummyProfileFactory profileFactory = new DummyProfileFactory(); + private final QProfileBackuper backuper = mock(QProfileBackuper.class); + private final QProfileCopier underTest = new QProfileCopier(db.getDbClient(), profileFactory, backuper); @Test public void create_target_profile_and_copy_rules() { @@ -99,7 +98,6 @@ public class QProfileCopierTest { @Test public void copy_to_existing_profile() { - OrganizationDto organization = db.organizations().getDefaultOrganization(); QProfileDto profile1 = db.qualityProfiles().insert(); QProfileDto profile2 = db.qualityProfiles().insert(p -> p.setLanguage(profile1.getLanguage())); @@ -125,7 +123,8 @@ public class QProfileCopierTest { throw new UnsupportedOperationException(); } - @Override public QProfileDto createCustom(DbSession dbSession, QProfileName key, @Nullable String parentKey) { + @Override + public QProfileDto createCustom(DbSession dbSession, QProfileName key, @Nullable String parentKey) { createdProfile = QualityProfileTesting.newQualityProfileDto() .setLanguage(key.getLanguage()) .setParentKee(parentKey) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java index cfd30e45881..b2955027080 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java @@ -20,6 +20,7 @@ package org.sonar.server.qualityprofile; import java.io.IOException; +import java.io.InputStream; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; @@ -43,39 +44,38 @@ import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.db.rule.RuleDefinitionDto; import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.exceptions.NotFoundException; -import org.sonar.server.organization.DefaultOrganizationProvider; -import org.sonar.server.organization.TestDefaultOrganizationProvider; import org.sonar.server.rule.DefaultRuleFinder; import org.sonar.server.tester.UserSessionRule; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.commons.io.IOUtils.toInputStream; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfileDto; public class QProfileExportersTest { @org.junit.Rule public UserSessionRule userSessionRule = UserSessionRule.standalone(); - private System2 system2 = new AlwaysIncreasingSystem2(); + private final System2 system2 = new AlwaysIncreasingSystem2(); @org.junit.Rule public ExpectedException expectedException = ExpectedException.none(); @org.junit.Rule public DbTester db = DbTester.create(system2); - private RuleFinder ruleFinder = new DefaultRuleFinder(db.getDbClient()); - private ProfileExporter[] exporters = new ProfileExporter[] { + private final RuleFinder ruleFinder = new DefaultRuleFinder(db.getDbClient()); + private final ProfileExporter[] exporters = new ProfileExporter[] { new StandardExporter(), new XooExporter()}; - private ProfileImporter[] importers = new ProfileImporter[] { + private final ProfileImporter[] importers = new ProfileImporter[] { new XooProfileImporter(), new XooProfileImporterWithMessages(), new XooProfileImporterWithError()}; private RuleDefinitionDto rule; - private QProfileRules qProfileRules = mock(QProfileRules.class); - private QProfileExporters underTest = new QProfileExporters(db.getDbClient(), ruleFinder, qProfileRules, exporters, importers); + private final QProfileRules qProfileRules = mock(QProfileRules.class); + private final QProfileExporters underTest = new QProfileExporters(db.getDbClient(), ruleFinder, qProfileRules, exporters, importers); @Before public void setUp() { @@ -101,7 +101,6 @@ public class QProfileExportersTest { public void import_xml() { QProfileDto profile = createProfile(); - underTest.importXml(profile, "XooProfileImporter", toInputStream("", UTF_8), db.getSession()); ArgumentCaptor profileCapture = ArgumentCaptor.forClass(QProfileDto.class); @@ -129,22 +128,23 @@ public class QProfileExportersTest { @Test public void fail_to_import_xml_when_error_in_importer() { - try { - underTest.importXml(QProfileTesting.newXooP1(), "XooProfileImporterWithError", toInputStream("", UTF_8), db.getSession()); - fail(); - } catch (BadRequestException e) { - assertThat(e).hasMessage("error!"); - } + QProfileDto qProfileDto = newQualityProfileDto(); + InputStream inputStream = toInputStream("", UTF_8); + DbSession dbSession = db.getSession(); + assertThatThrownBy(() -> underTest.importXml( + qProfileDto, "XooProfileImporterWithError", inputStream, dbSession)) + .isInstanceOf(BadRequestException.class) + .hasMessage("error!"); } @Test public void fail_to_import_xml_on_unknown_importer() { - try { - underTest.importXml(QProfileTesting.newXooP1(), "Unknown", toInputStream("", UTF_8), db.getSession()); - fail(); - } catch (BadRequestException e) { - assertThat(e).hasMessage("No such importer : Unknown"); - } + QProfileDto qProfileDto = newQualityProfileDto(); + InputStream inputStream = toInputStream("", UTF_8); + DbSession dbSession = db.getSession(); + assertThatThrownBy(() -> underTest.importXml(qProfileDto, "Unknown", inputStream, dbSession)) + .isInstanceOf(BadRequestException.class) + .hasMessage("No such importer : Unknown"); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileTesting.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileTesting.java deleted file mode 100644 index 3c2da445191..00000000000 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileTesting.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 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.qualityprofile; - -import org.sonar.db.qualityprofile.QProfileDto; - -/** - * Utility class for tests involving quality profiles. - * @deprecated replaced by {@link org.sonar.db.qualityprofile.QualityProfileDbTester} - */ -@Deprecated -public class QProfileTesting { - - public static final QProfileName XOO_P1_NAME = new QProfileName("xoo", "P1"); - public static final String XOO_P1_KEY = "XOO_P1"; - public static final QProfileName XOO_P2_NAME = new QProfileName("xoo", "P2"); - public static final String XOO_P2_KEY = "XOO_P2"; - public static final QProfileName XOO_P3_NAME = new QProfileName("xoo", "P3"); - public static final String XOO_P3_KEY = "XOO_P3"; - - /** - * @deprecated provide organization as dto - */ - @Deprecated - public static QProfileDto newQProfileDto(QProfileName name, String key) { - return new QProfileDto() - .setKee(key) - .setRulesProfileUuid("rp-" + key) - .setName(name.getName()) - .setLanguage(name.getLanguage()); - } - - /** - * @deprecated provide organization as dto - */ - @Deprecated - public static QProfileDto newXooP1() { - return newQProfileDto(XOO_P1_NAME, XOO_P1_KEY); - } - - /** - * @deprecated provide organization as dto - */ - @Deprecated - public static QProfileDto newXooP2() { - return newQProfileDto(XOO_P2_NAME, XOO_P2_KEY); - } - - /** - * @deprecated provide organization as dto - */ - @Deprecated - public static QProfileDto newXooP3() { - return newQProfileDto(XOO_P3_NAME, XOO_P3_KEY); - } -} diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java index e07057725f0..561ff19fef9 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java @@ -67,12 +67,12 @@ public class ActivateRuleActionTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - private ArgumentCaptor> ruleActivationCaptor = ArgumentCaptor.forClass(Collection.class); - private DbClient dbClient = db.getDbClient(); - private QProfileRules qProfileRules = mock(QProfileRules.class); + private final ArgumentCaptor> ruleActivationCaptor = ArgumentCaptor.forClass(Collection.class); + private final DbClient dbClient = db.getDbClient(); + private final QProfileRules qProfileRules = mock(QProfileRules.class); private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession); - private WsActionTester ws = new WsActionTester(new ActivateRuleAction(dbClient, qProfileRules, userSession, wsSupport)); + private final WsActionTester ws = new WsActionTester(new ActivateRuleAction(dbClient, qProfileRules, userSession, wsSupport)); @Before public void before() { @@ -100,7 +100,7 @@ public class ActivateRuleActionTest { } @Test - public void fail_if_not_organization_quality_profile_administrator() { + public void fail_if_not_global_quality_profile_administrator() { userSession.logIn(db.users().insertUser()); QProfileDto qualityProfile = db.qualityProfiles().insert(); TestRequest request = ws.newRequest() diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java index b32b4818d17..196fb809ed6 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddGroupActionTest.java @@ -58,9 +58,9 @@ public class AddGroupActionTest { public DbTester db = DbTester.create(); private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession); - private UuidFactory uuidFactory = UuidFactoryFast.getInstance(); + private final UuidFactory uuidFactory = UuidFactoryFast.getInstance(); - private WsActionTester ws = new WsActionTester(new AddGroupAction(db.getDbClient(), uuidFactory, wsSupport, LANGUAGES)); + private final WsActionTester ws = new WsActionTester(new AddGroupAction(db.getDbClient(), uuidFactory, wsSupport, LANGUAGES)); @Test public void test_definition() { @@ -154,7 +154,7 @@ public class AddGroupActionTest { } @Test - public void uses_default_organization_when_no_organization() { + public void uses_global_permission() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); GroupDto group = db.users().insertGroup(); userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java index 8b7aa5a1505..43ac22c7528 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java @@ -29,7 +29,6 @@ import org.sonar.api.web.UserRole; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.project.ProjectDto; import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.db.user.UserDto; @@ -59,11 +58,11 @@ public class AddProjectActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private DbClient dbClient = db.getDbClient(); - private Languages languages = LanguageTesting.newLanguages(LANGUAGE_1, LANGUAGE_2); - private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession); - private AddProjectAction underTest = new AddProjectAction(dbClient, userSession, languages, TestComponentFinder.from(db), wsSupport); - private WsActionTester tester = new WsActionTester(underTest); + private final DbClient dbClient = db.getDbClient(); + private final Languages languages = LanguageTesting.newLanguages(LANGUAGE_1, LANGUAGE_2); + private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession); + private final AddProjectAction underTest = new AddProjectAction(dbClient, userSession, languages, TestComponentFinder.from(db), wsSupport); + private final WsActionTester tester = new WsActionTester(underTest); @Test public void definition() { @@ -84,7 +83,7 @@ public class AddProjectActionTest { @Test public void add_project_on_profile() { logInAsProfileAdmin(); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo")); TestResponse response = call(project, profile); @@ -107,10 +106,10 @@ public class AddProjectActionTest { } @Test - public void change_association_in_default_organization() { + public void change_association() { logInAsProfileAdmin(); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); // two profiles on same language QProfileDto profile1 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1)); QProfileDto profile2 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1)); @@ -125,7 +124,7 @@ public class AddProjectActionTest { @Test public void changing_association_does_not_change_other_language_associations() { logInAsProfileAdmin(); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile1Language1 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1)); QProfileDto profile2Language2 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_2)); QProfileDto profile3Language1 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1)); @@ -139,7 +138,7 @@ public class AddProjectActionTest { @Test public void project_administrator_can_change_profile() { - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo")); userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project); @@ -149,9 +148,9 @@ public class AddProjectActionTest { } @Test - public void throw_ForbiddenException_if_not_project_nor_organization_administrator() { + public void throw_ForbiddenException_if_not_project_nor_global_administrator() { userSession.logIn(db.users().insertUser()); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo")); expectedException.expect(ForbiddenException.class); @@ -163,7 +162,7 @@ public class AddProjectActionTest { @Test public void throw_UnauthorizedException_if_not_logged_in() { userSession.anonymous(); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile = db.qualityProfiles().insert(); expectedException.expect(UnauthorizedException.class); @@ -189,7 +188,7 @@ public class AddProjectActionTest { @Test public void throw_NotFoundException_if_profile_does_not_exist() { logInAsProfileAdmin(); - ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization()); + ComponentDto project = db.components().insertPrivateProject(); expectedException.expect(NotFoundException.class); expectedException.expectMessage("Quality Profile for language 'xoo' and name 'unknown' does not exist"); @@ -238,13 +237,4 @@ public class AddProjectActionTest { .setParam("qualityProfile", qualityProfile.getName()); return request.execute(); } - - private TestResponse call(OrganizationDto organization, ProjectDto project, QProfileDto qualityProfile) { - TestRequest request = tester.newRequest() - .setParam("organization", organization.getKey()) - .setParam("project", project.getKey()) - .setParam("language", qualityProfile.getLanguage()) - .setParam("qualityProfile", qualityProfile.getName()); - return request.execute(); - } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java index bf30a046b49..1c68f56f350 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/AddUserActionTest.java @@ -40,7 +40,6 @@ import org.sonar.server.ws.WsActionTester; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.db.permission.GlobalPermission.ADMINISTER_QUALITY_PROFILES; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LOGIN; import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE; @@ -135,21 +134,6 @@ public class AddUserActionTest { assertThat(db.getDbClient().qProfileEditUsersDao().exists(db.getSession(), profile, user)).isTrue(); } - @Test - public void uses_default_organization_when_no_organization() { - QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); - UserDto user = db.users().insertUser(); - userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES); - - ws.newRequest() - .setParam(PARAM_QUALITY_PROFILE, profile.getName()) - .setParam(PARAM_LANGUAGE, XOO) - .setParam(PARAM_LOGIN, user.getLogin()) - .execute(); - - assertThat(db.getDbClient().qProfileEditUsersDao().exists(db.getSession(), profile, user)).isTrue(); - } - @Test public void fail_when_user_does_not_exist() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java index 340394bc72d..15ee9482343 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java @@ -47,10 +47,10 @@ public class BackupActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private QProfileBackuper backuper = new QProfileBackuperImpl(db.getDbClient(), null, null, null, new QProfileParser()); + private final QProfileBackuper backuper = new QProfileBackuperImpl(db.getDbClient(), null, null, null, new QProfileParser()); private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession); - private Languages languages = LanguageTesting.newLanguages(A_LANGUAGE); - private WsActionTester tester = new WsActionTester(new BackupAction(db.getDbClient(), backuper, wsSupport, languages)); + private final Languages languages = LanguageTesting.newLanguages(A_LANGUAGE); + private final WsActionTester tester = new WsActionTester(new BackupAction(db.getDbClient(), backuper, wsSupport, languages)); @Test public void returns_backup_of_profile_with_specified_key() { @@ -66,7 +66,7 @@ public class BackupActionTest { } @Test - public void returns_backup_of_profile_with_specified_name_on_default_organization() { + public void returns_backup_of_profile_with_specified_name() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(A_LANGUAGE)); TestResponse response = tester.newRequest() diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java index cd800af8792..5e56dabbb01 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionTest.java @@ -52,7 +52,7 @@ public class ChangelogActionTest { private static final String DATE = "2011-04-25T01:15:42+0100"; - private TestSystem2 system2 = new TestSystem2().setNow(DateUtils.parseDateTime(DATE).getTime()); + private final TestSystem2 system2 = new TestSystem2().setNow(DateUtils.parseDateTime(DATE).getTime()); @Rule public DbTester db = DbTester.create(system2); @@ -61,8 +61,8 @@ public class ChangelogActionTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - private QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession); - private WsActionTester ws = new WsActionTester(new ChangelogAction(wsSupport, new Languages(), db.getDbClient())); + private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession); + private final WsActionTester ws = new WsActionTester(new ChangelogAction(wsSupport, new Languages(), db.getDbClient())); @Test public void return_change_with_all_fields() { @@ -168,38 +168,6 @@ public class ChangelogActionTest { "}"); } - @Test - public void find_changelog_by_organization_and_language_and_name() { - QProfileDto qualityProfile = db.qualityProfiles().insert(); - RuleDefinitionDto rule = db.rules().insert(); - UserDto user = db.users().insertUser(); - insertChange(qualityProfile, ActiveRuleChange.Type.ACTIVATED, user, - ImmutableMap.of( - "ruleUuid", rule.getUuid(), - "severity", "MINOR")); - - String response = ws.newRequest() - .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage()) - .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName()) - .execute() - .getInput(); - - assertJson(response).isSimilarTo("{\n" + - " \"events\": [\n" + - " {\n" + - " \"date\": \"" + DATE + "\",\n" + - " \"authorLogin\": \"" + user.getLogin() + "\",\n" + - " \"action\": \"ACTIVATED\",\n" + - " \"ruleKey\": \"" + rule.getKey() + "\",\n" + - " \"ruleName\": \"" + rule.getName() + "\",\n" + - " \"params\": {\n" + - " \"severity\": \"MINOR\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}"); - } - @Test public void changelog_empty() { QProfileDto qualityProfile = db.qualityProfiles().insert(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java index 8b0ef3fb3df..c44de89bf60 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java @@ -139,7 +139,7 @@ public class CopyActionTest { } @Test - public void copy_rules_on_existing_profile_in_default_organization() { + public void copy_rules_on_existing_profile() { logInAsQProfileAdministrator(); QProfileDto sourceProfile = db.qualityProfiles().insert(p -> p.setLanguage(A_LANGUAGE)); QProfileDto targetProfile = db.qualityProfiles().insert(p -> p.setLanguage(A_LANGUAGE)); @@ -213,7 +213,7 @@ public class CopyActionTest { } @Test - public void throw_ForbiddenException_if_not_profile_administrator_of_organization() { + public void throw_ForbiddenException_if_not_profile_global_administrator() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(A_LANGUAGE)); userSession.logIn().addPermission(GlobalPermission.SCAN); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java index 78a907c4338..0c160b1992e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java @@ -63,12 +63,12 @@ public class DeactivateRuleActionTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - private ArgumentCaptor> ruleUuidsCaptor = ArgumentCaptor.forClass(Collection.class); - private DbClient dbClient = db.getDbClient(); - private QProfileRules qProfileRules = mock(QProfileRules.class); + private final ArgumentCaptor> ruleUuidsCaptor = ArgumentCaptor.forClass(Collection.class); + private final DbClient dbClient = db.getDbClient(); + private final QProfileRules qProfileRules = mock(QProfileRules.class); private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession); - private DeactivateRuleAction underTest = new DeactivateRuleAction(dbClient, qProfileRules, userSession, wsSupport); - private WsActionTester ws = new WsActionTester(underTest); + private final DeactivateRuleAction underTest = new DeactivateRuleAction(dbClient, qProfileRules, userSession, wsSupport); + private final WsActionTester ws = new WsActionTester(underTest); @Before public void before() { @@ -84,7 +84,7 @@ public class DeactivateRuleActionTest { } @Test - public void deactivate_rule_in_default_organization() { + public void deactivate_rule() { userSession.logIn(db.users().insertUser()).addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES); QProfileDto qualityProfile = db.qualityProfiles().insert(); RuleDefinitionDto rule = db.rules().insert(RuleTesting.randomRuleKey()); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java index 85f27004939..a0201b8f930 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java @@ -63,18 +63,18 @@ public class DeleteActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private DbClient dbClient = db.getDbClient(); - private DbSession dbSession = db.getSession(); - private ActiveRuleIndexer activeRuleIndexer = mock(ActiveRuleIndexer.class); + private final DbClient dbClient = db.getDbClient(); + private final DbSession dbSession = db.getSession(); + private final ActiveRuleIndexer activeRuleIndexer = mock(ActiveRuleIndexer.class); - private DeleteAction underTest = new DeleteAction( + private final DeleteAction underTest = new DeleteAction( new Languages(LanguageTesting.newLanguage(A_LANGUAGE)), new QProfileFactoryImpl(dbClient, UuidFactoryFast.getInstance(), System2.INSTANCE, activeRuleIndexer), dbClient, userSession, new QProfileWsSupport(dbClient, userSession)); - private WsActionTester ws = new WsActionTester(underTest); + private final WsActionTester ws = new WsActionTester(underTest); @Test - public void delete_profile_by_language_and_name_in_default_organization() { + public void delete_profile_by_language_and_name() { ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile1 = createProfile(); QProfileDto profile2 = createProfile(); @@ -94,25 +94,6 @@ public class DeleteActionTest { verifyProfileExists(profile2); } - @Test - public void delete_profile_by_language_and_name_in_specified_organization() { - ProjectDto project = db.components().insertPrivateProjectDto(); - QProfileDto profile1 = createProfile(); - QProfileDto profile2 = createProfile(); - db.qualityProfiles().associateWithProject(project, profile1); - logInAsQProfileAdministrator(); - - TestResponse response = ws.newRequest() - .setMethod("POST") - .setParam(PARAM_LANGUAGE, profile1.getLanguage()) - .setParam(PARAM_QUALITY_PROFILE, profile1.getName()) - .execute(); - assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); - - verifyProfileDoesNotExist(profile1); - verifyProfileExists(profile2); - } - @Test public void as_qprofile_editor() { QProfileDto profile = createProfile(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java index 41c7ef9c31e..2c3a9392947 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java @@ -35,7 +35,6 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.qualityprofile.QProfileDto; -import org.sonar.db.user.UserDto; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.language.LanguageTesting; import org.sonar.server.qualityprofile.QProfileBackuper; @@ -46,7 +45,6 @@ import org.sonar.server.ws.WsActionTester; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.db.organization.OrganizationDto.Subscription.PAID; public class ExportActionTest { @@ -60,11 +58,11 @@ public class ExportActionTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - private DbClient dbClient = db.getDbClient(); - private QProfileBackuper backuper = new TestBackuper(); + private final DbClient dbClient = db.getDbClient(); + private final QProfileBackuper backuper = new TestBackuper(); @Test - public void export_profile_in_default_organization() { + public void export_profile() { QProfileDto profile = createProfile(false); WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap")); @@ -106,7 +104,7 @@ public class ExportActionTest { } @Test - public void throw_NotFoundException_if_profile_with_specified_name_does_not_exist_in_default_organization() { + public void throw_NotFoundException_if_profile_with_specified_name_does_not_exist() { expectedException.expect(NotFoundException.class); newWsActionTester().newRequest() diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java index 11369776308..dac5c4c166e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java @@ -27,7 +27,6 @@ import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.project.ProjectDto; import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.db.user.UserDto; @@ -51,7 +50,7 @@ public class ProjectsActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private WsActionTester ws = new WsActionTester(new ProjectsAction(db.getDbClient(), userSession)); + private final WsActionTester ws = new WsActionTester(new ProjectsAction(db.getDbClient(), userSession)); @Test public void list_authorized_projects_only() { @@ -80,11 +79,10 @@ public class ProjectsActionTest { @Test public void paginate() { - OrganizationDto organization = db.organizations().getDefaultOrganization(); - ProjectDto project1 = db.components().insertPublicProjectDto(organization, p -> p.setName("Project One")); - ProjectDto project2 = db.components().insertPublicProjectDto(organization, p -> p.setName("Project Two")); - ProjectDto project3 = db.components().insertPublicProjectDto(organization, p -> p.setName("Project Three")); - ProjectDto project4 = db.components().insertPublicProjectDto(organization, p -> p.setName("Project Four")); + ProjectDto project1 = db.components().insertPublicProjectDto(p -> p.setName("Project One")); + ProjectDto project2 = db.components().insertPublicProjectDto(p -> p.setName("Project Two")); + ProjectDto project3 = db.components().insertPublicProjectDto(p -> p.setName("Project Three")); + ProjectDto project4 = db.components().insertPublicProjectDto(p -> p.setName("Project Four")); QProfileDto qualityProfile = db.qualityProfiles().insert(); associateProjectsWithProfile(qualityProfile, project1, project2, project3, project4); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java index ea77a357e52..9b7b4e14e3e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java @@ -35,15 +35,14 @@ import org.sonar.db.DbTester; import org.sonar.db.qualityprofile.ActiveRuleDto; import org.sonar.db.qualityprofile.ActiveRuleKey; import org.sonar.db.qualityprofile.QProfileDto; +import org.sonar.db.qualityprofile.QualityProfileTesting; import org.sonar.db.rule.RuleDefinitionDto; import org.sonar.db.rule.RuleTesting; import org.sonar.server.es.EsTester; import org.sonar.server.es.SearchOptions; import org.sonar.server.exceptions.BadRequestException; -import org.sonar.server.qualityprofile.QProfileName; import org.sonar.server.qualityprofile.QProfileRules; import org.sonar.server.qualityprofile.QProfileRulesImpl; -import org.sonar.server.qualityprofile.QProfileTesting; import org.sonar.server.qualityprofile.RuleActivator; import org.sonar.server.qualityprofile.index.ActiveRuleIndexer; import org.sonar.server.rule.index.RuleIndex; @@ -76,14 +75,14 @@ public class QProfilesWsMediumTest { @Rule public DbTester dbTester = DbTester.create(); - private DbClient dbClient = dbTester.getDbClient(); - private DbSession dbSession = dbTester.getSession(); - private RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE); - private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), dbClient); - private ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(dbClient, es.client()); - private TypeValidations typeValidations = new TypeValidations(emptyList()); - private RuleActivator ruleActivator = new RuleActivator(System2.INSTANCE, dbClient, typeValidations, userSessionRule); - private QProfileRules qProfileRules = new QProfileRulesImpl(dbClient, ruleActivator, ruleIndex, activeRuleIndexer); + private final DbClient dbClient = dbTester.getDbClient(); + private final DbSession dbSession = dbTester.getSession(); + private final RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE); + private final RuleIndexer ruleIndexer = new RuleIndexer(es.client(), dbClient); + private final ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(dbClient, es.client()); + private final TypeValidations typeValidations = new TypeValidations(emptyList()); + private final RuleActivator ruleActivator = new RuleActivator(System2.INSTANCE, dbClient, typeValidations, userSessionRule); + private final QProfileRules qProfileRules = new QProfileRulesImpl(dbClient, ruleActivator, ruleIndex, activeRuleIndexer); private final QProfileWsSupport qProfileWsSupport = new QProfileWsSupport(dbClient, userSessionRule); private final RuleQueryFactory ruleQueryFactory = new RuleQueryFactory(dbClient); @@ -397,8 +396,8 @@ public class QProfilesWsMediumTest { @Test public void reset() { - QProfileDto profile = QProfileTesting.newXooP1(); - QProfileDto childProfile = QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY); + QProfileDto profile = QualityProfileTesting.newQualityProfileDto().setLanguage("java"); + QProfileDto childProfile = QualityProfileTesting.newQualityProfileDto().setParentKee(profile.getKee()).setLanguage("java"); dbClient.qualityProfileDao().insert(dbSession, profile, childProfile); RuleDefinitionDto rule = createRule(profile.getLanguage(), "rule"); @@ -432,7 +431,7 @@ public class QProfilesWsMediumTest { } private QProfileDto createProfile(String lang) { - QProfileDto profile = QProfileTesting.newQProfileDto(new QProfileName(lang, "P" + lang), "p" + lang); + QProfileDto profile = QualityProfileTesting.newQualityProfileDto().setName("P" + lang).setLanguage(lang); dbClient.qualityProfileDao().insert(dbSession, profile); return profile; } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java index 85fc13c707c..69133c65ea2 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveGroupActionTest.java @@ -57,7 +57,7 @@ public class RemoveGroupActionTest { private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession); - private WsActionTester ws = new WsActionTester(new RemoveGroupAction(db.getDbClient(), wsSupport, LANGUAGES)); + private final WsActionTester ws = new WsActionTester(new RemoveGroupAction(db.getDbClient(), wsSupport, LANGUAGES)); @Test public void test_definition() { @@ -135,22 +135,6 @@ public class RemoveGroupActionTest { assertThat(db.getDbClient().qProfileEditGroupsDao().exists(db.getSession(), profile, group)).isFalse(); } - @Test - public void uses_default_organization_when_no_organization() { - QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); - GroupDto group = db.users().insertGroup(); - db.qualityProfiles().addGroupPermission(profile, group); - userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES); - - ws.newRequest() - .setParam(PARAM_QUALITY_PROFILE, profile.getName()) - .setParam(PARAM_LANGUAGE, XOO) - .setParam(PARAM_GROUP, group.getName()) - .execute(); - - assertThat(db.getDbClient().qProfileEditGroupsDao().exists(db.getSession(), profile, group)).isFalse(); - } - @Test public void fail_when_group_does_not_exist() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java index 046269a7b5f..c97cae4adcd 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java @@ -59,13 +59,13 @@ public class RemoveProjectActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private DbClient dbClient = db.getDbClient(); - private Languages languages = LanguageTesting.newLanguages(LANGUAGE_1, LANGUAGE_2); + private final DbClient dbClient = db.getDbClient(); + private final Languages languages = LanguageTesting.newLanguages(LANGUAGE_1, LANGUAGE_2); private final QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession); - private RemoveProjectAction underTest = new RemoveProjectAction(dbClient, userSession, languages, + private final RemoveProjectAction underTest = new RemoveProjectAction(dbClient, userSession, languages, new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport); - private WsActionTester ws = new WsActionTester(underTest); + private final WsActionTester ws = new WsActionTester(underTest); @Test public void definition() { @@ -88,7 +88,7 @@ public class RemoveProjectActionTest { public void remove_profile_from_project() { logInAsProfileAdmin(); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profileLang1 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1)); QProfileDto profileLang2 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_2)); db.qualityProfiles().associateWithProject(project, profileLang1); @@ -116,7 +116,7 @@ public class RemoveProjectActionTest { @Test public void project_administrator_can_remove_profile() { - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo")); db.qualityProfiles().associateWithProject(project, profile); userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project); @@ -143,7 +143,7 @@ public class RemoveProjectActionTest { @Test public void fail_if_not_enough_permissions() { userSession.logIn(db.users().insertUser()); - ProjectDto project = db.components().insertPrivateProjectDto(db.getDefaultOrganization()); + ProjectDto project = db.components().insertPrivateProjectDto(); QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo")); expectedException.expect(ForbiddenException.class); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java index c51d0182749..c95c35c742c 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RemoveUserActionTest.java @@ -135,7 +135,7 @@ public class RemoveUserActionTest { } @Test - public void uses_default_organization_when_no_organization() { + public void uses_global_permission() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); UserDto user = db.users().insertUser(); db.qualityProfiles().addUserPermission(profile, user); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RestoreActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RestoreActionTest.java index f74bcc637f2..c341fe39b89 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RestoreActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/RestoreActionTest.java @@ -31,13 +31,10 @@ import org.sonar.api.resources.Languages; import org.sonar.api.server.ws.WebService; import org.sonar.db.DbSession; import org.sonar.db.DbTester; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.language.LanguageTesting; -import org.sonar.server.organization.DefaultOrganizationProvider; -import org.sonar.server.organization.TestDefaultOrganizationProvider; import org.sonar.server.qualityprofile.BulkChangeResult; import org.sonar.server.qualityprofile.QProfileBackuper; import org.sonar.server.qualityprofile.QProfileRestoreSummary; @@ -61,10 +58,9 @@ public class RestoreActionTest { @Rule public UserSessionRule userSession = UserSessionRule.standalone(); - private TestBackuper backuper = new TestBackuper(); - private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); - private Languages languages = LanguageTesting.newLanguages(A_LANGUAGE); - private WsActionTester tester = new WsActionTester(new RestoreAction(db.getDbClient(), backuper, languages, userSession)); + private final TestBackuper backuper = new TestBackuper(); + private final Languages languages = LanguageTesting.newLanguages(A_LANGUAGE); + private final WsActionTester tester = new WsActionTester(new RestoreAction(db.getDbClient(), backuper, languages, userSession)); @Test public void test_definition() { @@ -83,9 +79,9 @@ public class RestoreActionTest { } @Test - public void profile_is_restored_on_default_organization_with_the_name_provided_in_backup() { + public void profile_is_restored_with_the_name_provided_in_backup() { logInAsQProfileAdministrator(); - TestResponse response = restore("", null); + TestResponse response = restore(""); assertThat(backuper.restoredBackup).isEqualTo(""); assertThat(backuper.restoredSummary.getProfile().getName()).isEqualTo("the-name-in-backup"); @@ -102,28 +98,6 @@ public class RestoreActionTest { "}"); } - @Test - public void profile_is_restored_on_specified_organization_with_the_name_provided_in_backup() { - OrganizationDto org = db.organizations().insert(); - logInAsQProfileAdministrator(); - TestResponse response = restore("", org.getKey()); - - assertThat(backuper.restoredBackup).isEqualTo(""); - assertThat(backuper.restoredSummary.getProfile().getName()).isEqualTo("the-name-in-backup"); - JsonAssert.assertJson(response.getInput()).isSimilarTo("{" + - " \"profile\": {" + - " \"name\": \"the-name-in-backup\"," + - " \"language\": \"xoo\"," + - " \"languageName\": \"Xoo\"," + - " \"isDefault\": false," + - " \"isInherited\": false" + - " }," + - " \"ruleSuccesses\": 0," + - " \"ruleFailures\": 0" + - "}"); - - } - @Test public void throw_IAE_if_backup_is_missing() { logInAsQProfileAdministrator(); @@ -143,7 +117,7 @@ public class RestoreActionTest { expectedException.expect(ForbiddenException.class); expectedException.expectMessage("Insufficient privileges"); - restore("", null); + restore(""); } @Test @@ -153,7 +127,7 @@ public class RestoreActionTest { expectedException.expect(UnauthorizedException.class); expectedException.expectMessage("Authentication is required"); - restore("", null); + restore(""); } private void logInAsQProfileAdministrator() { @@ -162,13 +136,10 @@ public class RestoreActionTest { .addPermission(ADMINISTER_QUALITY_PROFILES); } - private TestResponse restore(String backupContent, @Nullable String organizationKey) { + private TestResponse restore(String backupContent) { TestRequest request = tester.newRequest() .setMethod("POST") .setParam("backup", backupContent); - if (organizationKey != null) { - request.setParam("organization", organizationKey); - } return request.execute(); } @@ -206,7 +177,8 @@ public class RestoreActionTest { throw new UnsupportedOperationException(); } - @Override public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) { + @Override + public QProfileRestoreSummary copy(DbSession dbSession, QProfileDto from, QProfileDto to) { throw new UnsupportedOperationException(); } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java index ade503e11a1..4e3144bca82 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java @@ -32,7 +32,6 @@ import org.sonar.api.utils.System2; import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbTester; -import org.sonar.db.organization.OrganizationDto; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.project.ProjectDto; import org.sonar.db.qualityprofile.QProfileDto; @@ -65,9 +64,9 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters. public class SearchActionTest { - private static Language XOO1 = newLanguage("xoo1"); - private static Language XOO2 = newLanguage("xoo2"); - private static Languages LANGUAGES = new Languages(XOO1, XOO2); + private static final Language XOO1 = newLanguage("xoo1"); + private static final Language XOO2 = newLanguage("xoo2"); + private static final Languages LANGUAGES = new Languages(XOO1, XOO2); @Rule public DbTester db = DbTester.create(System2.INSTANCE); @@ -75,8 +74,8 @@ public class SearchActionTest { public UserSessionRule userSession = UserSessionRule.standalone(); @Rule public ExpectedException expectedException = ExpectedException.none(); - private QualityProfileDbTester qualityProfileDb = db.qualityProfiles(); - private DbClient dbClient = db.getDbClient(); + private final QualityProfileDbTester qualityProfileDb = db.qualityProfiles(); + private final DbClient dbClient = db.getDbClient(); private SearchAction underTest = new SearchAction(userSession, LANGUAGES, dbClient, new ComponentFinder(dbClient, null)); private WsActionTester ws = new WsActionTester(underTest); @@ -98,17 +97,6 @@ public class SearchActionTest { assertThat(result.getProfilesList()).isEmpty(); } - @Test - public void default_organization() { - QProfileDto profile1OnDefaultOrg = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey())); - QProfileDto profile2OnDefaultOrg = db.qualityProfiles().insert(p -> p.setLanguage(XOO2.getKey())); - - SearchWsResponse result = call(ws.newRequest()); - - assertThat(result.getProfilesList()).extracting(QualityProfile::getKey) - .containsExactlyInAnyOrder(profile1OnDefaultOrg.getKee(), profile2OnDefaultOrg.getKee()); - } - @Test public void filter_on_default_profile() { QProfileDto defaultProfile1 = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey())); @@ -264,7 +252,6 @@ public class SearchActionTest { @Test public void actions_when_user_is_global_qprofile_administer() { - OrganizationDto organization = db.organizations().getDefaultOrganization(); QProfileDto customProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey())); QProfileDto builtInProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()).setIsBuiltIn(true)); QProfileDto defaultProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey())); @@ -286,7 +273,6 @@ public class SearchActionTest { @Test public void actions_when_user_can_edit_profile() { - OrganizationDto organization = db.organizations().getDefaultOrganization(); QProfileDto profile1 = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey())); QProfileDto profile2 = db.qualityProfiles().insert(p -> p.setLanguage(XOO2.getKey())); QProfileDto profile3 = db.qualityProfiles().insert(p -> p.setLanguage(XOO2.getKey())); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java index 319cc795a37..5214c568fc4 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchGroupsActionTest.java @@ -64,7 +64,7 @@ public class SearchGroupsActionTest { private final QProfileWsSupport wsSupport = new QProfileWsSupport(db.getDbClient(), userSession); - private WsActionTester ws = new WsActionTester(new SearchGroupsAction(db.getDbClient(), wsSupport, LANGUAGES)); + private final WsActionTester ws = new WsActionTester(new SearchGroupsAction(db.getDbClient(), wsSupport, LANGUAGES)); @Test public void test_definition() { @@ -234,7 +234,7 @@ public class SearchGroupsActionTest { } @Test - public void uses_default_organization_when_no_organization() { + public void uses_global_permission() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); GroupDto group = db.users().insertGroup(); db.qualityProfiles().addGroupPermission(profile, group); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java index 232fe883c5d..da64f6b6cad 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/ws/SearchUsersActionTest.java @@ -257,7 +257,7 @@ public class SearchUsersActionTest { } @Test - public void uses_default_organization_when_no_organization() { + public void uses_global_permission() { QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO)); UserDto user1 = db.users().insertUser(); db.qualityProfiles().addUserPermission(profile, user1); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java index 5b7981176c6..c5861108c65 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java @@ -42,6 +42,7 @@ import org.sonar.db.qualityprofile.ActiveRuleDto; import org.sonar.db.qualityprofile.ActiveRuleKey; import org.sonar.db.qualityprofile.ActiveRuleParamDto; import org.sonar.db.qualityprofile.QProfileDto; +import org.sonar.db.qualityprofile.QualityProfileTesting; import org.sonar.db.rule.RuleDefinitionDto; import org.sonar.db.rule.RuleDto; import org.sonar.db.rule.RuleParamDto; @@ -49,7 +50,6 @@ import org.sonar.db.rule.RuleTesting; import org.sonar.db.user.UserDto; import org.sonar.server.es.EsTester; import org.sonar.server.es.SearchOptions; -import org.sonar.server.qualityprofile.QProfileTesting; import org.sonar.server.rule.index.RuleIndex; import org.sonar.server.rule.index.RuleIndexer; import org.sonar.server.rule.index.RuleQuery; @@ -65,7 +65,7 @@ public class RuleUpdaterTest { static final RuleKey RULE_KEY = RuleKey.of("squid", "S001"); - private System2 system2 = new TestSystem2().setNow(Instant.now().toEpochMilli()); + private final System2 system2 = new TestSystem2().setNow(Instant.now().toEpochMilli()); @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -79,11 +79,11 @@ public class RuleUpdaterTest { @Rule public EsTester es = EsTester.create(); - private RuleIndex ruleIndex = new RuleIndex(es.client(), system2); - private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), db.getDbClient()); - private DbSession dbSession = db.getSession(); + private final RuleIndex ruleIndex = new RuleIndex(es.client(), system2); + private final RuleIndexer ruleIndexer = new RuleIndexer(es.client(), db.getDbClient()); + private final DbSession dbSession = db.getSession(); - private RuleUpdater underTest = new RuleUpdater(db.getDbClient(), ruleIndexer, system2); + private final RuleUpdater underTest = new RuleUpdater(db.getDbClient(), ruleIndexer, system2); @Test public void do_not_update_rule_with_removed_status() { @@ -96,7 +96,7 @@ public class RuleUpdaterTest { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Rule with REMOVED status cannot be updated: squid:S001"); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); } @Test @@ -115,7 +115,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY); assertThat(update.isEmpty()).isTrue(); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); RuleDto rule = db.getDbClient().ruleDao().selectOrFailByKey(dbSession, RULE_KEY); @@ -147,7 +147,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY) .setMarkdownNote("my *note*"); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); RuleDto rule = db.getDbClient().ruleDao().selectOrFailByKey(dbSession, RULE_KEY); @@ -173,7 +173,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY) .setMarkdownNote(null); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); RuleDto rule = db.getDbClient().ruleDao().selectOrFailByKey(dbSession, RULE_KEY); @@ -194,7 +194,7 @@ public class RuleUpdaterTest { // java8 is a system tag -> ignore RuleUpdate update = createForPluginRule(RULE_KEY) .setTags(Sets.newHashSet("bug", "java8")); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); RuleDto rule = db.getDbClient().ruleDao().selectOrFailByKey(dbSession, RULE_KEY); assertThat(rule.getTags()).containsOnly("bug"); @@ -217,7 +217,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY) .setTags(null); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); RuleDto rule = db.getDbClient().ruleDao().selectOrFailByKey(dbSession, RULE_KEY); @@ -240,7 +240,7 @@ public class RuleUpdaterTest { DefaultDebtRemediationFunction fn = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "1min"); RuleUpdate update = createForPluginRule(RULE_KEY) .setDebtRemediationFunction(fn); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); // verify debt is overridden @@ -264,7 +264,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY) .setDebtRemediationFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "2d", null)); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); // verify debt is overridden @@ -288,7 +288,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY) .setDebtRemediationFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "10min")); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); // verify debt is overridden @@ -317,7 +317,7 @@ public class RuleUpdaterTest { RuleUpdate update = createForPluginRule(RULE_KEY) .setDebtRemediationFunction(null); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); // verify debt is coming from default values @@ -357,7 +357,7 @@ public class RuleUpdaterTest { .setSeverity("MAJOR") .setStatus(RuleStatus.READY) .setParameters(ImmutableMap.of("regex", "b.*")); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); @@ -405,7 +405,7 @@ public class RuleUpdaterTest { .setMarkdownDescription("New description") .setSeverity("MAJOR") .setStatus(RuleStatus.READY); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); dbSession.clearCache(); @@ -435,7 +435,7 @@ public class RuleUpdaterTest { db.rules().insertRuleParam(customRule, param -> param.setName("message").setType("STRING").setDescription("message")); // Create a quality profile - QProfileDto profileDto = QProfileTesting.newXooP1(); + QProfileDto profileDto = QualityProfileTesting.newQualityProfileDto(); db.getDbClient().qualityProfileDao().insert(dbSession, profileDto); dbSession.commit(); @@ -455,7 +455,7 @@ public class RuleUpdaterTest { // Update custom rule parameter 'regex', add 'message' and remove 'format' RuleUpdate update = createForCustomRule(customRule.getKey()) .setParameters(ImmutableMap.of("regex", "b.*", "message", "a message")); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); // Verify custom rule parameters has been updated List params = db.getDbClient().ruleDao().selectRuleParamsByRuleKey(dbSession, customRule.getKey()); @@ -503,7 +503,7 @@ public class RuleUpdaterTest { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("The name is missing"); - underTest.update(dbSession, update, userSessionRule); + underTest.update(dbSession, update, userSessionRule); } @Test @@ -523,7 +523,7 @@ public class RuleUpdaterTest { underTest.update(dbSession, createForCustomRule(customRule.getKey()).setName("New name").setMarkdownDescription(""), - userSessionRule); + userSessionRule); } @Test -- 2.39.5