From 90c44d08cd1203c578b4c0f66126e3c22187c4ed Mon Sep 17 00:00:00 2001 From: Eric Hartmann Date: Mon, 29 May 2017 19:49:10 +0200 Subject: [PATCH] SONAR-9304 Create migration for QPROFILE --- .../src/main/java/org/sonar/db/Dto.java | 49 ------- .../db/qualityprofile/QualityProfileDao.java | 34 ++--- .../qualityprofile/QualityProfileMapper.java | 34 +++-- .../db/qualityprofile/RulesProfileDto.java | 8 +- .../qualityprofile/QualityProfileMapper.xml | 100 +++++++------ .../db/qualityprofile/ActiveRuleDaoTest.java | 42 +++--- .../qualityprofile/QualityProfileDaoTest.java | 135 ++++++++++-------- .../QualityProfileDbTester.java | 4 +- .../qualityprofile/QualityProfileTesting.java | 5 +- .../QualityProfileDaoTest/projects.xml | 71 --------- .../db/migration/version/v65/DbVersion65.java | 3 +- .../version/v65/PopulateQProfiles.java | 58 ++++++++ .../version/v65/DbVersion65Test.java | 2 +- .../version/v65/PopulateQProfilesTest.java | 116 +++++++++++++++ .../v65/PopulateQProfilesTest/initial.sql | 26 ++++ .../LoadReportAnalysisMetadataHolderStep.java | 2 +- .../server/organization/ws/DeleteAction.java | 2 +- .../BuiltInQProfileInsertImpl.java | 2 +- .../qualityprofile/QProfileBackuperImpl.java | 4 +- .../qualityprofile/QProfileComparison.java | 2 +- .../qualityprofile/QProfileExporters.java | 2 +- .../qualityprofile/QProfileResetImpl.java | 2 +- .../server/qualityprofile/RuleActivator.java | 6 +- .../qualityprofile/RuleActivatorContext.java | 2 +- .../RuleActivatorContextFactory.java | 2 +- .../qualityprofile/ws/AddProjectAction.java | 8 +- .../qualityprofile/ws/ChangeParentAction.java | 4 +- .../qualityprofile/ws/ChangelogAction.java | 2 +- .../qualityprofile/ws/CompareAction.java | 2 +- .../server/qualityprofile/ws/CopyAction.java | 2 +- .../qualityprofile/ws/CreateAction.java | 2 +- .../qualityprofile/ws/DeleteAction.java | 2 +- .../qualityprofile/ws/InheritanceAction.java | 4 +- .../qualityprofile/ws/OldRestoreAction.java | 2 +- .../ws/RemoveProjectAction.java | 2 +- .../qualityprofile/ws/RestoreAction.java | 2 +- .../qualityprofile/ws/SearchAction.java | 6 +- .../server/qualityprofile/ws/SearchData.java | 2 +- .../qualityprofile/ws/SearchDataLoader.java | 10 +- .../server/rule/ws/ActiveRuleCompleter.java | 2 +- .../org/sonar/server/rule/ws/AppAction.java | 2 +- ...teQualityProfilesLastUsedDateStepTest.java | 16 +-- .../organization/ws/DeleteActionTest.java | 2 +- .../QProfileBackuperMediumTest.java | 6 +- .../QProfileComparisonMediumTest.java | 32 ++--- .../QProfileCopierMediumTest.java | 2 +- .../qualityprofile/QProfileExportersTest.java | 6 +- .../QProfileFactoryMediumTest.java | 6 +- .../qualityprofile/QProfileFactoryTest.java | 4 +- .../QProfileResetMediumTest.java | 6 +- .../RegisterQualityProfilesMediumTest.java | 10 +- .../RegisterQualityProfilesTest.java | 4 +- .../RuleActivatorMediumTest.java | 2 +- .../ws/ActivateRuleActionTest.java | 10 +- .../ws/ActivateRulesActionTest.java | 2 +- .../ws/AddProjectActionTest.java | 12 +- .../qualityprofile/ws/BackupActionTest.java | 4 +- .../ws/ChangeParentActionTest.java | 62 ++++---- .../ws/ChangelogActionDatabaseTest.java | 8 +- .../ws/CompareActionMediumTest.java | 12 +- .../qualityprofile/ws/CompareActionTest.java | 4 +- .../qualityprofile/ws/CopyActionTest.java | 36 ++--- .../qualityprofile/ws/CreateActionTest.java | 10 +- .../ws/DeactivateRuleActionTest.java | 10 +- .../ws/DeactivateRulesActionTest.java | 2 +- .../qualityprofile/ws/DeleteActionTest.java | 20 +-- .../qualityprofile/ws/ExportActionTest.java | 8 +- .../ws/InheritanceActionTest.java | 14 +- .../qualityprofile/ws/ProjectsActionTest.java | 28 ++-- .../ws/QProfileWsSupportTest.java | 6 +- .../ws/QProfilesWsMediumTest.java | 78 +++++----- .../ws/RemoveProjectActionTest.java | 12 +- .../qualityprofile/ws/RenameActionTest.java | 12 +- .../qualityprofile/ws/SearchActionTest.java | 10 +- .../ws/SetDefaultActionTest.java | 30 ++-- .../sonar/server/rule/RuleUpdaterTest.java | 2 +- .../rule/ws/ActiveRuleCompleterTest.java | 2 +- .../server/rule/ws/RuleQueryFactoryTest.java | 8 +- .../rule/ws/SearchActionMediumTest.java | 4 +- 79 files changed, 688 insertions(+), 581 deletions(-) delete mode 100644 server/sonar-db-dao/src/main/java/org/sonar/db/Dto.java delete mode 100644 server/sonar-db-dao/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfiles.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest.java create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest/initial.sql diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/Dto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/Dto.java deleted file mode 100644 index 8a6d2ff11a8..00000000000 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/Dto.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 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.db; - -import java.io.Serializable; -import java.util.Date; - -public abstract class Dto { - - private Date createdAt; - private Date updatedAt; - - public abstract K getKey(); - - public Dto setCreatedAt(Date datetime) { - this.createdAt = datetime; - return this; - } - - public Dto setUpdatedAt(Date datetime) { - this.updatedAt = datetime; - return this; - } - - public final Date getCreatedAt() { - return this.createdAt; - } - - public final Date getUpdatedAt() { - return this.updatedAt; - } -} diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index 6d0f8a45065..7dd416bd086 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -79,10 +79,7 @@ public class QualityProfileDao implements Dao { private void doInsert(QualityProfileMapper mapper, RulesProfileDto profile) { Preconditions.checkArgument(profile.getId() == null, "Quality profile is already persisted (got id %d)", profile.getId()); - Date now = new Date(system.now()); - profile.setCreatedAt(now); - profile.setUpdatedAt(now); - mapper.insert(profile); + mapper.insert(profile, new Date(system.now())); } public void update(DbSession session, RulesProfileDto profile, RulesProfileDto... otherProfiles) { @@ -95,12 +92,11 @@ public class QualityProfileDao implements Dao { private void doUpdate(QualityProfileMapper mapper, RulesProfileDto profile) { Preconditions.checkArgument(profile.getId() != null, "Quality profile is not persisted"); - profile.setUpdatedAt(new Date(system.now())); - mapper.update(profile); + mapper.update(profile, new Date(system.now())); } public List selectDefaultProfiles(DbSession session, OrganizationDto organization, Collection languageKeys) { - return executeLargeInputs(languageKeys, chunk -> mapper(session).selectDefaultProfiles(organization.getUuid(), chunk)); + return mapper(session).selectDefaultProfiles(organization.getUuid(), languageKeys); } @CheckForNull @@ -109,12 +105,12 @@ public class QualityProfileDao implements Dao { } @CheckForNull - public RulesProfileDto selectByProjectAndLanguage(DbSession session, String projectKey, String language) { - return mapper(session).selectByProjectAndLanguage(projectKey, language); + public RulesProfileDto selectAssociatedToProjectAndLanguage(DbSession session, ComponentDto project, String language) { + return mapper(session).selectAssociatedToProjectUuidAndLanguage(project.getOrganizationUuid(), project.projectUuid(), language); } - public List selectByProjectAndLanguages(DbSession session, OrganizationDto organization, ComponentDto project, Collection languageKeys) { - return executeLargeInputs(languageKeys, input -> mapper(session).selectByProjectAndLanguages(organization.getUuid(), project.getKey(), input)); + public List selectAssociatedToProjectUuidAndLanguages(DbSession session, ComponentDto project, Collection languages) { + return mapper(session).selectAssociatedToProjectUuidAndLanguages(project.getOrganizationUuid(), project.uuid(), languages); } public List selectByLanguage(DbSession dbSession, OrganizationDto organization, String language) { @@ -132,7 +128,7 @@ public class QualityProfileDao implements Dao { List descendants = Lists.newArrayList(); for (RulesProfileDto child : selectChildren(session, key)) { descendants.add(child); - descendants.addAll(selectDescendants(session, child.getKey())); + descendants.addAll(selectDescendants(session, child.getKee())); } return descendants; } @@ -143,23 +139,23 @@ public class QualityProfileDao implements Dao { } public List selectByNameAndLanguages(OrganizationDto organization, String name, Collection languageKeys, DbSession session) { - return executeLargeInputs(languageKeys, input -> mapper(session).selectByNameAndLanguages(organization.getUuid(), name, input)); + return mapper(session).selectByNameAndLanguages(organization.getUuid(), name, languageKeys); } public Map countProjectsByProfileKey(DbSession dbSession, OrganizationDto organization) { return KeyLongValue.toMap(mapper(dbSession).countProjectsByProfileKey(organization.getUuid())); } - public void insertProjectProfileAssociation(String projectUuid, String profileKey, DbSession session) { - mapper(session).insertProjectProfileAssociation(projectUuid, profileKey); + public void insertProjectProfileAssociation(DbSession dbSession, ComponentDto project, RulesProfileDto profile) { + mapper(dbSession).insertProjectProfileAssociation(project.uuid(), profile.getKee()); } - public void deleteProjectProfileAssociation(String projectUuid, String profileKey, DbSession session) { - mapper(session).deleteProjectProfileAssociation(projectUuid, profileKey); + public void deleteProjectProfileAssociation(DbSession dbSession, ComponentDto project, RulesProfileDto profile) { + mapper(dbSession).deleteProjectProfileAssociation(project.uuid(), profile.getKee()); } - public void updateProjectProfileAssociation(String projectUuid, String newProfileKey, String oldProfileKey, DbSession session) { - mapper(session).updateProjectProfileAssociation(projectUuid, newProfileKey, oldProfileKey); + public void updateProjectProfileAssociation(DbSession dbSession, ComponentDto project, String newProfileKey, String oldProfileKey) { + mapper(dbSession).updateProjectProfileAssociation(project.uuid(), newProfileKey, oldProfileKey); } public void deleteProjectAssociationsByProfileKeys(DbSession dbSession, Collection profileKeys) { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java index 10bf85d14de..9a514215385 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileMapper.java @@ -28,9 +28,9 @@ import org.sonar.db.KeyLongValue; public interface QualityProfileMapper { - void insert(RulesProfileDto dto); + void insert(@Param("dto") RulesProfileDto dto, @Param("now") Date now); - void update(RulesProfileDto dto); + void update(@Param("dto") RulesProfileDto dto, @Param("now") Date now); void deleteByKeys(@Param("profileKeys") Collection profileKeys); @@ -39,12 +39,17 @@ public interface QualityProfileMapper { @CheckForNull RulesProfileDto selectDefaultProfile(@Param("organizationUuid") String organizationUuid, @Param("language") String language); - List selectDefaultProfiles(@Param("organizationUuid") String organizationUuid, @Param("languages") List languages); + List selectDefaultProfiles( + @Param("organizationUuid") String organizationUuid, + @Param("languages") Collection languages); @CheckForNull RulesProfileDto selectByNameAndLanguage(@Param("organizationUuid") String organizationUuid, @Param("name") String name, @Param("language") String language); - List selectByNameAndLanguages(@Param("organizationUuid") String organizationUuid, @Param("name") String name, @Param("languages") List languages); + List selectByNameAndLanguages( + @Param("organizationUuid") String organizationUuid, + @Param("name") String name, + @Param("languages") Collection languages); @CheckForNull RulesProfileDto selectByKey(String key); @@ -61,14 +66,25 @@ public interface QualityProfileMapper { List countProjectsByProfileKey(@Param("organizationUuid") String organizationUuid); - RulesProfileDto selectByProjectAndLanguage(@Param("projectKey") String projectKey, @Param("language") String language); + @CheckForNull + RulesProfileDto selectAssociatedToProjectUuidAndLanguage( + @Param("organizationUuid") String organizationUuid, + @Param("projectUuid") String projectUuid, + @Param("language") String language); - List selectByProjectAndLanguages(@Param("organizationUuid") String organizationUuid, @Param("projectKey") String projectKey, - @Param("languages") List input); + List selectAssociatedToProjectUuidAndLanguages( + @Param("organizationUuid") String organizationUuid, + @Param("projectUuid") String projectUuid, + @Param("languages") Collection languages); - void insertProjectProfileAssociation(@Param("projectUuid") String projectUuid, @Param("profileKey") String profileKey); + void insertProjectProfileAssociation( + @Param("projectUuid") String projectUuid, + @Param("profileUuid") String profileUuid); - void updateProjectProfileAssociation(@Param("projectUuid") String projectUuid, @Param("profileKey") String profileKey, @Param("oldProfileKey") String oldProfileKey); + void updateProjectProfileAssociation( + @Param("projectUuid") String projectUuid, + @Param("profileUuid") String profileUuid, + @Param("oldProfileUuid") String oldProfileUuid); void deleteProjectProfileAssociation(@Param("projectUuid") String projectUuid, @Param("profileKey") String profileKey); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/RulesProfileDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/RulesProfileDto.java index cc8ad2fd1b5..0afffd0f7aa 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/RulesProfileDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/RulesProfileDto.java @@ -23,13 +23,12 @@ import java.util.Date; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.core.util.UtcDateUtils; -import org.sonar.db.Dto; import org.sonar.db.organization.OrganizationDto; /** * Represents the table "rules_profiles" */ -public class RulesProfileDto extends Dto { +public class RulesProfileDto { private Integer id; /** @@ -56,11 +55,6 @@ public class RulesProfileDto extends Dto { return this; } - @Override - public String getKey() { - return kee; - } - public RulesProfileDto setKey(String s) { return setKee(s); } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml index 9eb7b487da8..3eeb5f676ff 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileMapper.xml @@ -10,42 +10,40 @@ p.name as name, p.language as language, p.parent_kee as parentKee, - p.created_at as createdAt, - p.updated_at as updatedAt, p.rules_updated_at as rulesUpdatedAt, p.last_used as lastUsed, p.user_updated_at as userUpdatedAt, p.is_built_in as isBuiltIn - + INSERT INTO rules_profiles (organization_uuid, kee, parent_kee, name, language, created_at, updated_at, rules_updated_at, last_used, user_updated_at, is_built_in) VALUES ( - #{organizationUuid, jdbcType=VARCHAR}, - #{kee, jdbcType=VARCHAR}, - #{parentKee, jdbcType=VARCHAR}, - #{name, jdbcType=VARCHAR}, - #{language, jdbcType=VARCHAR}, - #{createdAt, jdbcType=TIMESTAMP}, - #{updatedAt, jdbcType=TIMESTAMP}, - #{rulesUpdatedAt, jdbcType=VARCHAR}, - #{lastUsed, jdbcType=BIGINT}, - #{userUpdatedAt, jdbcType=BIGINT}, - #{isBuiltIn, jdbcType=BOOLEAN} + #{dto.organizationUuid, jdbcType=VARCHAR}, + #{dto.kee, jdbcType=VARCHAR}, + #{dto.parentKee, jdbcType=VARCHAR}, + #{dto.name, jdbcType=VARCHAR}, + #{dto.language, jdbcType=VARCHAR}, + #{now, jdbcType=TIMESTAMP}, + #{now, jdbcType=TIMESTAMP}, + #{dto.rulesUpdatedAt, jdbcType=VARCHAR}, + #{dto.lastUsed, jdbcType=BIGINT}, + #{dto.userUpdatedAt, jdbcType=BIGINT}, + #{dto.isBuiltIn, jdbcType=BOOLEAN} ) - + UPDATE rules_profiles SET - name=#{name, jdbcType=VARCHAR}, - language=#{language, jdbcType=VARCHAR}, - parent_kee=#{parentKee, jdbcType=VARCHAR}, - updated_at=#{updatedAt, jdbcType=TIMESTAMP}, - rules_updated_at=#{rulesUpdatedAt, jdbcType=VARCHAR}, - last_used=#{lastUsed, jdbcType=BIGINT}, - user_updated_at=#{userUpdatedAt, jdbcType=BIGINT}, - is_built_in=#{isBuiltIn, jdbcType=BOOLEAN} - WHERE id=#{id} + name=#{dto.name, jdbcType=VARCHAR}, + language=#{dto.language, jdbcType=VARCHAR}, + parent_kee=#{dto.parentKee, jdbcType=VARCHAR}, + updated_at=#{now, jdbcType=TIMESTAMP}, + rules_updated_at=#{dto.rulesUpdatedAt, jdbcType=VARCHAR}, + last_used=#{dto.lastUsed, jdbcType=BIGINT}, + user_updated_at=#{dto.userUpdatedAt, jdbcType=BIGINT}, + is_built_in=#{dto.isBuiltIn, jdbcType=BOOLEAN} + WHERE id=#{dto.id} @@ -180,35 +178,45 @@ group by pp.profile_key - + select - FROM rules_profiles p - JOIN project_qprofiles pp ON pp.profile_key=p.kee - JOIN projects project ON pp.project_uuid=project.uuid AND project.kee=#{projectKey} - WHERE p.language=#{language} + from rules_profiles p + inner join project_qprofiles pp ON pp.profile_key = p.kee + where + p.language = #{language, jdbcType=VARCHAR} + and pp.project_uuid = #{projectUuid, jdbcType=VARCHAR} + and p.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} - + select - FROM rules_profiles p - JOIN project_qprofiles pp ON pp.profile_key=p.kee - JOIN projects project ON pp.project_uuid=project.uuid AND project.kee=#{projectKey, jdbcType=VARCHAR} - JOIN organizations org ON project.organization_uuid = org.uuid AND p.organization_uuid = org.uuid - WHERE p.language in #{language, jdbcType=VARCHAR} - AND org.uuid = #{organizationUuid, jdbcType=VARCHAR} - - - - INSERT INTO project_qprofiles (project_uuid, profile_key) - VALUES (#{projectUuid, jdbcType=VARCHAR}, #{profileKey, jdbcType=VARCHAR}) + from rules_profiles p + inner join project_qprofiles pq ON pq.profile_key = p.kee + where + p.language in #{language, jdbcType=VARCHAR} + and pq.project_uuid = #{projectUuid, jdbcType=VARCHAR} + and p.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} + + + + insert into project_qprofiles ( + project_uuid, + profile_key + ) values ( + #{projectUuid, jdbcType=VARCHAR}, + #{profileUuid, jdbcType=VARCHAR} + ) - UPDATE project_qprofiles - SET profile_key=#{profileKey, jdbcType=VARCHAR} - WHERE project_uuid=#{projectUuid, jdbcType=VARCHAR} AND profile_key=#{oldProfileKey, jdbcType=VARCHAR} + update project_qprofiles + set + profile_key = #{profileUuid, jdbcType=VARCHAR} + where + project_uuid = #{projectUuid, jdbcType=VARCHAR} + and profile_key = #{oldProfileUuid, jdbcType=VARCHAR} diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java index bb08d8d48ee..35530c4abd4 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java @@ -131,7 +131,7 @@ public class ActiveRuleDaoTest { underTest.insert(dbSession, activeRule); assertThat(underTest.selectByKey(dbSession, activeRule.getKey())).isPresent(); - assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile2.getKey(), rule2.getKey()))).isAbsent(); + assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile2.getKee(), rule2.getKey()))).isAbsent(); } @Test @@ -143,7 +143,7 @@ public class ActiveRuleDaoTest { thrown.expect(RowNotFoundException.class); thrown.expectMessage("Active rule with key 'qp2:xoo:x2' does not exist"); - underTest.selectOrFailByKey(dbSession, ActiveRuleKey.of(profile2.getKey(), rule2.getKey())); + underTest.selectOrFailByKey(dbSession, ActiveRuleKey.of(profile2.getKee(), rule2.getKey())); } @Test @@ -182,8 +182,8 @@ public class ActiveRuleDaoTest { underTest.insert(dbTester.getSession(), activeRule2); dbSession.commit(); - assertThat(underTest.selectByProfileKey(dbSession, profile1.getKey())).hasSize(2); - assertThat(underTest.selectByProfileKey(dbSession, profile2.getKey())).isEmpty(); + assertThat(underTest.selectByProfileKey(dbSession, profile1.getKee())).hasSize(2); + assertThat(underTest.selectByProfileKey(dbSession, profile2.getKee())).isEmpty(); } @Test @@ -192,7 +192,7 @@ public class ActiveRuleDaoTest { underTest.insert(dbTester.getSession(), activeRule); dbSession.commit(); - assertThat(underTest.selectByProfileKey(dbSession, profile1.getKey())).isEmpty(); + assertThat(underTest.selectByProfileKey(dbSession, profile1.getKee())).isEmpty(); } @Test @@ -207,7 +207,7 @@ public class ActiveRuleDaoTest { ActiveRuleDto result = underTest.selectOrFailByKey(dbSession, activeRule.getKey()); assertThat(result.getId()).isEqualTo(activeRule.getId()); - assertThat(result.getKey()).isEqualTo(ActiveRuleKey.of(profile1.getKey(), rule1.getKey())); + assertThat(result.getKey()).isEqualTo(ActiveRuleKey.of(profile1.getKee(), rule1.getKey())); assertThat(result.getRuleId()).isEqualTo(rule1.getId()); assertThat(result.getProfileId()).isEqualTo(profile1.getId()); assertThat(result.getSeverityString()).isEqualTo(BLOCKER); @@ -259,9 +259,9 @@ public class ActiveRuleDaoTest { underTest.update(dbTester.getSession(), activeRuleUpdated); dbSession.commit(); - ActiveRuleDto result = underTest.selectOrFailByKey(dbSession, ActiveRuleKey.of(profile1.getKey(), rule1.getKey())); + ActiveRuleDto result = underTest.selectOrFailByKey(dbSession, ActiveRuleKey.of(profile1.getKee(), rule1.getKey())); assertThat(result.getId()).isEqualTo(activeRule.getId()); - assertThat(result.getKey()).isEqualTo(ActiveRuleKey.of(profile1.getKey(), rule1.getKey())); + assertThat(result.getKey()).isEqualTo(ActiveRuleKey.of(profile1.getKee(), rule1.getKey())); assertThat(result.getRuleId()).isEqualTo(rule1.getId()); assertThat(result.getProfileId()).isEqualTo(profile1.getId()); assertThat(result.getSeverityString()).isEqualTo(MAJOR); @@ -305,12 +305,12 @@ public class ActiveRuleDaoTest { underTest.delete(dbSession, activeRule.getKey()); - assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile1.getKey(), rule1.getKey()))).isAbsent(); + assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile1.getKee(), rule1.getKey()))).isAbsent(); } @Test public void delete_does_not_fail_when_active_rule_does_not_exist() { - underTest.delete(dbSession, ActiveRuleKey.of(profile1.getKey(), rule1.getKey())); + underTest.delete(dbSession, ActiveRuleKey.of(profile1.getKee(), rule1.getKey())); } @Test @@ -319,10 +319,10 @@ public class ActiveRuleDaoTest { underTest.insert(dbSession, newRow(profile1, rule2)); underTest.insert(dbSession, newRow(profile2, rule1)); - underTest.deleteByProfileKeys(dbSession, asList(profile1.getKey())); + underTest.deleteByProfileKeys(dbSession, asList(profile1.getKee())); assertThat(dbTester.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); - assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile2.getKey(), rule1.getKey()))).isPresent(); + assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile2.getKee(), rule1.getKey()))).isPresent(); } @Test @@ -378,7 +378,7 @@ public class ActiveRuleDaoTest { assertThat(underTest.selectParamByKeyAndName(activeRule.getKey(), activeRuleParam1.getKey(), dbSession)).isNotNull(); assertThat(underTest.selectParamByKeyAndName(activeRule.getKey(), "unknown", dbSession)).isNull(); - assertThat(underTest.selectParamByKeyAndName(ActiveRuleKey.of(profile2.getKey(), rule1.getKey()), "unknown", dbSession)).isNull(); + assertThat(underTest.selectParamByKeyAndName(ActiveRuleKey.of(profile2.getKee(), rule1.getKey()), "unknown", dbSession)).isNull(); } @Test @@ -486,7 +486,7 @@ public class ActiveRuleDaoTest { ActiveRuleParamDto param2 = ActiveRuleParamDto.createFor(rule1Param1).setValue("bar"); underTest.insertParam(dbSession, activeRuleInProfile2, param2); - underTest.deleteParametersByProfileKeys(dbSession, asList(profile1.getKey(), "does_not_exist")); + underTest.deleteParametersByProfileKeys(dbSession, asList(profile1.getKee(), "does_not_exist")); List params = underTest.selectAllParams(dbSession); assertThat(params).hasSize(1); @@ -523,7 +523,7 @@ public class ActiveRuleDaoTest { @Test public void does_not_fail_to_delete_param_by_key_and_name_when_active_rule_does_not_exist() { - underTest.deleteParamByKeyAndName(dbSession, ActiveRuleKey.of(profile1.getKey(), rule1.getKey()), rule1Param1.getName()); + underTest.deleteParamByKeyAndName(dbSession, ActiveRuleKey.of(profile1.getKee(), rule1.getKey()), rule1Param1.getName()); } @Test @@ -584,8 +584,8 @@ public class ActiveRuleDaoTest { Map counts = underTest.countActiveRulesByProfileKey(dbSession, organization); assertThat(counts).containsOnly( - entry(profile1.getKey(), 2L), - entry(profile2.getKey(), 1L)); + entry(profile1.getKee(), 2L), + entry(profile2.getKee(), 1L)); } @Test @@ -609,7 +609,7 @@ public class ActiveRuleDaoTest { Map counts = underTest.countActiveRulesByProfileKey(dbSession, organization); - assertThat(counts).containsExactly(entry(profile1.getKey(), 1L)); + assertThat(counts).containsExactly(entry(profile1.getKee(), 1L)); } @Test @@ -622,7 +622,7 @@ public class ActiveRuleDaoTest { Map counts = underTest.countActiveRulesForRuleStatusByProfileKey(dbSession, organization, RuleStatus.BETA); - assertThat(counts).containsOnly(entry(profile2.getKey(), 2L)); + assertThat(counts).containsOnly(entry(profile2.getKee(), 2L)); } @Test @@ -647,7 +647,7 @@ public class ActiveRuleDaoTest { Map counts = underTest.countActiveRulesForInheritanceByProfileKey(dbSession, organization, ActiveRuleDto.OVERRIDES); - assertThat(counts).containsOnly(entry(profile2.getKey(), 1L)); + assertThat(counts).containsOnly(entry(profile2.getKee(), 1L)); } @Test @@ -671,6 +671,6 @@ public class ActiveRuleDaoTest { Map counts = underTest.countActiveRulesForInheritanceByProfileKey(dbSession, organization, ActiveRuleDto.OVERRIDES); - assertThat(counts).containsOnly(entry(profile1.getKey(), 1L)); + assertThat(counts).containsOnly(entry(profile1.getKee(), 1L)); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java index f67b323e5a2..c6332f53d86 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java @@ -111,11 +111,11 @@ public class QualityProfileDaoTest { RulesProfileDto p2 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization()); RulesProfileDto p3 = dbTester.qualityProfiles().insert(dbTester.getDefaultOrganization()); - underTest.deleteByKeys(dbSession, asList(p1.getKey(), p3.getKey(), "does_not_exist")); + underTest.deleteByKeys(dbSession, asList(p1.getKee(), p3.getKee(), "does_not_exist")); List> keysInDb = dbTester.select(dbSession, "select kee as \"key\" from rules_profiles"); assertThat(keysInDb).hasSize(1); - assertThat(keysInDb.get(0).get("key")).isEqualTo(p2.getKey()); + assertThat(keysInDb.get(0).get("key")).isEqualTo(p2.getKee()); } @Test @@ -149,12 +149,12 @@ public class QualityProfileDaoTest { dbTester.qualityProfiles().associateProjectWithQualityProfile(project2, profile1); dbTester.qualityProfiles().associateProjectWithQualityProfile(project3, profile2); - underTest.deleteProjectAssociationsByProfileKeys(dbSession, asList(profile1.getKey(), "does_not_exist")); + underTest.deleteProjectAssociationsByProfileKeys(dbSession, asList(profile1.getKee(), "does_not_exist")); List> rows = dbTester.select(dbSession, "select project_uuid as \"projectUuid\", profile_key as \"profileKey\" from project_qprofiles"); assertThat(rows).hasSize(1); assertThat(rows.get(0).get("projectUuid")).isEqualTo(project3.uuid()); - assertThat(rows.get(0).get("profileKey")).isEqualTo(profile2.getKey()); + assertThat(rows.get(0).get("profileKey")).isEqualTo(profile2.getKee()); } @Test @@ -198,7 +198,7 @@ public class QualityProfileDaoTest { RulesProfileDto java = underTest.selectDefaultProfile(dbTester.getSession(), organization, "java"); assertThat(java).isNotNull(); - assertThat(java.getKey()).isEqualTo("java_sonar_way"); + assertThat(java.getKee()).isEqualTo("java_sonar_way"); assertThat(underTest.selectDefaultProfile(dbTester.getSession(), dbTester.organizations().insert(), "java")).isNull(); assertThat(underTest.selectDefaultProfile(dbTester.getSession(), organization, "js")).isNull(); @@ -209,11 +209,11 @@ public class QualityProfileDaoTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); List java = underTest.selectDefaultProfiles(dbTester.getSession(), organization, singletonList("java")); - assertThat(java).extracting("key").containsOnly("java_sonar_way"); + assertThat(java).extracting(RulesProfileDto::getKee).containsOnly("java_sonar_way"); assertThat(underTest.selectDefaultProfiles(dbTester.getSession(), organization, singletonList("js"))).isEmpty(); - assertThat(underTest.selectDefaultProfiles(dbTester.getSession(), organization, of("java", "js"))).extracting("key").containsOnly("java_sonar_way"); - assertThat(underTest.selectDefaultProfiles(dbTester.getSession(), organization, of("js", "java"))).extracting("key").containsOnly("java_sonar_way"); + assertThat(underTest.selectDefaultProfiles(dbTester.getSession(), organization, of("java", "js"))).extracting(RulesProfileDto::getKee).containsOnly("java_sonar_way"); + assertThat(underTest.selectDefaultProfiles(dbTester.getSession(), organization, of("js", "java"))).extracting(RulesProfileDto::getKee).containsOnly("java_sonar_way"); } @Test @@ -258,7 +258,7 @@ public class QualityProfileDaoTest { assertThat(result.getId()).isEqualTo(profile.getId()); assertThat(result.getName()).isEqualTo(profile.getName()); - assertThat(result.getKey()).isEqualTo(profile.getKey()); + assertThat(result.getKee()).isEqualTo(profile.getKee()); assertThat(result.getLanguage()).isEqualTo(profile.getLanguage()); assertThat(result.getOrganizationUuid()).isEqualTo(profile.getOrganizationUuid()); } @@ -319,33 +319,62 @@ public class QualityProfileDaoTest { dbTester.qualityProfiles().associateProjectWithQualityProfile(projectInOtherOrg, profileInOtherOrg); assertThat(underTest.countProjectsByProfileKey(dbTester.getSession(), organization)).containsOnly( - MapEntry.entry(profileWithProjects.getKey(), 2L)); + MapEntry.entry(profileWithProjects.getKee(), 2L)); } @Test - public void select_by_project_key_and_language() { - dbTester.prepareDbUnit(getClass(), "projects.xml"); - - RulesProfileDto dto = underTest.selectByProjectAndLanguage(dbTester.getSession(), "org.codehaus.sonar:sonar", "java"); - assertThat(dto.getId()).isEqualTo(1); + public void test_selectAssociatedToProjectAndLanguage() { + OrganizationDto org = dbTester.organizations().insert(); + ComponentDto project1 = dbTester.components().insertPublicProject(org); + ComponentDto project2 = dbTester.components().insertPublicProject(org); + RulesProfileDto javaProfile = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("java")); + RulesProfileDto jsProfile = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("js")); + dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, javaProfile, jsProfile); + + assertThat(underTest.selectAssociatedToProjectAndLanguage(dbTester.getSession(), project1, "java").getKee()) + .isEqualTo(javaProfile.getKee()); + assertThat(underTest.selectAssociatedToProjectAndLanguage(dbTester.getSession(), project1, "js").getKee()) + .isEqualTo(jsProfile.getKee()); + assertThat(underTest.selectAssociatedToProjectAndLanguage(dbTester.getSession(), project1, "cobol")) + .isNull(); + assertThat(underTest.selectAssociatedToProjectAndLanguage(dbTester.getSession(), project2, "java")) + .isNull(); + } - assertThat(underTest.selectByProjectAndLanguage(dbTester.getSession(), "org.codehaus.sonar:sonar", "unkown")).isNull(); - assertThat(underTest.selectByProjectAndLanguage(dbTester.getSession(), "unknown", "java")).isNull(); + @Test + public void test_selectAssociatedToProjectUuidAndLanguages() { + OrganizationDto org = dbTester.organizations().insert(); + ComponentDto project1 = dbTester.components().insertPublicProject(org); + ComponentDto project2 = dbTester.components().insertPublicProject(org); + RulesProfileDto javaProfile = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("java")); + RulesProfileDto jsProfile = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("js")); + dbTester.qualityProfiles().associateProjectWithQualityProfile(project1, javaProfile, jsProfile); + + assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbTester.getSession(), project1, singletonList("java"))) + .extracting(RulesProfileDto::getKee).containsOnly(javaProfile.getKee()); + assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbTester.getSession(), project1, singletonList("unknown"))) + .isEmpty(); + assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbTester.getSession(), project1, of("java", "unknown"))) + .extracting(RulesProfileDto::getKee).containsExactly(javaProfile.getKee()); + assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbTester.getSession(), project1, of("java", "js"))) + .extracting(RulesProfileDto::getKee).containsExactlyInAnyOrder(javaProfile.getKee(), jsProfile.getKee()); + assertThat(underTest.selectAssociatedToProjectUuidAndLanguages(dbTester.getSession(), project2, singletonList("java"))) + .isEmpty(); } @Test - public void select_by_project_and_languages() { - dbTester.prepareDbUnit(getClass(), "projects.xml"); - - OrganizationDto organization = dbTester.organizations().insert(OrganizationTesting.newOrganizationDto().setUuid("org1")); - ComponentDto project = dbTester.getDbClient().componentDao().selectOrFailByKey(dbTester.getSession(), "org.codehaus.sonar:sonar"); - ComponentDto unknownProject = dbTester.components().insertPrivateProject(organization, p -> p.setKey("unknown")); - List dto = underTest.selectByProjectAndLanguages(dbTester.getSession(), organization, project, singletonList("java")); - assertThat(dto).extracting("id").containsOnly(1); - - assertThat(underTest.selectByProjectAndLanguages(dbTester.getSession(), organization, project, singletonList("unkown"))).isEmpty(); - assertThat(underTest.selectByProjectAndLanguages(dbTester.getSession(), organization, project, of("java", "unkown"))).extracting("id").containsOnly(1); - assertThat(underTest.selectByProjectAndLanguages(dbTester.getSession(), organization, unknownProject, singletonList("java"))).isEmpty(); + public void test_updateProjectProfileAssociation() { + OrganizationDto org = dbTester.organizations().insert(); + ComponentDto project = dbTester.components().insertPrivateProject(org); + RulesProfileDto javaProfile1 = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("java")); + RulesProfileDto jsProfile = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("js")); + RulesProfileDto javaProfile2 = dbTester.qualityProfiles().insert(org, p -> p.setLanguage("java")); + qualityProfileDb.associateProjectWithQualityProfile(project, javaProfile1, jsProfile); + + underTest.updateProjectProfileAssociation(dbSession, project, javaProfile2.getKee(), javaProfile1.getKee()); + + assertThat(underTest.selectAssociatedToProjectAndLanguage(dbSession, project, "java").getKee()).isEqualTo(javaProfile2.getKee()); + assertThat(underTest.selectAssociatedToProjectAndLanguage(dbSession, project, "js").getKee()).isEqualTo(jsProfile.getKee()); } @Test @@ -357,7 +386,7 @@ public class QualityProfileDaoTest { assertThat(underTest.selectByKey(dbSession, "qp-key-42")).isNull(); assertThat(underTest.selectByKeys(dbSession, newArrayList("qp-key-1", "qp-key-3", "qp-key-42"))) .hasSize(2) - .extracting(RulesProfileDto::getKey).containsOnlyOnce("qp-key-1", "qp-key-3"); + .extracting(RulesProfileDto::getKee).containsOnlyOnce("qp-key-1", "qp-key-3"); assertThat(underTest.selectByKeys(dbSession, emptyList())).isEmpty(); } @@ -378,13 +407,13 @@ public class QualityProfileDaoTest { qualityProfileDb.insertQualityProfiles(profile2); qualityProfileDb.associateProjectWithQualityProfile(project3, profile2); - assertThat(underTest.selectSelectedProjects(organization, profile1.getKey(), null, dbSession)) + assertThat(underTest.selectSelectedProjects(organization, profile1.getKee(), null, dbSession)) .extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey") .containsOnly( - tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKey()), - tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), profile1.getKey())); + tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKee()), + tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), profile1.getKee())); - assertThat(underTest.selectSelectedProjects(organization, profile1.getKey(), "ect1", dbSession)).hasSize(1); + assertThat(underTest.selectSelectedProjects(organization, profile1.getKee(), "ect1", dbSession)).hasSize(1); assertThat(underTest.selectSelectedProjects(organization, "unknown", null, dbSession)).isEmpty(); } @@ -404,13 +433,13 @@ public class QualityProfileDaoTest { qualityProfileDb.insertQualityProfiles(profile2); qualityProfileDb.associateProjectWithQualityProfile(project2, profile2); - assertThat(underTest.selectDeselectedProjects(organization, profile1.getKey(), null, dbSession)) + assertThat(underTest.selectDeselectedProjects(organization, profile1.getKee(), null, dbSession)) .extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey") .containsExactly( tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), null), tuple(project3.getId(), project3.uuid(), project3.key(), project3.name(), null)); - assertThat(underTest.selectDeselectedProjects(organization, profile1.getKey(), "ect2", dbSession)).hasSize(1); + assertThat(underTest.selectDeselectedProjects(organization, profile1.getKee(), "ect2", dbSession)).hasSize(1); assertThat(underTest.selectDeselectedProjects(organization, "unknown", null, dbSession)).hasSize(3); } @@ -430,31 +459,17 @@ public class QualityProfileDaoTest { qualityProfileDb.insertQualityProfiles(profile2); qualityProfileDb.associateProjectWithQualityProfile(project2, profile2); - assertThat(underTest.selectProjectAssociations(organization, profile1.getKey(), null, dbSession)) + assertThat(underTest.selectProjectAssociations(organization, profile1.getKee(), null, dbSession)) .extracting("projectId", "projectUuid", "projectKey", "projectName", "profileKey") .containsOnly( - tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKey()), + tuple(project1.getId(), project1.uuid(), project1.key(), project1.name(), profile1.getKee()), tuple(project2.getId(), project2.uuid(), project2.key(), project2.name(), null), tuple(project3.getId(), project3.uuid(), project3.key(), project3.name(), null)); - assertThat(underTest.selectProjectAssociations(organization, profile1.getKey(), "ect2", dbSession)).hasSize(1); + assertThat(underTest.selectProjectAssociations(organization, profile1.getKee(), "ect2", dbSession)).hasSize(1); assertThat(underTest.selectProjectAssociations(organization, "unknown", null, dbSession)).hasSize(3); } - @Test - public void update_project_profile_association() { - ComponentDto project = dbTester.components().insertPrivateProject(); - RulesProfileDto profile1Language1 = insertQualityProfileDto("profile1", "Profile 1", "xoo"); - RulesProfileDto profile2Language2 = insertQualityProfileDto("profile2", "Profile 2", "xoo2"); - RulesProfileDto profile3Language1 = insertQualityProfileDto("profile3", "Profile 3", "xoo"); - qualityProfileDb.associateProjectWithQualityProfile(project, profile1Language1, profile2Language2); - - underTest.updateProjectProfileAssociation(project.uuid(), profile3Language1.getKey(), profile1Language1.getKey(), dbSession); - - assertThat(underTest.selectByProjectAndLanguage(dbSession, project.getKey(), "xoo").getKey()).isEqualTo(profile3Language1.getKey()); - assertThat(underTest.selectByProjectAndLanguage(dbSession, project.getKey(), "xoo2").getKey()).isEqualTo(profile2Language2.getKey()); - } - @Test public void selectOutdatedProfiles_returns_the_custom_profiles_with_specified_name() { OrganizationDto org1 = dbTester.organizations().insert(); @@ -480,15 +495,15 @@ public class QualityProfileDaoTest { public void renameAndCommit_updates_name_of_specified_profiles() { OrganizationDto org1 = dbTester.organizations().insert(); OrganizationDto org2 = dbTester.organizations().insert(); - RulesProfileDto fooInOrg1 = dbTester.qualityProfiles().insert(org1, p->p.setName("foo")); - RulesProfileDto fooInOrg2 = dbTester.qualityProfiles().insert(org2, p->p.setName("foo")); - RulesProfileDto bar = dbTester.qualityProfiles().insert(org1, p->p.setName("bar")); + RulesProfileDto fooInOrg1 = dbTester.qualityProfiles().insert(org1, p -> p.setName("foo")); + RulesProfileDto fooInOrg2 = dbTester.qualityProfiles().insert(org2, p -> p.setName("foo")); + RulesProfileDto bar = dbTester.qualityProfiles().insert(org1, p -> p.setName("bar")); underTest.renameAndCommit(dbSession, asList(fooInOrg1.getKee(), fooInOrg2.getKee()), "foo (copy)"); - assertThat(underTest.selectOrFailByKey(dbSession, fooInOrg1.getKey()).getName()).isEqualTo("foo (copy)"); - assertThat(underTest.selectOrFailByKey(dbSession, fooInOrg2.getKey()).getName()).isEqualTo("foo (copy)"); - assertThat(underTest.selectOrFailByKey(dbSession, bar.getKey()).getName()).isEqualTo("bar"); + assertThat(underTest.selectOrFailByKey(dbSession, fooInOrg1.getKee()).getName()).isEqualTo("foo (copy)"); + assertThat(underTest.selectOrFailByKey(dbSession, fooInOrg2.getKee()).getName()).isEqualTo("foo (copy)"); + assertThat(underTest.selectOrFailByKey(dbSession, bar.getKee()).getName()).isEqualTo("bar"); } @Test @@ -498,7 +513,7 @@ public class QualityProfileDaoTest { underTest.renameAndCommit(dbSession, Collections.emptyList(), "foo (copy)"); - assertThat(underTest.selectOrFailByKey(dbSession, profile.getKey()).getName()).isEqualTo("foo"); + assertThat(underTest.selectOrFailByKey(dbSession, profile.getKee()).getName()).isEqualTo("foo"); } private RulesProfileDto insertQualityProfileDto(String key, String name, String language) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java index 9c9b359e290..562f925b2ca 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDbTester.java @@ -75,14 +75,14 @@ public class QualityProfileDbTester { public void insertProjectWithQualityProfileAssociations(ComponentDto project, RulesProfileDto... qualityProfiles) { dbClient.componentDao().insert(dbSession, project); for (RulesProfileDto qualityProfile : qualityProfiles) { - dbClient.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), qualityProfile.getKey(), dbSession); + dbClient.qualityProfileDao().insertProjectProfileAssociation(dbSession, project, qualityProfile); } dbSession.commit(); } public void associateProjectWithQualityProfile(ComponentDto project, RulesProfileDto... qualityProfiles) { for (RulesProfileDto qualityProfile : qualityProfiles) { - dbClient.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), qualityProfile.getKey(), dbSession); + dbClient.qualityProfileDao().insertProjectProfileAssociation(dbSession, project, qualityProfile); } dbSession.commit(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileTesting.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileTesting.java index 5a1e7638dcf..3c1c9c1dec5 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileTesting.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileTesting.java @@ -19,7 +19,6 @@ */ package org.sonar.db.qualityprofile; -import java.util.Date; import org.sonar.core.util.Uuids; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -37,8 +36,6 @@ public class QualityProfileTesting { .setName(uuid) .setLanguage(randomAlphanumeric(20)) .setLastUsed(nextLong()); - dto.setCreatedAt(new Date()) - .setUpdatedAt(new Date()); return dto; } @@ -56,7 +53,7 @@ public class QualityProfileTesting { // can be defined by tests DbSession dbSession = dbTester.getSession(); QProfileChangeMapper mapper = dbSession.getMapper(QProfileChangeMapper.class); - stream(dtos).forEach(dto -> mapper.insert(dto)); + stream(dtos).forEach(mapper::insert); dbSession.commit(); } } diff --git a/server/sonar-db-dao/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml b/server/sonar-db-dao/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml deleted file mode 100644 index 2b1a2bf6aa8..00000000000 --- a/server/sonar-db-dao/src/test/resources/org/sonar/db/qualityprofile/QualityProfileDaoTest/projects.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java index 138c1f77f8c..a9956f20c78 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65.java @@ -48,6 +48,7 @@ public class DbVersion65 implements DbVersion { .add(1719, "Create table default_qprofiles", CreateTableDefaultQProfiles.class) .add(1720, "Populate table default_qprofiles", PopulateTableDefaultQProfiles.class) .add(1721, "Drop rules_profiles.is_default", DropIsDefaultColumnFromRulesProfiles.class) - .add(1722, "Create table qprofiles", CreateTableQProfiles.class); + .add(1722, "Create table qprofiles", CreateTableQProfiles.class) + .add(1723, "Populate table qprofiles", PopulateQProfiles.class); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfiles.java new file mode 100644 index 00000000000..a7505cd9d55 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfiles.java @@ -0,0 +1,58 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.platform.db.migration.version.v65; + +import java.sql.SQLException; +import org.sonar.api.utils.System2; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class PopulateQProfiles extends DataChange { + + private final System2 system2; + + public PopulateQProfiles(Database db, System2 system2) { + super(db); + this.system2 = system2; + } + + @Override + protected void execute(Context context) throws SQLException { + long now = system2.now(); + + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("select p.kee, p.organization_uuid, p.parent_kee from rules_profiles p " + + "where not exists ( select qp.uuid from qprofiles qp where qp.uuid = p.kee and qp.organization_uuid = p.organization_uuid )"); + massUpdate.update("insert into qprofiles" + + " (uuid, organization_uuid, rules_profile_uuid, parent_uuid, created_at, updated_at) values (?, ?, ?, ?, ?, ?)"); + massUpdate.rowPluralName("qprofiles"); + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(1)); + update.setString(2, row.getString(2)); + update.setString(3, row.getString(1)); + update.setString(4, row.getString(3)); + update.setLong(5, now); + update.setLong(6, now); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java index c5921805052..a1f026d0fff 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/DbVersion65Test.java @@ -35,6 +35,6 @@ public class DbVersion65Test { @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 23); + verifyMigrationCount(underTest, 24); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest.java new file mode 100644 index 00000000000..b4fb5dc578c --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest.java @@ -0,0 +1,116 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.platform.db.migration.version.v65; + +import java.sql.SQLException; +import java.util.Map; +import java.util.Random; +import java.util.stream.IntStream; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.api.utils.internal.AlwaysIncreasingSystem2; +import org.sonar.db.CoreDbTester; + +import static java.lang.String.format; +import static org.assertj.core.api.Assertions.assertThat; + + +public class PopulateQProfilesTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(PopulateQProfilesTest.class, "initial.sql"); + + private System2 system2 = new AlwaysIncreasingSystem2(); + private PopulateQProfiles underTest = new PopulateQProfiles(db.database(), system2); + + @Test + public void migration_is_reentrant() throws SQLException { + insertRulesProfile("ORG_1", "java", "u1", null,true); + insertRulesProfile("ORG_2", "js", "u2", "u1", true); + + // org1 is already processed + insertQProfile("u1", "ORG_1", "RPU1"); + + underTest.execute(); + + assertThat(countRows()).isEqualTo(2); + Map qprofile1 = selectQProfile("u1", "ORG_1"); + Map qprofile2 = selectQProfile("u2", "ORG_2"); + + assertThat(qprofile1.get("UUID")).isEqualTo("u1"); + assertThat(qprofile1.get("ORGANIZATION_UUID")).isEqualTo("ORG_1"); + assertThat(qprofile1.get("RULES_PROFILE_UUID")).isEqualTo("RPU1"); // Ok if not overridden ? + assertThat(qprofile1.get("PARENT_UUID")).isNull(); + + assertThat(qprofile2.get("UUID")).isEqualTo("u2"); + assertThat(qprofile2.get("ORGANIZATION_UUID")).isEqualTo("ORG_2"); + assertThat(qprofile2.get("RULES_PROFILE_UUID")).isEqualTo("u2"); + assertThat(qprofile2.get("PARENT_UUID")).isEqualTo("u1"); + } + + @Test + public void migration_must_create_as_much_as_rules_profile() throws SQLException { + Random random = new Random(); + int nbRulesProfile = 100 + random.nextInt(100); + IntStream.range(0, nbRulesProfile).forEach( + i -> insertRulesProfile("ORG_" + i, "java", "uuid" + i, random.nextBoolean() ? "ORG_" + random.nextInt(i + 1) : null,random.nextBoolean()) + ); + + underTest.execute(); + + assertThat(countRows()).isEqualTo(nbRulesProfile); + } + + + private int countRows() { + return db.countRowsOfTable("qprofiles"); + } + + private void insertRulesProfile(String orgUuid, String language, String uuid, String parentKee, boolean isDefault) { + db.executeInsert("RULES_PROFILES", + "NAME", "name_" + uuid, + "KEE", uuid, + "ORGANIZATION_UUID", orgUuid, + "PARENT_KEE", parentKee, + "LANGUAGE", language, + "IS_DEFAULT", isDefault, + "IS_BUILT_IN", true); + } + + private void insertQProfile(String uuid, String orgUuid, String rulesProfileUuid) { + db.executeInsert("QPROFILES", + "ORGANIZATION_UUID", orgUuid, + "RULES_PROFILE_UUID", rulesProfileUuid, + "UUID", uuid, + "CREATED_AT", system2.now(), + "UPDATED_AT", system2.now() + ); + } + + private Map selectQProfile(String uuid, String orgUuid) { + return db.selectFirst(format("select * from qprofiles where uuid='%s' and organization_uuid='%s'", uuid, orgUuid)); + } +} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest/initial.sql new file mode 100644 index 00000000000..df8bf1316ff --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v65/PopulateQProfilesTest/initial.sql @@ -0,0 +1,26 @@ +CREATE TABLE "RULES_PROFILES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "NAME" VARCHAR(100) NOT NULL, + "LANGUAGE" VARCHAR(20), + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "KEE" VARCHAR(255) NOT NULL, + "PARENT_KEE" VARCHAR(255), + "RULES_UPDATED_AT" VARCHAR(100), + "IS_DEFAULT" BOOLEAN NOT NULL DEFAULT FALSE, + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "LAST_USED" BIGINT, + "USER_UPDATED_AT" BIGINT, + "IS_BUILT_IN" BOOLEAN NOT NULL +); +CREATE UNIQUE INDEX "UNIQ_QPROF_KEY" ON "RULES_PROFILES" ("KEE"); + +CREATE TABLE "QPROFILES" ( + "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, + "ORGANIZATION_UUID" VARCHAR(40) NOT NULL, + "RULES_PROFILE_UUID" VARCHAR(40) NOT NULL, + "PARENT_UUID" VARCHAR(40), + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL +); +CREATE INDEX "QPROFILES_ORG_UUID" ON "QPROFILES" ("ORGANIZATION_UUID"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java index e4c7a64a2f2..b10b8745fb8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadReportAnalysisMetadataHolderStep.java @@ -110,7 +110,7 @@ public class LoadReportAnalysisMetadataHolderStep implements ComputationStep { List profiles = dbClient.qualityProfileDao().selectByKeys(dbSession, profileKeys); String badKeys = profiles.stream() .filter(p -> !p.getOrganizationUuid().equals(organization.getUuid())) - .map(RulesProfileDto::getKey) + .map(RulesProfileDto::getKee) .collect(MoreCollectors.join(Joiner.on(", "))); if (!badKeys.isEmpty()) { throw MessageException.of(format("Quality profiles with following keys don't exist in organization [%s]: %s", organization.getKey(), badKeys)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java index 29c1da4f3f3..5d11c6a0988 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/organization/ws/DeleteAction.java @@ -136,7 +136,7 @@ public class DeleteAction implements OrganizationsWsAction { private void deleteQualityProfiles(DbSession dbSession, OrganizationDto organization) { List profiles = dbClient.qualityProfileDao().selectAll(dbSession, organization); List profileKeys = profiles.stream() - .map(RulesProfileDto::getKey) + .map(RulesProfileDto::getKee) .collect(MoreCollectors.toArrayList(profiles.size())); qProfileFactory.deleteByKeys(dbSession, profileKeys); dbSession.commit(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java index 8b39354c7e7..532b81ed0eb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/BuiltInQProfileInsertImpl.java @@ -118,7 +118,7 @@ public class BuiltInQProfileInsertImpl implements BuiltInQProfileInsert { List paramDtos = insertActiveRuleParams(session, activeRule, ruleKey, dto); - ActiveRuleChange change = ActiveRuleChange.createFor(ActiveRuleChange.Type.ACTIVATED, ActiveRuleKey.of(profileDto.getKey(), ruleKey)); + ActiveRuleChange change = ActiveRuleChange.createFor(ActiveRuleChange.Type.ACTIVATED, ActiveRuleKey.of(profileDto.getKee(), ruleKey)); change.setSeverity(dto.getSeverityString()); paramDtos.forEach(paramDto -> change.setParameter(paramDto.getKey(), paramDto.getValue())); return change; diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java index 476c517f68b..69411175cd8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java @@ -83,7 +83,7 @@ public class QProfileBackuperImpl implements QProfileBackuper { @Override public void backup(DbSession dbSession, RulesProfileDto profileDto, Writer writer) { - List activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey()); + List activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKee()); activeRules.sort(BackupActiveRuleComparator.INSTANCE); writeXml(dbSession, writer, profileDto, activeRules.iterator()); } @@ -129,7 +129,7 @@ public class QProfileBackuperImpl implements QProfileBackuper { public QProfileRestoreSummary restore(DbSession dbSession, Reader backup, RulesProfileDto profile) { return restore(dbSession, backup, nameInBackup -> { checkArgument(profile.getLanguage().equals(nameInBackup.getLanguage()), - "Can't restore %s backup on %s profile with key [%s]. Languages are different.", nameInBackup.getLanguage(), profile.getLanguage(), profile.getKey()); + "Can't restore %s backup on %s profile with key [%s]. Languages are different.", nameInBackup.getLanguage(), profile.getLanguage(), profile.getKee()); return profile; }); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java index 020890e9133..3d316f432aa 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java @@ -87,7 +87,7 @@ public class QProfileComparison { } private Map loadActiveRules(DbSession session, RulesProfileDto profile) { - return Maps.uniqueIndex(dbClient.activeRuleDao().selectByProfileKey(session, profile.getKey()), ActiveRuleToRuleKey.INSTANCE); + return Maps.uniqueIndex(dbClient.activeRuleDao().selectByProfileKey(session, profile.getKee()), ActiveRuleToRuleKey.INSTANCE); } public static class QProfileComparisonResult { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java index 6f853def9d8..89f328d0a53 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java @@ -111,7 +111,7 @@ public class QProfileExporters { private RulesProfile wrap(RulesProfileDto profile) { try (DbSession dbSession = dbClient.openSession(false)) { RulesProfile target = new RulesProfile(profile.getName(), profile.getLanguage()); - List activeRuleDtos = dbClient.activeRuleDao().selectByProfileKey(dbSession, profile.getKey()); + List activeRuleDtos = dbClient.activeRuleDao().selectByProfileKey(dbSession, profile.getKee()); List activeRuleParamDtos = dbClient.activeRuleDao().selectParamsByActiveRuleIds(dbSession, Lists.transform(activeRuleDtos, ActiveRuleDto::getId)); ListMultimap activeRuleParamsByActiveRuleId = FluentIterable.from(activeRuleParamDtos).index(ActiveRuleParamDto::getActiveRuleId); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileResetImpl.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileResetImpl.java index 5f284419e50..b539981155a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileResetImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileResetImpl.java @@ -109,7 +109,7 @@ public class QProfileResetImpl implements QProfileReset { for (RuleActivation activation : activations) { try { - List changes = activator.activate(dbSession, activation, profile.getKey()); + List changes = activator.activate(dbSession, activation, profile.getKee()); ruleToBeDeactivated.remove(activation.getRuleKey()); result.incrementSucceeded(); result.addChanges(changes); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index 197a50753b3..82b40aa1385 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -228,7 +228,7 @@ public class RuleActivator { List changes = Lists.newArrayList(); // get all inherited profiles - String qualityProfileKey = rulesProfileDto.getKey(); + String qualityProfileKey = rulesProfileDto.getKee(); List children = getChildren(session, qualityProfileKey); for (RulesProfileDto child : children) { RuleActivation childActivation = new RuleActivation(activation).setCascade(true); @@ -373,7 +373,7 @@ public class RuleActivator { List profiles = getChildren(dbSession, key.qProfile()); for (RulesProfileDto profile : profiles) { - ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), key.ruleKey()); + ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKee(), key.ruleKey()); changes.addAll(cascadeDeactivation(activeRuleKey, dbSession, true, force)); } @@ -494,7 +494,7 @@ public class RuleActivator { List changes = new ArrayList<>(); profileDto.setParentKee(null); db.qualityProfileDao().update(dbSession, profileDto); - for (ActiveRuleDto activeRule : db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey())) { + for (ActiveRuleDto activeRule : db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKee())) { if (ActiveRuleDto.INHERITED.equals(activeRule.getInheritance())) { changes.addAll(deactivate(dbSession, activeRule.getKey(), true)); } else if (ActiveRuleDto.OVERRIDES.equals(activeRule.getInheritance())) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java index b38bf1d68ad..bced651ea9c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContext.java @@ -231,6 +231,6 @@ class RuleActivatorContext { void verifyForActivation() { checkRequest(RuleStatus.REMOVED != rule.getStatus(), "Rule was removed: %s", rule.getKey()); checkRequest(!rule.isTemplate(), "Rule template can't be activated on a Quality profile: %s", rule.getKey()); - checkRequest(profile.getLanguage().equals(rule.getLanguage()), "Rule %s and profile %s have different languages", rule.getKey(), profile.getKey()); + checkRequest(profile.getLanguage().equals(rule.getLanguage()), "Rule %s and profile %s have different languages", rule.getKey(), profile.getKee()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java index 9a574ff001d..8b38d7ed5c0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivatorContextFactory.java @@ -58,7 +58,7 @@ public class RuleActivatorContextFactory { private RuleActivatorContext create(RuleKey ruleKey, DbSession session, RuleActivatorContext context) { initRule(ruleKey, context, session); - initActiveRules(context.profile().getKey(), ruleKey, context, session, false); + initActiveRules(context.profile().getKee(), ruleKey, context, session, false); String parentKee = context.profile().getParentKee(); if (parentKee != null) { initActiveRules(parentKee, ruleKey, context, session, true); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/AddProjectAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/AddProjectAction.java index a0f8d2c9531..953a4d1c63a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/AddProjectAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/AddProjectAction.java @@ -87,13 +87,13 @@ public class AddProjectAction implements QProfileWsAction { throw new IllegalArgumentException("Project and Quality profile must have same organization"); } - RulesProfileDto currentProfile = dbClient.qualityProfileDao().selectByProjectAndLanguage(dbSession, project.key(), profile.getLanguage()); + RulesProfileDto currentProfile = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(dbSession, project, profile.getLanguage()); if (currentProfile == null) { // project uses the default profile - dbClient.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), profile.getKey(), dbSession); + dbClient.qualityProfileDao().insertProjectProfileAssociation(dbSession, project, profile); dbSession.commit(); - } else if (!profile.getKey().equals(currentProfile.getKey())) { - dbClient.qualityProfileDao().updateProjectProfileAssociation(project.uuid(), profile.getKey(), currentProfile.getKey(), dbSession); + } else if (!profile.getKee().equals(currentProfile.getKee())) { + dbClient.qualityProfileDao().updateProjectProfileAssociation(dbSession, project, profile.getKee(), currentProfile.getKee()); dbSession.commit(); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java index 8a1eda3a913..e2ab0746b1c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangeParentAction.java @@ -94,13 +94,13 @@ public class ChangeParentAction implements QProfileWsAction { String parentKey = request.param(PARAM_PARENT_KEY); String parentName = request.param(PARAM_PARENT_NAME); if (isEmpty(parentKey) && isEmpty(parentName)) { - ruleActivator.setParent(dbSession, profile.getKey(), null); + ruleActivator.setParent(dbSession, profile.getKee(), null); } else { String parentOrganizationKey = parentKey == null ? organization.getKey() : null; String parentLanguage = parentKey == null ? request.param(PARAM_LANGUAGE) : null; QProfileReference parentRef = QProfileReference.from(parentKey, parentOrganizationKey, parentLanguage, parentName); RulesProfileDto parent = wsSupport.getProfile(dbSession, parentRef); - ruleActivator.setParent(dbSession, profile.getKey(), parent.getKey()); + ruleActivator.setParent(dbSession, profile.getKee(), parent.getKee()); } response.noContent(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java index ea2c511c8d5..972c1d5e582 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ChangelogAction.java @@ -86,7 +86,7 @@ public class ChangelogAction implements QProfileWsAction { try (DbSession dbSession = dbClient.openSession(false)) { RulesProfileDto profile = wsSupport.getProfile(dbSession, reference); - QProfileChangeQuery query = new QProfileChangeQuery(profile.getKey()); + QProfileChangeQuery query = new QProfileChangeQuery(profile.getKee()); Date since = parseStartingDateOrDateTime(request.param(PARAM_SINCE)); if (since != null) { query.setFromIncluded(since.getTime()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CompareAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CompareAction.java index c96b65ae233..aa5dd97602f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CompareAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CompareAction.java @@ -149,7 +149,7 @@ public class CompareAction implements QProfileWsAction { } private void writeProfile(JsonWriter json, RulesProfileDto profile) { - json.prop(ATTRIBUTE_KEY, profile.getKey()) + json.prop(ATTRIBUTE_KEY, profile.getKee()) .prop(ATTRIBUTE_NAME, profile.getName()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CopyAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CopyAction.java index 40e3fdf78d9..03a6437866f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CopyAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CopyAction.java @@ -90,7 +90,7 @@ public class CopyAction implements QProfileWsAction { String parentKey = copiedProfile.getParentKee(); response.newJsonWriter() .beginObject() - .prop("key", copiedProfile.getKey()) + .prop("key", copiedProfile.getKee()) .prop("name", copiedProfile.getName()) .prop("language", languageKey) .prop("languageName", language == null ? null : language.getName()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java index 4043da6559c..e0a165cef48 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/CreateAction.java @@ -150,7 +150,7 @@ public class CreateAction implements QProfileWsAction { String language = result.profile().getLanguage(); CreateWsResponse.QualityProfile.Builder builder = CreateWsResponse.QualityProfile.newBuilder() .setOrganization(organization.getKey()) - .setKey(result.profile().getKey()) + .setKey(result.profile().getKee()) .setName(result.profile().getName()) .setLanguage(language) .setLanguageName(languages.get(result.profile().getLanguage()).getName()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java index 8d2f95d0d7c..2a0572021d0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/DeleteAction.java @@ -85,7 +85,7 @@ public class DeleteAction implements QProfileWsAction { } private List selectDescendants(DbSession dbSession, RulesProfileDto profile) { - return dbClient.qualityProfileDao().selectDescendants(dbSession, profile.getKey()); + return dbClient.qualityProfileDao().selectDescendants(dbSession, profile.getKee()); } private void ensureNoneIsMarkedAsDefault(DbSession dbSession, RulesProfileDto profile, List descendants) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java index f5637e27de9..829ecc69a72 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/InheritanceAction.java @@ -76,7 +76,7 @@ public class InheritanceAction implements QProfileWsAction { OrganizationDto organization = dbClient.organizationDao().selectByUuid(dbSession, organizationUuid) .orElseThrow(() -> new IllegalStateException(String.format("Could not find organization with uuid '%s' for quality profile '%s'", organizationUuid, profile.getKee()))); List ancestors = profileLookup.ancestors(profile, dbSession); - List children = dbClient.qualityProfileDao().selectChildren(dbSession, profile.getKey()); + List children = dbClient.qualityProfileDao().selectChildren(dbSession, profile.getKee()); Statistics statistics = new Statistics(dbSession, organization); writeProtobuf(buildResponse(profile, ancestors, children, statistics), request, response); @@ -104,7 +104,7 @@ public class InheritanceAction implements QProfileWsAction { } private static QualityProfile buildProfile(RulesProfileDto qualityProfile, Statistics statistics) { - String key = qualityProfile.getKey(); + String key = qualityProfile.getKee(); QualityProfile.Builder builder = QualityProfile.newBuilder() .setKey(key) .setName(qualityProfile.getName()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/OldRestoreAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/OldRestoreAction.java index 7d1f723c156..af4a35fb627 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/OldRestoreAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/OldRestoreAction.java @@ -108,7 +108,7 @@ public class OldRestoreAction implements WsAction { JsonWriter jsonProfile = json.beginObject().name("profile").beginObject(); jsonProfile - .prop("key", profile.getKey()) + .prop("key", profile.getKee()) .prop("name", profile.getName()) .prop("language", languageKey) .prop("isDefault", false) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RemoveProjectAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RemoveProjectAction.java index e6558bf7918..393ad87fb98 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RemoveProjectAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RemoveProjectAction.java @@ -86,7 +86,7 @@ public class RemoveProjectAction implements QProfileWsAction { throw new IllegalArgumentException("Project and Quality profile must have same organization"); } - dbClient.qualityProfileDao().deleteProjectProfileAssociation(project.uuid(), profile.getKey(), dbSession); + dbClient.qualityProfileDao().deleteProjectProfileAssociation(dbSession, project, profile); dbSession.commit(); response.noContent(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RestoreAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RestoreAction.java index c93d2054048..edcefa69f4e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RestoreAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RestoreAction.java @@ -109,7 +109,7 @@ public class RestoreAction implements QProfileWsAction { JsonWriter jsonProfile = json.beginObject().name("profile").beginObject(); jsonProfile .prop("organization", organization.getKey()) - .prop("key", profile.getKey()) + .prop("key", profile.getKee()) .prop("name", profile.getName()) .prop("language", languageKey) .prop("isDefault", false) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java index 87a96638abd..44339c5f9c7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java @@ -159,7 +159,7 @@ public class SearchAction implements QProfileWsAction { } List profiles = dataLoader.findProfiles(dbSession, request, organization, project); - Set defaultProfiles = dbClient.defaultQProfileDao().selectExistingQProfileUuids(dbSession, organization.getUuid(), profiles.stream().map(RulesProfileDto::getKey).collect(MoreCollectors.toList())); + Set defaultProfiles = dbClient.defaultQProfileDao().selectExistingQProfileUuids(dbSession, organization.getUuid(), profiles.stream().map(RulesProfileDto::getKee).collect(MoreCollectors.toList())); return new SearchData() .setOrganization(organization) @@ -193,14 +193,14 @@ public class SearchAction implements QProfileWsAction { private SearchWsResponse buildResponse(SearchData data) { List profiles = data.getProfiles(); - Map profilesByKey = profiles.stream().collect(Collectors.toMap(RulesProfileDto::getKey, identity())); + Map profilesByKey = profiles.stream().collect(Collectors.toMap(RulesProfileDto::getKee, identity())); SearchWsResponse.Builder response = SearchWsResponse.newBuilder(); for (RulesProfileDto profile : profiles) { QualityProfile.Builder profileBuilder = response.addProfilesBuilder(); - String profileKey = profile.getKey(); + String profileKey = profile.getKee(); setNullable(profile.getOrganizationUuid(), o -> profileBuilder.setOrganization(data.getOrganization().getKey())); profileBuilder.setKey(profileKey); setNullable(profile.getName(), profileBuilder::setName); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchData.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchData.java index f6f3c863643..8f98ab7367d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchData.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchData.java @@ -83,7 +83,7 @@ public class SearchData { } boolean isDefault(RulesProfileDto profile) { - return defaultProfileKeys.contains(profile.getKey()); + return defaultProfileKeys.contains(profile.getKee()); } SearchData setDefaultProfileKeys(Set s) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java index 8c20647a41b..39449bf75cc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/SearchDataLoader.java @@ -97,7 +97,7 @@ public class SearchDataLoader { // look up profiles by profileName (if any) for each language Set unresolvedLanguages = lookupByProfileName(dbSession, organization, qualityProfiles, languageKeys, profileName); // look up profile by componentKey for each language for which we don't have one yet - Set stillUnresolvedLanguages = lookupByModule(dbSession, organization, qualityProfiles, unresolvedLanguages, project); + Set stillUnresolvedLanguages = lookupByModule(dbSession, qualityProfiles, unresolvedLanguages, project); // look up profile by default for each language for which we don't have one yet Set noDefaultProfileLanguages = lookupDefaults(dbSession, organization, qualityProfiles, stillUnresolvedLanguages); @@ -118,7 +118,7 @@ public class SearchDataLoader { } private Set lookupByProfileName(DbSession dbSession, OrganizationDto organization, Map qualityProfiles, Set languageKeys, - @Nullable String profileName) { + @Nullable String profileName) { if (languageKeys.isEmpty() || profileName == null) { return languageKeys; } @@ -129,13 +129,13 @@ public class SearchDataLoader { return difference(languageKeys, qualityProfiles.keySet()); } - private Set lookupByModule(DbSession dbSession, OrganizationDto organization, Map qualityProfiles, Set languageKeys, - ComponentDto project) { + private Set lookupByModule(DbSession dbSession, Map qualityProfiles, Set languageKeys, + ComponentDto project) { if (languageKeys.isEmpty()) { return languageKeys; } - dbClient.qualityProfileDao().selectByProjectAndLanguages(dbSession, organization, project, languageKeys) + dbClient.qualityProfileDao().selectAssociatedToProjectUuidAndLanguages(dbSession, project, languageKeys) .forEach(qualityProfile -> qualityProfiles.put(qualityProfile.getLanguage(), qualityProfile)); return difference(languageKeys, qualityProfiles.keySet()); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java index 70d930592dd..21d42e8ed9f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java @@ -220,6 +220,6 @@ public class ActiveRuleCompleter { } setNullable(profile.getParentKee(), profileResponse::setParent); - profilesResponse.put(profile.getKey(), profileResponse.build()); + profilesResponse.put(profile.getKee(), profileResponse.build()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java index 961a7558b0b..bcf317abe07 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java @@ -91,7 +91,7 @@ public class AppAction implements RulesWsAction { if (languageIsSupported(profile)) { json .beginObject() - .prop("key", profile.getKey()) + .prop("key", profile.getKee()) .prop("name", profile.getName()) .prop("lang", profile.getLanguage()) .prop("parentKey", profile.getParentKee()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/UpdateQualityProfilesLastUsedDateStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/UpdateQualityProfilesLastUsedDateStepTest.java index 76c848d072a..ee9733c0096 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/UpdateQualityProfilesLastUsedDateStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/UpdateQualityProfilesLastUsedDateStepTest.java @@ -95,7 +95,7 @@ public class UpdateQualityProfilesLastUsedDateStepTest { qualityProfileDb.insertQualityProfiles(sonarWayJava, sonarWayPhp, myQualityProfile); measureRepository.addRawMeasure(1, QUALITY_PROFILES_KEY, Measure.newMeasureBuilder().create( - toJson(sonarWayJava.getKey(), myQualityProfile.getKey()))); + toJson(sonarWayJava.getKee(), myQualityProfile.getKee()))); underTest.execute(); @@ -108,14 +108,14 @@ public class UpdateQualityProfilesLastUsedDateStepTest { public void ancestor_profiles_are_updated() throws Exception { // Parent profiles should be updated RulesProfileDto rootProfile = newQualityProfileDto().setKey("root"); - RulesProfileDto parentProfile = newQualityProfileDto().setKey("parent").setParentKee(rootProfile.getKey()); + RulesProfileDto parentProfile = newQualityProfileDto().setKey("parent").setParentKee(rootProfile.getKee()); // Current profile => should be updated - RulesProfileDto currentProfile = newQualityProfileDto().setKey("current").setParentKee(parentProfile.getKey()); + RulesProfileDto currentProfile = newQualityProfileDto().setKey("current").setParentKee(parentProfile.getKee()); // Child of current profile => should not be updated - RulesProfileDto childProfile = newQualityProfileDto().setKey("child").setParentKee(currentProfile.getKey()); + RulesProfileDto childProfile = newQualityProfileDto().setKey("child").setParentKee(currentProfile.getKee()); qualityProfileDb.insertQualityProfiles(rootProfile, parentProfile, currentProfile, childProfile); - measureRepository.addRawMeasure(1, QUALITY_PROFILES_KEY, Measure.newMeasureBuilder().create(toJson(currentProfile.getKey()))); + measureRepository.addRawMeasure(1, QUALITY_PROFILES_KEY, Measure.newMeasureBuilder().create(toJson(currentProfile.getKee()))); underTest.execute(); @@ -130,7 +130,7 @@ public class UpdateQualityProfilesLastUsedDateStepTest { RulesProfileDto currentProfile = newQualityProfileDto().setKey("current").setParentKee("unknown"); qualityProfileDb.insertQualityProfiles(currentProfile); - measureRepository.addRawMeasure(1, QUALITY_PROFILES_KEY, Measure.newMeasureBuilder().create(toJson(currentProfile.getKey()))); + measureRepository.addRawMeasure(1, QUALITY_PROFILES_KEY, Measure.newMeasureBuilder().create(toJson(currentProfile.getKee()))); expectedException.expect(RowNotFoundException.class); underTest.execute(); @@ -142,11 +142,11 @@ public class UpdateQualityProfilesLastUsedDateStepTest { } private void assertQualityProfileIsUpdated(RulesProfileDto qp) { - assertThat(selectLastUser(qp.getKey())).withFailMessage("Quality profile '%s' hasn't been updated. Value: %d", qp.getKey(), qp.getLastUsed()).isEqualTo(ANALYSIS_DATE); + assertThat(selectLastUser(qp.getKee())).withFailMessage("Quality profile '%s' hasn't been updated. Value: %d", qp.getKee(), qp.getLastUsed()).isEqualTo(ANALYSIS_DATE); } private void assertQualityProfileIsTheSame(RulesProfileDto qp) { - assertThat(selectLastUser(qp.getKey())).isEqualTo(qp.getLastUsed()); + assertThat(selectLastUser(qp.getKee())).isEqualTo(qp.getLastUsed()); } @CheckForNull diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java index 92b1f38031f..24320dffb9d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java @@ -331,7 +331,7 @@ public class DeleteActionTest { verifyOrganizationDoesNotExist(org); assertThat(db.select("select kee as \"profileKey\" from rules_profiles")) .extracting(row -> (String) row.get("profileKey")) - .containsOnly(profileInOtherOrg.getKey()); + .containsOnly(profileInOtherOrg.getKee()); } private void verifyOrganizationDoesNotExist(OrganizationDto organization) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java index 9be6070371d..9ee4522a455 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java @@ -159,7 +159,7 @@ public class QProfileBackuperMediumTest { RulesProfileDto profile = db.qualityProfileDao().selectByNameAndLanguage(organization, "P1", "xoo", dbSession); assertThat(profile).isNotNull(); - List activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profile.getKey()); + List activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profile.getKee()); assertThat(activeRules).hasSize(1); ActiveRuleDto activeRuleDoc = activeRules.get(0); assertThat(activeRuleDoc.getSeverityString()).isEqualTo("BLOCKER"); @@ -172,7 +172,7 @@ public class QProfileBackuperMediumTest { assertThat(params.get(0).getValue()).isEqualTo("7"); // Check in es - assertThat(tester.get(RuleIndex.class).searchAll(new RuleQuery().setQProfileKey(profile.getKey()).setActivation(true))).containsOnly(XOO_X1); + assertThat(tester.get(RuleIndex.class).searchAll(new RuleQuery().setQProfileKey(profile.getKee()).setActivation(true))).containsOnly(XOO_X1); } @Test @@ -381,7 +381,7 @@ public class QProfileBackuperMediumTest { RulesProfileDto target = db.qualityProfileDao().selectByNameAndLanguage(organization, "P3", "xoo", dbSession); assertThat(target).isNotNull(); - assertThat(db.activeRuleDao().selectByProfileKey(dbSession, target.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(dbSession, target.getKee())).hasSize(1); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java index 4de53af8b38..01b8db02cc9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonMediumTest.java @@ -91,8 +91,8 @@ public class QProfileComparisonMediumTest { @Test public void compare_empty_profiles() { QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isEmpty(); @@ -111,8 +111,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isNotEmpty().containsOnlyKeys(xooRule1.getKey()); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isEmpty(); @@ -126,8 +126,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isNotEmpty().containsOnlyKeys(xooRule1.getKey()); assertThat(result.inRight()).isEmpty(); @@ -141,8 +141,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isNotEmpty().containsOnlyKeys(xooRule1.getKey()); @@ -157,8 +157,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isNotEmpty().containsOnlyKeys(xooRule1.getKey()); assertThat(result.inRight()).isNotEmpty().containsOnlyKeys(xooRule2.getKey()); @@ -173,8 +173,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isEmpty(); @@ -194,8 +194,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isEmpty(); @@ -218,8 +218,8 @@ public class QProfileComparisonMediumTest { dbSession.commit(); QProfileComparisonResult result = comparison.compare(dbSession, left, right); - assertThat(result.left().getKey()).isEqualTo(left.getKey()); - assertThat(result.right().getKey()).isEqualTo(right.getKey()); + assertThat(result.left().getKee()).isEqualTo(left.getKee()); + assertThat(result.right().getKee()).isEqualTo(right.getKee()); assertThat(result.same()).isEmpty(); assertThat(result.inLeft()).isEmpty(); assertThat(result.inRight()).isEmpty(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java index f53d149b5e6..ed703457cba 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java @@ -194,7 +194,7 @@ public class QProfileCopierMediumTest { private void verifyOneActiveRule(QProfileName profileName, String expectedSeverity, @Nullable String expectedInheritance, Map expectedParams) { RulesProfileDto dto = db.qualityProfileDao().selectByNameAndLanguage(organization, profileName.getName(), profileName.getLanguage(), dbSession); - verifyOneActiveRule(dto.getKey(), expectedSeverity, expectedInheritance, expectedParams); + verifyOneActiveRule(dto.getKee(), expectedSeverity, expectedInheritance, expectedParams); } private void verifyOneActiveRule(String profileKey, String expectedSeverity, @Nullable String expectedInheritance, Map expectedParams) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java index ddb13823f86..8a7240bd06c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java @@ -106,21 +106,21 @@ public class QProfileExportersTest { db.qualityProfileDao().insert(dbSession, profileDto); dbSession.commit(); - assertThat(db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKee())).isEmpty(); QProfileResult result = exporters.importXml(profileDto, "XooProfileImporter", toInputStream("", UTF_8), dbSession); dbSession.commit(); activeRuleIndexer.index(result.getChanges()); // Check in db - List activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKey()); + List activeRules = db.activeRuleDao().selectByProfileKey(dbSession, profileDto.getKee()); assertThat(activeRules).hasSize(1); ActiveRuleDto activeRule = activeRules.get(0); assertThat(activeRule.getKey().ruleKey()).isEqualTo(RuleKey.of("xoo", "R1")); assertThat(activeRule.getSeverityString()).isEqualTo(Severity.CRITICAL); // Check in es - assertThat(tester.get(RuleIndex.class).searchAll(new RuleQuery().setQProfileKey(profileDto.getKey()).setActivation(true))).containsOnly(RuleKey.of("xoo", "R1")); + assertThat(tester.get(RuleIndex.class).searchAll(new RuleQuery().setQProfileKey(profileDto.getKee()).setActivation(true))).containsOnly(RuleKey.of("xoo", "R1")); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java index 84053d0def6..376bf919ae0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java @@ -73,7 +73,7 @@ public class QProfileFactoryMediumTest { dbSession.commit(); dbSession.clearCache(); assertThat(writtenDto.getOrganizationUuid()).isEqualTo(uuid); - assertThat(writtenDto.getKey()).isNotEmpty(); + assertThat(writtenDto.getKee()).isNotEmpty(); assertThat(writtenDto.getName()).isEqualTo("P1"); assertThat(writtenDto.getLanguage()).isEqualTo("xoo"); assertThat(writtenDto.getId()).isNotNull(); @@ -94,7 +94,7 @@ public class QProfileFactoryMediumTest { dbSession.commit(); dbSession.clearCache(); assertThat(writtenDto.getOrganizationUuid()).isEqualTo(uuid); - assertThat(writtenDto.getKey()).isNotEmpty(); + assertThat(writtenDto.getKee()).isNotEmpty(); assertThat(writtenDto.getName()).isEqualTo("P1"); assertThat(writtenDto.getLanguage()).isEqualTo("xoo"); assertThat(writtenDto.getId()).isNotNull(); @@ -173,7 +173,7 @@ public class QProfileFactoryMediumTest { private static void assertEqual(RulesProfileDto writtenDto, RulesProfileDto readDto) { assertThat(readDto.getOrganizationUuid()).isEqualTo(writtenDto.getOrganizationUuid()); assertThat(readDto.getName()).isEqualTo(writtenDto.getName()); - assertThat(readDto.getKey()).startsWith(writtenDto.getKey()); + assertThat(readDto.getKee()).startsWith(writtenDto.getKee()); assertThat(readDto.getLanguage()).isEqualTo(writtenDto.getLanguage()); assertThat(readDto.getId()).isEqualTo(writtenDto.getId()); assertThat(readDto.getParentKee()).isEqualTo(writtenDto.getParentKee()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryTest.java index 2beab0da034..45e765d5113 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryTest.java @@ -69,7 +69,7 @@ public class QProfileFactoryTest { RulesProfileDto profile2 = createRandomProfile(org); RulesProfileDto profile3 = createRandomProfile(org); - List profileKeys = asList(profile1.getKey(), profile2.getKey(), "does_not_exist"); + List profileKeys = asList(profile1.getKee(), profile2.getKee(), "does_not_exist"); underTest.deleteByKeys(db.getSession(), profileKeys); verify(activeRuleIndexer).deleteByProfileKeys(profileKeys); @@ -108,6 +108,6 @@ public class QProfileFactoryTest { } private AbstractObjectAssert assertQualityProfileFromDb(RulesProfileDto profile) { - return assertThat(db.getDbClient().qualityProfileDao().selectByKey(db.getSession(), profile.getKey())); + return assertThat(db.getDbClient().qualityProfileDao().selectByKey(db.getSession(), profile.getKee())); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java index e39162b3774..0c3d4bddbcf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileResetMediumTest.java @@ -126,13 +126,13 @@ public class QProfileResetMediumTest { RuleKey ruleKey = RuleKey.of("xoo", "x1"); RulesProfileDto profile = tester.get(QualityProfileDao.class).selectByNameAndLanguage(defaultOrganization, "Basic", ServerTester.Xoo.KEY, dbSession); - ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), ruleKey); + ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKee(), ruleKey); // Change the severity and the value of the parameter in the active rule tester.get(RuleActivator.class).activate(dbSession, new RuleActivation(ruleKey).setSeverity(BLOCKER) .setParameter("acceptWhitespace", "false"), - profile.getKey()); + profile.getKee()); dbSession.commit(); // Verify severity and param has changed @@ -175,7 +175,7 @@ public class QProfileResetMediumTest { }, defProfile); RulesProfileDto profile = tester.get(QualityProfileDao.class).selectByNameAndLanguage(defaultOrganization, "Basic", ServerTester.Xoo.KEY, dbSession); - ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), RuleKey.of("xoo", "x1")); + ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKee(), RuleKey.of("xoo", "x1")); // Change param in the rule def register(new Rules() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java index cf50f423cdc..50d68aa9852 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesMediumTest.java @@ -86,10 +86,10 @@ public class RegisterQualityProfilesMediumTest { // Check ActiveRules in DB ActiveRuleDao activeRuleDao = dbClient.activeRuleDao(); - assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2); + assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKee())).hasSize(2); RuleKey ruleKey = RuleKey.of("xoo", "x1"); - ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), ruleKey); + ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKee(), ruleKey); assertThat(activeRuleDao.selectByKey(dbSession, activeRuleKey)).isPresent(); // Check in ES @@ -139,11 +139,11 @@ public class RegisterQualityProfilesMediumTest { // Check ActiveRules in DB ActiveRuleDao activeRuleDao = dbClient.activeRuleDao(); - assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKey())).hasSize(2); + assertThat(activeRuleDao.selectByProfileKey(dbSession, profile.getKee())).hasSize(2); RuleKey ruleKey = RuleKey.of("xoo", "x1"); - ActiveRuleDto activeRule = activeRuleDao.selectByKey(dbSession, ActiveRuleKey.of(profile.getKey(), ruleKey)).get(); - assertThat(activeRule.getKey().qProfile()).isEqualTo(profile.getKey()); + ActiveRuleDto activeRule = activeRuleDao.selectByKey(dbSession, ActiveRuleKey.of(profile.getKee(), ruleKey)).get(); + assertThat(activeRule.getKey().qProfile()).isEqualTo(profile.getKee()); assertThat(activeRule.getKey().ruleKey()).isEqualTo(ruleKey); assertThat(activeRule.getSeverityString()).isEqualTo(Severity.CRITICAL); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesTest.java index 2c354ffdddf..b5d09e4ff26 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RegisterQualityProfilesTest.java @@ -115,8 +115,8 @@ public class RegisterQualityProfilesTest { underTest.start(); - assertThat(dbTester.qualityProfiles().selectByKey(outdatedProfileInOrg1.getKey()).get().getName()).isEqualTo("Sonar way (outdated copy)"); - assertThat(dbTester.qualityProfiles().selectByKey(outdatedProfileInOrg2.getKey()).get().getName()).isEqualTo("Sonar way (outdated copy)"); + assertThat(dbTester.qualityProfiles().selectByKey(outdatedProfileInOrg1.getKee()).get().getName()).isEqualTo("Sonar way (outdated copy)"); + assertThat(dbTester.qualityProfiles().selectByKey(outdatedProfileInOrg2.getKee()).get().getName()).isEqualTo("Sonar way (outdated copy)"); assertThat(logTester.logs(LoggerLevel.INFO)).contains("Rename Quality profiles [foo/Sonar way] to [Sonar way (outdated copy)] in 2 organizations"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java index a6ffaa53535..15bb60a2e73 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java @@ -206,7 +206,7 @@ public class RuleActivatorMediumTest { ImmutableMap.of("max", "7", "min", "3")); assertThat(changes).hasSize(1); assertThat(changes.get(0).getType()).isEqualTo(ActiveRuleChange.Type.ACTIVATED); - assertProfileHasBeenUpdatedManually(profileDto.getKey()); + assertProfileHasBeenUpdatedManually(profileDto.getKee()); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java index aefbf90b949..f291007af2b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRuleActionTest.java @@ -105,7 +105,7 @@ public class ActivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam("rule_key", RuleTesting.newRuleDto().getKey().toString()) - .setParam("profile_key", qualityProfile.getKey()); + .setParam("profile_key", qualityProfile.getKee()); thrown.expect(ForbiddenException.class); request.execute(); @@ -119,7 +119,7 @@ public class ActivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam("rule_key", ruleKey.toString()) - .setParam("profile_key", qualityProfile.getKey()) + .setParam("profile_key", qualityProfile.getKee()) .setParam("severity", "BLOCKER") .setParam("params", "key1=v1;key2=v2") .setParam("reset", "false"); @@ -128,7 +128,7 @@ public class ActivateRuleActionTest { assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); ArgumentCaptor captor = ArgumentCaptor.forClass(RuleActivation.class); - Mockito.verify(ruleActivator).activate(any(DbSession.class), captor.capture(), eq(qualityProfile.getKey())); + Mockito.verify(ruleActivator).activate(any(DbSession.class), captor.capture(), eq(qualityProfile.getKee())); assertThat(captor.getValue().getRuleKey()).isEqualTo(ruleKey); assertThat(captor.getValue().getSeverity()).isEqualTo(Severity.BLOCKER); assertThat(captor.getValue().getParameters()).containsExactly(entry("key1", "v1"), entry("key2", "v2")); @@ -143,7 +143,7 @@ public class ActivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam("rule_key", ruleKey.toString()) - .setParam("profile_key", qualityProfile.getKey()) + .setParam("profile_key", qualityProfile.getKee()) .setParam("severity", "BLOCKER") .setParam("params", "key1=v1;key2=v2") .setParam("reset", "false"); @@ -152,7 +152,7 @@ public class ActivateRuleActionTest { assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); ArgumentCaptor captor = ArgumentCaptor.forClass(RuleActivation.class); - Mockito.verify(ruleActivator).activate(any(DbSession.class), captor.capture(), eq(qualityProfile.getKey())); + Mockito.verify(ruleActivator).activate(any(DbSession.class), captor.capture(), eq(qualityProfile.getKee())); assertThat(captor.getValue().getRuleKey()).isEqualTo(ruleKey); assertThat(captor.getValue().getSeverity()).isEqualTo(Severity.BLOCKER); assertThat(captor.getValue().getParameters()).containsExactly(entry("key1", "v1"), entry("key2", "v2")); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java index 87e0eb3e52f..ba85b4c51fe 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ActivateRulesActionTest.java @@ -112,7 +112,7 @@ public class ActivateRulesActionTest { RulesProfileDto qualityProfile = dbTester.qualityProfiles().insert(organization); TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam("profile_key", qualityProfile.getKey()); + .setParam("profile_key", qualityProfile.getKee()); thrown.expect(ForbiddenException.class); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java index 1619b58a102..31c72d476c7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/AddProjectActionTest.java @@ -213,7 +213,7 @@ public class AddProjectActionTest { tester.newRequest() .setParam("projectUuid", "unknown") - .setParam("profileKey", profile.getKey()) + .setParam("profileKey", profile.getKee()) .execute(); } @@ -232,13 +232,13 @@ public class AddProjectActionTest { } private void assertProjectIsAssociatedToProfile(ComponentDto project, RulesProfileDto profile) { - RulesProfileDto loaded = dbClient.qualityProfileDao().selectByProjectAndLanguage(db.getSession(), project.getKey(), profile.getLanguage()); - assertThat(loaded.getKey()).isEqualTo(profile.getKey()); + RulesProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage()); + assertThat(loaded.getKee()).isEqualTo(profile.getKee()); } private void assertProjectIsNotAssociatedToProfile(ComponentDto project, RulesProfileDto profile) { - RulesProfileDto loaded = dbClient.qualityProfileDao().selectByProjectAndLanguage(db.getSession(), project.getKey(), profile.getLanguage()); - assertThat(loaded == null || !loaded.getKey().equals(profile.getKey())).isTrue(); + RulesProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage()); + assertThat(loaded == null || !loaded.getKee().equals(profile.getKee())).isTrue(); } private void logInAsProfileAdmin(OrganizationDto organization) { @@ -248,7 +248,7 @@ public class AddProjectActionTest { private TestResponse call(ComponentDto project, RulesProfileDto qualityProfile) { TestRequest request = tester.newRequest() .setParam("projectUuid", project.uuid()) - .setParam("profileKey", qualityProfile.getKey()); + .setParam("profileKey", qualityProfile.getKee()); return request.execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java index 6f26b628f54..35e5c90a6b0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/BackupActionTest.java @@ -80,10 +80,10 @@ public class BackupActionTest { public void returns_backup_of_profile_with_specified_key() throws Exception { RulesProfileDto profile = db.qualityProfiles().insertQualityProfile(QualityProfileTesting.newQualityProfileDto()); - TestResponse response = tester.newRequest().setParam("profileKey", profile.getKey()).execute(); + TestResponse response = tester.newRequest().setParam("profileKey", profile.getKee()).execute(); assertThat(response.getMediaType()).isEqualTo("application/xml"); assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile)); - assertThat(response.getHeader("Content-Disposition")).isEqualTo("attachment; filename=" + profile.getKey() + ".xml"); + assertThat(response.getHeader("Content-Disposition")).isEqualTo("attachment; filename=" + profile.getKee() + ".xml"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java index 91b91f02e6a..aaf97b48ce5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java @@ -161,21 +161,21 @@ public class ChangeParentActionTest { ruleIndexer.indexRuleDefinition(rule1.getKey()); activeRuleIndexer.index(); - assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey())).isEmpty(); + assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee())).isEmpty(); // Set parent wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE_KEY, child.getKey()) - .setParam("parentKey", parent1.getKey()) + .setParam(PARAM_PROFILE_KEY, child.getKee()) + .setParam("parentKey", parent1.getKee()) .execute(); // Check rule 1 enabled - List activeRules1 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules1 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules1).hasSize(1); assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo(rule1.getRuleKey()); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).hasSize(1); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).hasSize(1); } @Test @@ -192,21 +192,21 @@ public class ChangeParentActionTest { activeRuleIndexer.index(); // Set parent 1 - ruleActivator.setParent(dbSession, child.getKey(), parent1.getKey()); + ruleActivator.setParent(dbSession, child.getKee(), parent1.getKee()); // Set parent 2 through WS wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE_KEY, child.getKey()) - .setParam("parentKey", parent2.getKey()) + .setParam(PARAM_PROFILE_KEY, child.getKee()) + .setParam("parentKey", parent2.getKee()) .execute(); // Check rule 2 enabled - List activeRules2 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules2 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules2).hasSize(1); assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo(rule2.getRuleKey()); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).hasSize(1); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).hasSize(1); } @Test @@ -220,19 +220,19 @@ public class ChangeParentActionTest { activeRuleIndexer.index(); // Set parent - ruleActivator.setParent(dbSession, child.getKey(), parent.getKey()); + ruleActivator.setParent(dbSession, child.getKee(), parent.getKee()); // Remove parent through WS wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE_KEY, child.getKey()) + .setParam(PARAM_PROFILE_KEY, child.getKee()) .execute(); // Check no rule enabled - List activeRules = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules).isEmpty(); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).isEmpty(); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).isEmpty(); } @Test @@ -248,7 +248,7 @@ public class ChangeParentActionTest { ruleIndexer.indexRuleDefinition(rule1.getKey()); activeRuleIndexer.index(); - assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey())).isEmpty(); + assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee())).isEmpty(); System.out.println("org uuid: " + organization.getUuid()); System.out.println("org key: " + organization.getKey()); @@ -263,10 +263,10 @@ public class ChangeParentActionTest { .execute(); // 1. check rule 1 enabled - List activeRules1 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules1 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules1).hasSize(1); assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo(rule1.getRuleKey()); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).hasSize(1); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).hasSize(1); // 2. Set parent 2 wsActionTester.newRequest() @@ -278,7 +278,7 @@ public class ChangeParentActionTest { .execute(); // 2. check rule 2 enabled - List activeRules2 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules2 = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules2).hasSize(1); assertThat(activeRules2.get(0).getKey().ruleKey().rule()).isEqualTo(rule2.getRuleKey()); @@ -292,9 +292,9 @@ public class ChangeParentActionTest { .execute(); // 3. check no rule enabled - List activeRules = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules).isEmpty(); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).isEmpty(); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).isEmpty(); } @Test @@ -307,30 +307,30 @@ public class ChangeParentActionTest { ruleIndexer.indexRuleDefinition(rule1.getKey()); activeRuleIndexer.index(); - assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey())).isEmpty(); + assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee())).isEmpty(); // Set parent - ruleActivator.setParent(dbSession, child.getKey(), parent.getKey()); + ruleActivator.setParent(dbSession, child.getKee(), parent.getKee()); // Remove parent wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE_KEY, child.getKey()) + .setParam(PARAM_PROFILE_KEY, child.getKee()) .setParam("parentKey", "") .execute(); // Check no rule enabled - List activeRules = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey()); + List activeRules = dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee()); assertThat(activeRules).isEmpty(); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).isEmpty(); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).isEmpty(); } @Test public void fail_if_parent_key_and_name_both_set() throws Exception { RulesProfileDto child = createProfile(); - assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey())).isEmpty(); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).isEmpty(); + assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee())).isEmpty(); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).isEmpty(); TestRequest request = wsActionTester.newRequest() .setMethod("POST") @@ -346,8 +346,8 @@ public class ChangeParentActionTest { public void fail_if_profile_key_and_name_both_set() throws Exception { RulesProfileDto child = createProfile(); - assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKey())).isEmpty(); - assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).isEmpty(); + assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, child.getKee())).isEmpty(); + assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKee()), new SearchOptions()).getIds()).isEmpty(); TestRequest request = wsActionTester.newRequest() .setMethod("POST") @@ -368,7 +368,7 @@ public class ChangeParentActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE_KEY, child.getKey()); + .setParam(PARAM_PROFILE_KEY, child.getKee()); thrown.expect(ForbiddenException.class); thrown.expectMessage("Insufficient privileges"); @@ -384,7 +384,7 @@ public class ChangeParentActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam(PARAM_PROFILE_KEY, child.getKey()); + .setParam(PARAM_PROFILE_KEY, child.getKee()); thrown.expect(ForbiddenException.class); thrown.expectMessage("Insufficient privileges"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java index 32a7c73c507..5cf45fdfd42 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangelogActionDatabaseTest.java @@ -71,7 +71,7 @@ public class ChangelogActionDatabaseTest { String response = wsTester.newRequest() .setMethod("GET") - .setParam("profileKey", qualityProfile.getKey()) + .setParam("profileKey", qualityProfile.getKee()) .execute() .getInput(); @@ -131,7 +131,7 @@ public class ChangelogActionDatabaseTest { String response = wsTester.newRequest() .setMethod("GET") - .setParam("profileKey", qualityProfile.getKey()) + .setParam("profileKey", qualityProfile.getKee()) .execute() .getInput(); @@ -145,14 +145,14 @@ public class ChangelogActionDatabaseTest { QProfileChangeDto change = QualityProfileTesting.newQProfileChangeDto() .setKey(null) .setCreatedAt(0) - .setProfileKey(qualityProfile.getKey()); + .setProfileKey(qualityProfile.getKee()); DbSession session = dbTester.getSession(); dbTester.getDbClient().qProfileChangeDao().insert(session, change); session.commit(); String response = wsTester.newRequest() .setMethod("GET") - .setParam("profileKey", qualityProfile.getKey()) + .setParam("profileKey", qualityProfile.getKee()) .execute() .getInput(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java index b10d7392998..0c1c00f6af0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionMediumTest.java @@ -120,8 +120,8 @@ public class CompareActionMediumTest { session.commit(); wsTester.newGetRequest("api/qualityprofiles", "compare") - .setParam("leftKey", profile1.getKey()) - .setParam("rightKey", profile2.getKey()) + .setParam("leftKey", profile1.getKee()) + .setParam("rightKey", profile2.getKee()) .execute().assertJson(this.getClass(), "compare_nominal.json"); } @@ -136,8 +136,8 @@ public class CompareActionMediumTest { session.commit(); wsTester.newGetRequest("api/qualityprofiles", "compare") - .setParam("leftKey", profile1.getKey()) - .setParam("rightKey", profile2.getKey()) + .setParam("leftKey", profile1.getKee()) + .setParam("rightKey", profile2.getKee()) .execute().assertJson(this.getClass(), "compare_param_on_left.json"); } @@ -152,8 +152,8 @@ public class CompareActionMediumTest { session.commit(); wsTester.newGetRequest("api/qualityprofiles", "compare") - .setParam("leftKey", profile1.getKey()) - .setParam("rightKey", profile2.getKey()) + .setParam("leftKey", profile1.getKee()) + .setParam("rightKey", profile2.getKee()) .execute().assertJson(this.getClass(), "compare_param_on_right.json"); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionTest.java index b3385485519..d546ff3968d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CompareActionTest.java @@ -56,8 +56,8 @@ public class CompareActionTest { dbTester.qualityProfiles().insertQualityProfiles(left, right); TestRequest request = wsTester.newRequest().setMethod("POST") - .setParam("leftKey", left.getKey()) - .setParam("rightKey", right.getKey()); + .setParam("leftKey", left.getKee()) + .setParam("rightKey", right.getKee()); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Cannot compare quality profiles of different organizations."); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java index 8d2889f2098..afa90c5e8b3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CopyActionTest.java @@ -99,7 +99,7 @@ public class CopyActionTest { RulesProfileDto sourceProfile = db.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE)); TestResponse response = tester.newRequest() .setMethod("POST") - .setParam("fromKey", sourceProfile.getKey()) + .setParam("fromKey", sourceProfile.getKee()) .setParam("toName", "target-name") .execute(); @@ -114,14 +114,14 @@ public class CopyActionTest { "}"); RulesProfileDto loadedProfile = db.getDbClient().qualityProfileDao().selectByNameAndLanguage(organization, "target-name", sourceProfile.getLanguage(), db.getSession()); - assertThat(loadedProfile.getKey()).isEqualTo(generatedUuid); + assertThat(loadedProfile.getKee()).isEqualTo(generatedUuid); assertThat(loadedProfile.getParentKee()).isNull(); - assertThat(backuper.backupedProfile.getKey()).isEqualTo(sourceProfile.getKey()); + assertThat(backuper.backupedProfile.getKee()).isEqualTo(sourceProfile.getKee()); assertThat(backuper.restoredProfile.getOrganizationUuid()).isEqualTo(sourceProfile.getOrganizationUuid()); assertThat(backuper.restoredProfile.getLanguage()).isEqualTo(sourceProfile.getLanguage()); assertThat(backuper.restoredProfile.getName()).isEqualTo("target-name"); - assertThat(backuper.restoredProfile.getKey()).isEqualTo(generatedUuid); + assertThat(backuper.restoredProfile.getKee()).isEqualTo(generatedUuid); assertThat(backuper.restoredProfile.getParentKee()).isNull(); } @@ -134,23 +134,23 @@ public class CopyActionTest { TestResponse response = tester.newRequest() .setMethod("POST") - .setParam("fromKey", sourceProfile.getKey()) + .setParam("fromKey", sourceProfile.getKee()) .setParam("toName", targetProfile.getName()) .execute(); assertJson(response.getInput()).isSimilarTo("{" + - " \"key\": \"" + targetProfile.getKey() + "\"," + + " \"key\": \"" + targetProfile.getKee() + "\"," + " \"name\": \"" + targetProfile.getName() + "\"," + " \"language\": \"lang1\"," + " \"languageName\": \"Lang1\"," + " \"isDefault\": false," + " \"isInherited\": false" + "}"); - RulesProfileDto loadedProfile = db.getDbClient().qualityProfileDao().selectByKey(db.getSession(), targetProfile.getKey()); + RulesProfileDto loadedProfile = db.getDbClient().qualityProfileDao().selectByKey(db.getSession(), targetProfile.getKee()); assertThat(loadedProfile).isNotNull(); - assertThat(backuper.backupedProfile.getKey()).isEqualTo(sourceProfile.getKey()); - assertThat(backuper.restoredProfile.getKey()).isEqualTo(targetProfile.getKey()); + assertThat(backuper.backupedProfile.getKee()).isEqualTo(sourceProfile.getKee()); + assertThat(backuper.restoredProfile.getKee()).isEqualTo(targetProfile.getKee()); } @Test @@ -159,11 +159,11 @@ public class CopyActionTest { logInAsQProfileAdministrator(organization); RulesProfileDto parentProfile = db.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE)); - RulesProfileDto sourceProfile = db.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE), p -> p.setParentKee(parentProfile.getKey())); + RulesProfileDto sourceProfile = db.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE), p -> p.setParentKee(parentProfile.getKee())); TestResponse response = tester.newRequest() .setMethod("POST") - .setParam("fromKey", sourceProfile.getKey()) + .setParam("fromKey", sourceProfile.getKee()) .setParam("toName", "target-name") .execute(); @@ -178,15 +178,15 @@ public class CopyActionTest { "}"); RulesProfileDto loadedProfile = db.getDbClient().qualityProfileDao().selectByNameAndLanguage(organization, "target-name", sourceProfile.getLanguage(), db.getSession()); - assertThat(loadedProfile.getKey()).isEqualTo(generatedUuid); - assertThat(loadedProfile.getParentKee()).isEqualTo(parentProfile.getKey()); + assertThat(loadedProfile.getKee()).isEqualTo(generatedUuid); + assertThat(loadedProfile.getParentKee()).isEqualTo(parentProfile.getKee()); - assertThat(backuper.backupedProfile.getKey()).isEqualTo(sourceProfile.getKey()); + assertThat(backuper.backupedProfile.getKee()).isEqualTo(sourceProfile.getKee()); assertThat(backuper.restoredProfile.getOrganizationUuid()).isEqualTo(sourceProfile.getOrganizationUuid()); assertThat(backuper.restoredProfile.getLanguage()).isEqualTo(sourceProfile.getLanguage()); assertThat(backuper.restoredProfile.getName()).isEqualTo("target-name"); - assertThat(backuper.restoredProfile.getKey()).isEqualTo(generatedUuid); - assertThat(backuper.restoredProfile.getParentKee()).isEqualTo(parentProfile.getKey()); + assertThat(backuper.restoredProfile.getKee()).isEqualTo(generatedUuid); + assertThat(backuper.restoredProfile.getParentKee()).isEqualTo(parentProfile.getKee()); } @Test @@ -214,7 +214,7 @@ public class CopyActionTest { tester.newRequest() .setMethod("POST") - .setParam("fromKey", profile.getKey()) + .setParam("fromKey", profile.getKee()) .setParam("toName", "bar") .execute(); } @@ -230,7 +230,7 @@ public class CopyActionTest { tester.newRequest() .setMethod("POST") - .setParam("fromKey", profile.getKey()) + .setParam("fromKey", profile.getKee()) .setParam("toName", "bar") .execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java index 7355087a569..e3d1f3961e1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java @@ -116,12 +116,12 @@ public class CreateActionTest { CreateWsResponse response = executeRequest("New Profile", XOO_LANGUAGE); RulesProfileDto dto = dbClient.qualityProfileDao().selectByNameAndLanguage(organization, "New Profile", XOO_LANGUAGE, dbSession); - assertThat(dto.getKey()).isNotNull(); + assertThat(dto.getKee()).isNotNull(); assertThat(dto.getLanguage()).isEqualTo(XOO_LANGUAGE); assertThat(dto.getName()).isEqualTo("New Profile"); QualityProfile profile = response.getProfile(); - assertThat(profile.getKey()).isEqualTo(dto.getKey()); + assertThat(profile.getKey()).isEqualTo(dto.getKee()); assertThat(profile.getName()).isEqualTo("New Profile"); assertThat(profile.getLanguage()).isEqualTo(XOO_LANGUAGE); assertThat(profile.getIsInherited()).isFalse(); @@ -138,9 +138,9 @@ public class CreateActionTest { executeRequest("New Profile", XOO_LANGUAGE, ImmutableMap.of("xoo_lint", "")); RulesProfileDto dto = dbClient.qualityProfileDao().selectByNameAndLanguage(organization, "New Profile", XOO_LANGUAGE, dbSession); - assertThat(dto.getKey()).isNotNull(); - assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, dto.getKey())).hasSize(1); - assertThat(ruleIndex.searchAll(new RuleQuery().setQProfileKey(dto.getKey()).setActivation(true))).hasSize(1); + assertThat(dto.getKee()).isNotNull(); + assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, dto.getKee())).hasSize(1); + assertThat(ruleIndex.searchAll(new RuleQuery().setQProfileKey(dto.getKee()).setActivation(true))).hasSize(1); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java index aa720275029..9b86c8721e5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRuleActionTest.java @@ -100,7 +100,7 @@ public class DeactivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam("rule_key", RuleTesting.newRuleDto().getKey().toString()) - .setParam("profile_key", qualityProfile.getKey()); + .setParam("profile_key", qualityProfile.getKee()); thrown.expect(ForbiddenException.class); request.execute(); @@ -114,7 +114,7 @@ public class DeactivateRuleActionTest { TestRequest request = wsActionTester.newRequest() .setMethod("POST") .setParam("rule_key", ruleKey.toString()) - .setParam("profile_key", qualityProfile.getKey()); + .setParam("profile_key", qualityProfile.getKee()); TestResponse response = request.execute(); @@ -122,7 +122,7 @@ public class DeactivateRuleActionTest { ArgumentCaptor captor = ArgumentCaptor.forClass(ActiveRuleKey.class); Mockito.verify(ruleActivator).deactivateAndUpdateIndex(any(DbSession.class), captor.capture()); assertThat(captor.getValue().ruleKey()).isEqualTo(ruleKey); - assertThat(captor.getValue().qProfile()).isEqualTo(qualityProfile.getKey()); + assertThat(captor.getValue().qProfile()).isEqualTo(qualityProfile.getKee()); } @Test @@ -134,7 +134,7 @@ public class DeactivateRuleActionTest { .setMethod("POST") .setParam("organization", organization.getKey()) .setParam("rule_key", ruleKey.toString()) - .setParam("profile_key", qualityProfile.getKey()); + .setParam("profile_key", qualityProfile.getKee()); TestResponse response = request.execute(); @@ -142,6 +142,6 @@ public class DeactivateRuleActionTest { ArgumentCaptor captor = ArgumentCaptor.forClass(ActiveRuleKey.class); Mockito.verify(ruleActivator).deactivateAndUpdateIndex(any(DbSession.class), captor.capture()); assertThat(captor.getValue().ruleKey()).isEqualTo(ruleKey); - assertThat(captor.getValue().qProfile()).isEqualTo(qualityProfile.getKey()); + assertThat(captor.getValue().qProfile()).isEqualTo(qualityProfile.getKee()); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java index 8d404dab817..4ac08a7aadf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeactivateRulesActionTest.java @@ -111,7 +111,7 @@ public class DeactivateRulesActionTest { RulesProfileDto qualityProfile = dbTester.qualityProfiles().insert(organization); TestRequest request = wsActionTester.newRequest() .setMethod("POST") - .setParam("profile_key", qualityProfile.getKey()); + .setParam("profile_key", qualityProfile.getKee()); thrown.expect(ForbiddenException.class); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java index e1f17af43a5..d0ed9f98eab 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/DeleteActionTest.java @@ -80,7 +80,7 @@ public class DeleteActionTest { TestResponse response = tester.newRequest() .setMethod("POST") - .setParam("profileKey", profile1.getKey()) + .setParam("profileKey", profile1.getKee()) .execute(); assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); @@ -146,7 +146,7 @@ public class DeleteActionTest { tester.newRequest() .setMethod("POST") - .setParam("profileKey", profileInOrg2.getKey()) + .setParam("profileKey", profileInOrg2.getKee()) .execute(); } @@ -158,7 +158,7 @@ public class DeleteActionTest { tester.newRequest() .setMethod("POST") - .setParam("profileKey", profile.getKey()) + .setParam("profileKey", profile.getKee()) .execute(); } @@ -220,7 +220,7 @@ public class DeleteActionTest { .setParam("organization", organization.getKey()) .setParam("language", profile.getLanguage()) .setParam("profileName", profile.getName()) - .setParam("profileKey", profile.getKey()) + .setParam("profileKey", profile.getKee()) .execute(); } @@ -249,7 +249,7 @@ public class DeleteActionTest { tester.newRequest() .setMethod("POST") - .setParam("profileKey", profile.getKey()) + .setParam("profileKey", profile.getKee()) .execute(); } @@ -258,7 +258,7 @@ public class DeleteActionTest { OrganizationDto organization = dbTester.organizations().insert(); RulesProfileDto parentProfile = createProfile(organization); RulesProfileDto childProfile = dbTester.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE), - p -> p.setParentKee(parentProfile.getKey())); + p -> p.setParentKee(parentProfile.getKee())); dbTester.qualityProfiles().markAsDefault(childProfile); logInAsQProfileAdministrator(organization); @@ -268,7 +268,7 @@ public class DeleteActionTest { tester.newRequest() .setMethod("POST") - .setParam("profileKey", parentProfile.getKey()) + .setParam("profileKey", parentProfile.getKee()) .execute(); } @@ -279,12 +279,12 @@ public class DeleteActionTest { } private void verifyProfileDoesNotExist(RulesProfileDto profile, OrganizationDto organization) { - assertThat(dbClient.qualityProfileDao().selectByKey(session, profile.getKey())).isNull(); - assertThat(dbClient.qualityProfileDao().selectSelectedProjects(organization, profile.getKey(), null, session)).isEmpty(); + assertThat(dbClient.qualityProfileDao().selectByKey(session, profile.getKee())).isNull(); + assertThat(dbClient.qualityProfileDao().selectSelectedProjects(organization, profile.getKee(), null, session)).isEmpty(); } private void verifyProfileExists(RulesProfileDto profile) { - assertThat(dbClient.qualityProfileDao().selectByKey(session, profile.getKey())).isNotNull(); + assertThat(dbClient.qualityProfileDao().selectByKey(session, profile.getKee())).isNotNull(); } private RulesProfileDto createProfile(OrganizationDto organization) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java index ec51e1b8e19..c98e763228a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java @@ -180,7 +180,7 @@ public class ExportActionTest { .execute() .getInput(); - assertThat(result).isEqualTo("Backup of " + profile.getLanguage() + "/" + profile.getKey()); + assertThat(result).isEqualTo("Backup of " + profile.getLanguage() + "/" + profile.getKee()); } @Test @@ -205,7 +205,7 @@ public class ExportActionTest { .setParam("language", defaultJavaInOrg1.getLanguage()) .execute() .getInput()) - .isEqualTo("Backup of java/" + defaultJavaInOrg1.getKey()); + .isEqualTo("Backup of java/" + defaultJavaInOrg1.getKee()); // profile for specified organization, language and name --> do not mix with Xoo profile or profile with same lang/name on other // organization @@ -215,7 +215,7 @@ public class ExportActionTest { .setParam("name", defaultJavaInOrg1.getName()) .execute() .getInput()) - .isEqualTo("Backup of java/" + defaultJavaInOrg1.getKey()); + .isEqualTo("Backup of java/" + defaultJavaInOrg1.getKee()); } private RulesProfileDto createProfile(OrganizationDto organization, boolean isDefault) { @@ -254,7 +254,7 @@ public class ExportActionTest { @Override public void backup(DbSession dbSession, RulesProfileDto profile, Writer backupWriter) { try { - backupWriter.write(format("Backup of %s/%s", profile.getLanguage(), profile.getKey())); + backupWriter.write(format("Backup of %s/%s", profile.getLanguage(), profile.getKee())); } catch (IOException e) { throw new IllegalStateException(e); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java index 05ce1723d4b..ecd6231471c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java @@ -174,16 +174,16 @@ public class InheritanceActionTest { InputStream response = wsActionTester.newRequest() .setMethod("GET") .setMediaType(PROTOBUF) - .setParam("profileKey", child.getKey()) + .setParam("profileKey", child.getKee()) .execute() .getInputStream(); InheritanceWsResponse result = InheritanceWsResponse.parseFrom(response); - assertThat(result.getProfile().getKey()).isEqualTo(child.getKey()); + assertThat(result.getProfile().getKey()).isEqualTo(child.getKee()); assertThat(result.getProfile().getActiveRuleCount()).isEqualTo(childRules); - assertThat(result.getAncestorsList()).extracting(InheritanceWsResponse.QualityProfile::getKey).containsExactly(parent.getKey()); + assertThat(result.getAncestorsList()).extracting(InheritanceWsResponse.QualityProfile::getKey).containsExactly(parent.getKee()); assertThat(result.getAncestorsList()).extracting(InheritanceWsResponse.QualityProfile::getActiveRuleCount).containsExactly(parentRules); } @@ -201,12 +201,12 @@ public class InheritanceActionTest { InputStream response = wsActionTester.newRequest() .setMethod("GET") .setMediaType(PROTOBUF) - .setParam("profileKey", profile.getKey()) + .setParam("profileKey", profile.getKee()) .execute() .getInputStream(); InheritanceWsResponse result = InheritanceWsResponse.parseFrom(response); - assertThat(result.getProfile().getKey()).isEqualTo(profile.getKey()); + assertThat(result.getProfile().getKey()).isEqualTo(profile.getKee()); assertThat(result.getProfile().getActiveRuleCount()).isEqualTo(activeRules); } @@ -238,7 +238,7 @@ public class InheritanceActionTest { } private void setParent(RulesProfileDto profile, RulesProfileDto parent) { - ruleActivator.setParent(dbSession, parent.getKey(), profile.getKey()); + ruleActivator.setParent(dbSession, parent.getKee(), profile.getKee()); } private RuleDefinitionDto createRule(String lang, String id) { @@ -266,7 +266,7 @@ public class InheritanceActionTest { } private void overrideActiveRuleSeverity(RuleDefinitionDto rule, RulesProfileDto profile, String severity) { - ruleActivator.activate(dbSession, new RuleActivation(rule.getKey()).setSeverity(severity), profile.getKey()); + ruleActivator.activate(dbSession, new RuleActivation(rule.getKey()).setSeverity(severity), profile.getKee()); dbSession.commit(); activeRuleIndexer.index(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java index 91aef37f971..ddd2e4a3d64 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ProjectsActionTest.java @@ -86,7 +86,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").execute().assertJson(this.getClass(), "authorized_selected.json"); + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").execute().assertJson(this.getClass(), "authorized_selected.json"); } @Test @@ -101,20 +101,20 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "2") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "2") .execute().assertJson(this.getClass(), "selected_page1.json"); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "2").setParam("page", "2") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "2").setParam("page", "2") .execute().assertJson(this.getClass(), "selected_page2.json"); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "2").setParam("page", "3") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "2").setParam("page", "3") .execute().assertJson(this.getClass(), "empty.json"); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "2").setParam("page", "4") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "2").setParam("page", "4") .execute().assertJson(this.getClass(), "empty.json"); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "3").setParam("page", "1") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "3").setParam("page", "1") .execute().assertJson(this.getClass(), "selected_ps3_page1.json"); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "3").setParam("page", "2") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "3").setParam("page", "2") .execute().assertJson(this.getClass(), "selected_ps3_page2.json"); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "selected").setParam("pageSize", "3").setParam("page", "3") + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "selected").setParam("pageSize", "3").setParam("page", "3") .execute().assertJson(this.getClass(), "empty.json"); } @@ -130,7 +130,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "deselected").execute().assertJson(this.getClass(), "deselected.json"); + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "deselected").execute().assertJson(this.getClass(), "deselected.json"); } @Test @@ -147,7 +147,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "all").execute().assertJson(this.getClass(), "all.json"); + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "all.json"); } @Test @@ -162,7 +162,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "all").setParam("query", "project t").execute().assertJson(this.getClass(), "all_filtered.json"); + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "all").setParam("query", "project t").execute().assertJson(this.getClass(), "all_filtered.json"); } @Test(expected = NotFoundException.class) @@ -184,7 +184,7 @@ public class ProjectsActionTest { dbSession.commit(); - newRequest().setParam("key", xooP1.getKey()).setParam("selected", "all").execute().assertJson(this.getClass(), "return_deprecated_uuid_field.json"); + newRequest().setParam("key", xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "return_deprecated_uuid_field.json"); } private void createProfiles() { @@ -205,9 +205,9 @@ public class ProjectsActionTest { return ComponentTesting.newPrivateProjectDto(organizationDto, uuid).setName(name); } - private void associateProjectsWithProfile(DbSession session, RulesProfileDto profile, ComponentDto... projects) { + private void associateProjectsWithProfile(DbSession dbSession, RulesProfileDto profile, ComponentDto... projects) { for (ComponentDto project : projects) { - dbClient.qualityProfileDao().insertProjectProfileAssociation(project.uuid(), profile.getKey(), session); + dbClient.qualityProfileDao().insertProjectProfileAssociation(dbSession, project, profile); } } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java index 8b272863b13..51958153504 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfileWsSupportTest.java @@ -50,9 +50,9 @@ public class QProfileWsSupportTest { public void getProfile_returns_the_profile_specified_by_key() { RulesProfileDto profile = db.qualityProfiles().insertQualityProfile(QualityProfileTesting.newQualityProfileDto()); - RulesProfileDto loaded = underTest.getProfile(db.getSession(), QProfileReference.fromKey(profile.getKey())); + RulesProfileDto loaded = underTest.getProfile(db.getSession(), QProfileReference.fromKey(profile.getKee())); - assertThat(loaded.getKey()).isEqualTo(profile.getKey()); + assertThat(loaded.getKee()).isEqualTo(profile.getKee()); assertThat(loaded.getOrganizationUuid()).isEqualTo(profile.getOrganizationUuid()); assertThat(loaded.getLanguage()).isEqualTo(profile.getLanguage()); assertThat(loaded.getName()).isEqualTo(profile.getName()); @@ -73,7 +73,7 @@ public class QProfileWsSupportTest { RulesProfileDto loaded = underTest.getProfile(db.getSession(), QProfileReference.fromName(null, profile.getLanguage(), profile.getName())); - assertThat(loaded.getKey()).isEqualTo(profile.getKey()); + assertThat(loaded.getKee()).isEqualTo(profile.getKee()); assertThat(loaded.getOrganizationUuid()).isEqualTo(profile.getOrganizationUuid()); assertThat(loaded.getLanguage()).isEqualTo(profile.getLanguage()); assertThat(loaded.getName()).isEqualTo(profile.getName()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java index a3dd09b0151..b54c0147f14 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java @@ -106,17 +106,17 @@ public class QProfilesWsMediumTest { activeRuIndexer.index(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(1); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ACTION_DEACTIVATE_RULE); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(PARAM_RULE_KEY, rule.getKey().toString()); request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); } @Test @@ -134,16 +134,16 @@ public class QProfilesWsMediumTest { activeRuIndexer.index(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(4); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, DeactivateRulesAction.DEACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); WsTester.Result result = request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); } @Test @@ -160,17 +160,17 @@ public class QProfilesWsMediumTest { activeRuIndexer.index(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(2); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, DeactivateRulesAction.DEACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); WsTester.Result result = request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0); - assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(0); + assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKee())).hasSize(2); } @Test @@ -184,17 +184,17 @@ public class QProfilesWsMediumTest { activeRuIndexer.index(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(2); // 1. Deactivate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, DeactivateRulesAction.DEACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(WebService.Param.TEXT_QUERY, "hello"); WsTester.Result result = request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(1); } @Test @@ -205,17 +205,17 @@ public class QProfilesWsMediumTest { ruleIndexer.indexRuleDefinition(rule.getKey()); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ACTION_ACTIVATE_RULE); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(PARAM_RULE_KEY, rule.getKey().toString()); WsTester.Result result = request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(1); } @Test @@ -226,12 +226,12 @@ public class QProfilesWsMediumTest { ruleIndexer.indexRuleDefinition(rule.getKey()); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); try { // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ACTION_ACTIVATE_RULE); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(PARAM_RULE_KEY, rule.getKey().toString()); request.execute(); session.clearCache(); @@ -249,18 +249,18 @@ public class QProfilesWsMediumTest { ruleIndexer.indexRuleDefinition(rule.getKey()); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ACTION_ACTIVATE_RULE); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(PARAM_RULE_KEY, rule.getKey().toString()); request.setParam(PARAM_SEVERITY, "MINOR"); WsTester.Result result = request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKey(), rule.getKey()); + ActiveRuleKey activeRuleKey = ActiveRuleKey.of(profile.getKee(), rule.getKey()); assertThat(db.activeRuleDao().selectOrFailByKey(session, activeRuleKey).getSeverityString()) .isEqualTo("MINOR"); @@ -276,17 +276,17 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ActivateRulesAction.ACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(PARAM_LANGUAGES, "java"); request.execute().assertJson(getClass(), "bulk_activate_rule.json"); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(4); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(4); } @Test @@ -300,17 +300,17 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKee())).isEmpty(); // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ActivateRulesAction.ACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, php.getKey()); + request.setParam(PARAM_PROFILE_KEY, php.getKee()); request.setParam(PARAM_LANGUAGES, "php"); request.execute().assertJson(getClass(), "bulk_activate_rule_not_all.json"); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKee())).hasSize(2); } @Test @@ -323,27 +323,27 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); // 1. Activate Rule with query returning 0 hits WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ActivateRulesAction.ACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(WebService.Param.TEXT_QUERY, "php"); request.execute(); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(0); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(0); // 1. Activate Rule with query returning 1 hits request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ActivateRulesAction.ACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, profile.getKey()); + request.setParam(PARAM_PROFILE_KEY, profile.getKee()); request.setParam(WebService.Param.TEXT_QUERY, "world"); request.execute(); session.commit(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).hasSize(1); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).hasSize(1); } @Test @@ -354,7 +354,7 @@ public class QProfilesWsMediumTest { session.commit(); // 0. Assert No Active Rule for profile - assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKey())).isEmpty(); + assertThat(db.activeRuleDao().selectByProfileKey(session, profile.getKee())).isEmpty(); // 2. Assert ActiveRule with BLOCKER severity assertThat(tester.get(RuleIndex.class).search( @@ -363,7 +363,7 @@ public class QProfilesWsMediumTest { // 1. Activate Rule with query returning 2 hits WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ActivateRulesAction.ACTIVATE_RULES_ACTION); - request.setParam(ActivateRulesAction.PROFILE_KEY, profile.getKey()); + request.setParam(ActivateRulesAction.PROFILE_KEY, profile.getKee()); request.setParam(ActivateRulesAction.SEVERITY, "MINOR"); request.execute(); session.commit(); @@ -371,7 +371,7 @@ public class QProfilesWsMediumTest { // 2. Assert ActiveRule with MINOR severity assertThat(tester.get(ActiveRuleDao.class).selectByRuleId(session, organization, rule0.getId()).get(0).getSeverityString()).isEqualTo("MINOR"); assertThat(tester.get(RuleIndex.class).searchAll(new RuleQuery() - .setQProfileKey(profile.getKey()) + .setQProfileKey(profile.getKee()) .setKey(rule0.getKey().toString()) .setActiveSeverities(Collections.singleton("MINOR")) .setActivation(true))).hasSize(1); @@ -389,14 +389,14 @@ public class QProfilesWsMediumTest { // 1. Activate Rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ActivateRulesAction.ACTIVATE_RULES_ACTION); - request.setParam(PARAM_PROFILE_KEY, javaProfile.getKey()); - request.setParam(PARAM_QPROFILE, javaProfile.getKey()); + request.setParam(PARAM_PROFILE_KEY, javaProfile.getKee()); + request.setParam(PARAM_QPROFILE, javaProfile.getKee()); request.setParam("activation", "false"); request.execute().assertJson(getClass(), "does_not_return_warnings_when_bulk_activate_on_profile_and_rules_exist_on_another_language_than_profile.json"); session.clearCache(); // 2. Assert ActiveRule in DAO - assertThat(db.activeRuleDao().selectByProfileKey(session, javaProfile.getKey())).hasSize(2); + assertThat(db.activeRuleDao().selectByProfileKey(session, javaProfile.getKee())).hasSize(2); } @Test @@ -421,7 +421,7 @@ public class QProfilesWsMediumTest { // 1. reset child rule WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, ACTION_ACTIVATE_RULE); - request.setParam("profile_key", subProfile.getKey()); + request.setParam("profile_key", subProfile.getKee()); request.setParam("rule_key", rule.getKey().toString()); request.setParam("reset", "true"); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java index 8e0a4df70fd..2610ea9f219 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RemoveProjectActionTest.java @@ -156,7 +156,7 @@ public class RemoveProjectActionTest { tester.newRequest() .setParam("projectUuid", "unknown") - .setParam("profileKey", profile.getKey()) + .setParam("profileKey", profile.getKee()) .execute(); } @@ -175,13 +175,13 @@ public class RemoveProjectActionTest { } private void assertProjectIsAssociatedToProfile(ComponentDto project, RulesProfileDto profile) { - RulesProfileDto loaded = dbClient.qualityProfileDao().selectByProjectAndLanguage(db.getSession(), project.getKey(), profile.getLanguage()); - assertThat(loaded.getKey()).isEqualTo(profile.getKey()); + RulesProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage()); + assertThat(loaded.getKee()).isEqualTo(profile.getKee()); } private void assertProjectIsNotAssociatedToProfile(ComponentDto project, RulesProfileDto profile) { - RulesProfileDto loaded = dbClient.qualityProfileDao().selectByProjectAndLanguage(db.getSession(), project.getKey(), profile.getLanguage()); - assertThat(loaded == null || !loaded.getKey().equals(profile.getKey())).isTrue(); + RulesProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage()); + assertThat(loaded == null || !loaded.getKee().equals(profile.getKee())).isTrue(); } private void logInAsProfileAdmin() { @@ -191,7 +191,7 @@ public class RemoveProjectActionTest { private TestResponse call(ComponentDto project, RulesProfileDto qualityProfile) { TestRequest request = tester.newRequest() .setParam("projectUuid", project.uuid()) - .setParam("profileKey", qualityProfile.getKey()); + .setParam("profileKey", qualityProfile.getKee()); return request.execute(); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java index afcddf55ded..a2326a71f34 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/RenameActionTest.java @@ -94,14 +94,14 @@ public class RenameActionTest { .setLanguage("xoo") .setName("Old, valid name"); db.qualityProfiles().insertQualityProfile(qualityProfile1); - String qualityProfileKey1 = qualityProfile1.getKey(); + String qualityProfileKey1 = qualityProfile1.getKee(); RulesProfileDto qualityProfile2 = QualityProfileTesting.newQualityProfileDto() .setOrganizationUuid(organization.getUuid()) .setLanguage("xoo") .setName("Invalid, duplicated name"); db.qualityProfiles().insertQualityProfile(qualityProfile2); - String qualityProfileKey2 = qualityProfile2.getKey(); + String qualityProfileKey2 = qualityProfile2.getKee(); expectedException.expect(BadRequestException.class); expectedException.expectMessage("Quality profile already exists: Invalid, duplicated name"); @@ -121,14 +121,14 @@ public class RenameActionTest { .setLanguage("xoo") .setName("Old, unique name"); db.qualityProfiles().insertQualityProfile(qualityProfile1); - String qualityProfileKey1 = qualityProfile1.getKey(); + String qualityProfileKey1 = qualityProfile1.getKee(); RulesProfileDto qualityProfile2 = QualityProfileTesting.newQualityProfileDto() .setOrganizationUuid(organizationY.getUuid()) .setLanguage("xoo") .setName("Duplicated name"); db.qualityProfiles().insertQualityProfile(qualityProfile2); - String qualityProfileKey2 = qualityProfile2.getKey(); + String qualityProfileKey2 = qualityProfile2.getKee(); underTest.doHandle("Duplicated name", qualityProfileKey1); @@ -170,7 +170,7 @@ public class RenameActionTest { RulesProfileDto qualityProfile = QualityProfileTesting.newQualityProfileDto() .setOrganizationUuid(organizationY.getUuid()); db.qualityProfiles().insertQualityProfile(qualityProfile); - String qualityProfileKey = qualityProfile.getKey(); + String qualityProfileKey = qualityProfile.getKee(); expectedException.expect(ForbiddenException.class); expectedException.expectMessage("Insufficient privileges"); @@ -241,7 +241,7 @@ public class RenameActionTest { RulesProfileDto qualityProfile = QualityProfileTesting.newQualityProfileDto() .setOrganizationUuid(organization.getUuid()); db.qualityProfiles().insertQualityProfile(qualityProfile); - return qualityProfile.getKey(); + return qualityProfile.getKee(); } private void createProfiles() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java index 2b5f2aec7c4..20790befbfd 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java @@ -142,7 +142,7 @@ public class SearchActionTest { .setOrganizationUuid(organization.getUuid()) .setLanguage(xoo2.getKey()) .setName("My Sonar way") - .setParentKee(parentProfile.getKey()); + .setParentKee(parentProfile.getKee()); RulesProfileDto profileOnUnknownLang = RulesProfileDto.createFor("sonar-way-other-666") .setOrganizationUuid(organization.getUuid()) .setLanguage("other") @@ -185,7 +185,7 @@ public class SearchActionTest { assertJson(result).isSimilarTo("{\"profiles\":[" + "{" + - " \"key\":\"" + profile.getKey() + "\"," + + " \"key\":\"" + profile.getKee() + "\"," + " \"activeRuleCount\":3," + " \"activeDeprecatedRuleCount\":2" + "}]}"); @@ -241,7 +241,7 @@ public class SearchActionTest { assertThat(result.getProfilesList()) .extracting(QualityProfile::getKey) - .containsExactlyInAnyOrder(qualityProfileOnXoo1.getKey(), defaultProfileOnXoo2.getKey()); + .containsExactlyInAnyOrder(qualityProfileOnXoo1.getKee(), defaultProfileOnXoo2.getKee()); } @Test @@ -306,8 +306,8 @@ public class SearchActionTest { assertThat(result.getProfilesList()) .extracting(QualityProfile::getKey) - .contains(qualityProfileOnXoo1.getKey(), qualityProfileOnXoo2.getKey()) - .doesNotContain(anotherQualityProfileOnXoo1.getKey()); + .contains(qualityProfileOnXoo1.getKee(), qualityProfileOnXoo2.getKee()) + .doesNotContain(anotherQualityProfileOnXoo1.getKee()); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java index 6ca5719bab4..895ce8d3fab 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SetDefaultActionTest.java @@ -99,8 +99,8 @@ public class SetDefaultActionTest { public void set_default_profile_using_key() throws Exception { logInAsQProfileAdministrator(); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); - checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); + checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKee()); TestResponse response = tester.newRequest() .setMethod("POST") @@ -108,7 +108,7 @@ public class SetDefaultActionTest { assertThat(response.getInput()).isEmpty(); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); checkDefaultProfile(organization, xoo2Key, xoo2Profile.getKee()); // One more time! @@ -117,7 +117,7 @@ public class SetDefaultActionTest { .setParam("profileKey", xoo2Profile.getKee()).execute(); assertThat(response2.getInput()).isEmpty(); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); checkDefaultProfile(organization, xoo2Key, xoo2Profile.getKee()); } @@ -125,8 +125,8 @@ public class SetDefaultActionTest { public void set_default_profile_using_language_and_name() throws Exception { logInAsQProfileAdministrator(); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); - checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); + checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKee()); TestResponse response = tester.newRequest().setMethod("POST") .setParam("language", xoo2Profile.getLanguage()) @@ -136,7 +136,7 @@ public class SetDefaultActionTest { assertThat(response.getInput()).isEmpty(); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); checkDefaultProfile(organization, xoo2Key, xoo2Profile.getKee()); } @@ -161,8 +161,8 @@ public class SetDefaultActionTest { db.qualityProfiles().insertQualityProfiles(profileOrg1Old, profileOrg1New, profileOrg2); db.qualityProfiles().markAsDefault(profileOrg1Old, profileOrg2); - checkDefaultProfile(organization1, xoo1Key, profileOrg1Old.getKey()); - checkDefaultProfile(organization2, xoo1Key, profileOrg2.getKey()); + checkDefaultProfile(organization1, xoo1Key, profileOrg1Old.getKee()); + checkDefaultProfile(organization2, xoo1Key, profileOrg2.getKee()); TestResponse response = tester.newRequest().setMethod("POST") .setParam("language", profileOrg1New.getLanguage()) @@ -173,7 +173,7 @@ public class SetDefaultActionTest { assertThat(response.getInput()).isEmpty(); assertThat(response.getStatus()).isEqualTo(204); - checkDefaultProfile(organization1, xoo1Key, profileOrg1New.getKey()); + checkDefaultProfile(organization1, xoo1Key, profileOrg1New.getKee()); checkDefaultProfile(organization2, xoo1Key, profileOrg2.getKee()); } @@ -188,8 +188,8 @@ public class SetDefaultActionTest { .setParam("profileKey", "unknown-profile-666") .execute(); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); - checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); + checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKee()); } @Test @@ -204,8 +204,8 @@ public class SetDefaultActionTest { Fail.failBecauseExceptionWasNotThrown(NotFoundException.class); } catch (NotFoundException nfe) { assertThat(nfe).hasMessage("Quality Profile for language 'xoo2' and name 'Unknown' does not exist"); - checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKey()); - checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKey()); + checkDefaultProfile(organization, xoo1Key, xoo1Profile.getKee()); + checkDefaultProfile(organization, xoo2Key, xoo2Profile2.getKee()); } } @@ -251,6 +251,6 @@ public class SetDefaultActionTest { } private void checkDefaultProfile(OrganizationDto organization, String language, String key) { - assertThat(dbClient.qualityProfileDao().selectDefaultProfile(db.getSession(), organization, language).getKey()).isEqualTo(key); + assertThat(dbClient.qualityProfileDao().selectDefaultProfile(db.getSession(), organization, language).getKee()).isEqualTo(key); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java index 3da1950831e..1c8a24ffe89 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java @@ -482,7 +482,7 @@ public class RuleUpdaterTest { assertThat(paramsByKey.get("format").getDefaultValue()).isNull(); // Verify that severity has not changed - ActiveRuleDto activeRuleReloaded = db.getDbClient().activeRuleDao().selectOrFailByKey(dbSession, ActiveRuleKey.of(profileDto.getKey(), customRule.getKey())); + ActiveRuleDto activeRuleReloaded = db.getDbClient().activeRuleDao().selectOrFailByKey(dbSession, ActiveRuleKey.of(profileDto.getKee(), customRule.getKey())); assertThat(activeRuleReloaded.getSeverityString()).isEqualTo(Severity.BLOCKER); // Verify active rule parameters has been updated diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ActiveRuleCompleterTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ActiveRuleCompleterTest.java index bcd780e21ac..23be755b07f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ActiveRuleCompleterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ActiveRuleCompleterTest.java @@ -48,7 +48,7 @@ public class ActiveRuleCompleterTest { List result = activeRuleCompleter.completeShow(dbTester.getSession(), organization, rule); - assertThat(result).extracting(Rules.Active::getQProfile).containsExactlyInAnyOrder(qualityProfile.getKey()); + assertThat(result).extracting(Rules.Active::getQProfile).containsExactlyInAnyOrder(qualityProfile.getKee()); assertThat(result).extracting(Rules.Active::getSeverity).containsExactlyInAnyOrder(activeRule.getSeverityString()); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RuleQueryFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RuleQueryFactoryTest.java index 413112bfa17..01b970acd04 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RuleQueryFactoryTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RuleQueryFactoryTest.java @@ -129,7 +129,7 @@ public class RuleQueryFactoryTest { PARAM_IS_TEMPLATE, "true", PARAM_LANGUAGES, "java,js", TEXT_QUERY, "S001", - PARAM_QPROFILE, qualityProfile.getKey(), + PARAM_QPROFILE, qualityProfile.getKee(), PARAM_ORGANIZATION, organization.getKey(), PARAM_REPOSITORIES, "pmd,checkstyle", PARAM_SEVERITIES, "MINOR,CRITICAL", @@ -151,7 +151,7 @@ public class RuleQueryFactoryTest { assertThat(result.isTemplate()).isTrue(); assertThat(result.getLanguages()).containsOnly(qualityProfile.getLanguage()); assertThat(result.getQueryText()).isEqualTo("S001"); - assertThat(result.getQProfileKey()).isEqualTo(qualityProfile.getKey()); + assertThat(result.getQProfileKey()).isEqualTo(qualityProfile.getKee()); assertThat(result.getOrganizationUuid()).isEqualTo(organization.getUuid()); assertThat(result.getRepositories()).containsOnly("pmd", "checkstyle"); assertThat(result.getRuleKey()).isNull(); @@ -167,7 +167,7 @@ public class RuleQueryFactoryTest { @Test public void use_quality_profiles_language_if_available() throws Exception { RulesProfileDto qualityProfile = dbTester.qualityProfiles().insert(organization); - String qualityProfileKey = qualityProfile.getKey(); + String qualityProfileKey = qualityProfile.getKee(); RuleQuery result = execute( PARAM_LANGUAGES, "specifiedLanguage", @@ -225,7 +225,7 @@ public class RuleQueryFactoryTest { RulesProfileDto qualityProfile = dbTester.qualityProfiles().insert(organization1); - String qualityProfileKey = qualityProfile.getKey(); + String qualityProfileKey = qualityProfile.getKee(); String organization2Key = organization2.getKey(); thrown.expect(IllegalArgumentException.class); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java index b606b9ce8bc..c35db2aea05 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java @@ -393,7 +393,7 @@ public class SearchActionMediumTest { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); request.setParam(WebService.Param.TEXT_QUERY, "x1"); request.setParam(PARAM_ACTIVATION, "true"); - request.setParam(PARAM_QPROFILE, profile2.getKey()); + request.setParam(PARAM_QPROFILE, profile2.getKee()); request.setParam(WebService.Param.FIELDS, "actives"); WsTester.Result result = request.execute(); result.assertJson(this.getClass(), "search_profile_active_rules.json"); @@ -434,7 +434,7 @@ public class SearchActionMediumTest { WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD); request.setParam(WebService.Param.TEXT_QUERY, "x1"); request.setParam(PARAM_ACTIVATION, "true"); - request.setParam(PARAM_QPROFILE, profile2.getKey()); + request.setParam(PARAM_QPROFILE, profile2.getKee()); request.setParam(WebService.Param.FIELDS, "actives"); WsTester.Result result = request.execute(); result.assertJson(this.getClass(), "search_profile_active_rules_inheritance.json"); -- 2.39.5