aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2024-02-14 09:25:14 +0100
committersonartech <sonartech@sonarsource.com>2024-02-16 20:02:31 +0000
commit33de33ad99df936004546f37ecbfac62ce73f8d6 (patch)
tree9b2ba82b5dc9d95721e266302721d6429afeed9d
parent119aca6c8cac066f8de9da229e52d2f6213a0406 (diff)
downloadsonarqube-33de33ad99df936004546f37ecbfac62ce73f8d6.tar.gz
sonarqube-33de33ad99df936004546f37ecbfac62ce73f8d6.zip
SONAR-21165 Remove uuid from issues_impacts and rules_default_impacts table
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolverTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/pushevent/PushEventFactoryTest.java5
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java31
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueMapperIT.java2
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeCommandsIT.java4
-rw-r--r--server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java11
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/ImpactDto.java18
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml17
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml3
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml7
-rw-r--r--server/sonar-db-dao/src/schema/schema-sq.ddl6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java3
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java2
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java21
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTableIT.java53
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTableIT.java53
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTableIT.java58
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT.java57
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTableIT.java52
-rw-r--r--server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTableIT.java51
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java2
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRules.java12
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTable.java55
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTable.java55
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105.java51
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTable.java61
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTable.java61
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTable.java35
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTable.java32
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/package-info.java23
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105Test.java41
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java30
-rw-r--r--server/sonar-webserver-common/src/main/java/org/sonar/server/common/rule/RuleCreator.java4
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/NewRuleCreator.java2
-rw-r--r--server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/StartupRuleUpdater.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/StartupRuleUpdaterTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java44
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java2
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CompareActionIT.java2
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java3
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java11
47 files changed, 871 insertions, 152 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
index 2d236380aa1..3feed4fa16e 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
@@ -232,7 +232,7 @@ public class ExportIssuesStepIT {
.setRuleDescriptionContextKey("test_rule_description_context_key")
.setIssueCreationTime(963L)
.setIssueUpdateTime(852L)
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH).setUuid("uuid"))
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH))
.setIssueCloseTime(741L)
.setCodeVariants(List.of("v1", "v2"));
@@ -281,8 +281,8 @@ public class ExportIssuesStepIT {
IssueDto issueDto = createBaseIssueDto(readyRuleDto, SOME_PROJECT_UUID);
IssueDto issueDto2 = createBaseIssueDto(readyRuleDto, SOME_PROJECT_UUID);
issueDto2
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH).setUuid("uuid1"))
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.LOW).setUuid("uuid2"));
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH))
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.LOW));
insertIssue(issueDto);
insertIssue(issueDto2);
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
index 5a0b79b3404..366196f6ce9 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
@@ -43,7 +43,6 @@ import org.sonar.ce.task.projectexport.steps.DumpElement;
import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
import org.sonar.ce.task.projectexport.steps.ProjectHolder;
import org.sonar.ce.task.step.TestComputationStepContext;
-import org.sonar.core.util.Uuids;
import org.sonar.db.DbTester;
import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
@@ -207,8 +206,8 @@ public class ExportAdHocRulesStepIT {
.setIsExternal(false)
.setIsAdHoc(true)
.setCleanCodeAttribute(CleanCodeAttribute.CONVENTIONAL)
- .addDefaultImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(org.sonar.api.issue.impact.Severity.MEDIUM))
- .addDefaultImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
+ .addDefaultImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(org.sonar.api.issue.impact.Severity.MEDIUM))
+ .addDefaultImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
.setRuleKey(ruleKey)
.setScope(RuleDto.Scope.ALL)
.setStatus(RuleStatus.READY);
@@ -260,8 +259,8 @@ public class ExportAdHocRulesStepIT {
.setIsExternal(false)
.setIsAdHoc(true)
.setCleanCodeAttribute(CleanCodeAttribute.CONVENTIONAL)
- .addDefaultImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(org.sonar.api.issue.impact.Severity.MEDIUM))
- .addDefaultImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
+ .addDefaultImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(org.sonar.api.issue.impact.Severity.MEDIUM))
+ .addDefaultImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
.setAdHocName("ad_hoc_rule" + RandomStringUtils.randomAlphabetic(10))
.setAdHocType(RuleType.VULNERABILITY)
.setAdHocSeverity(Severity.CRITICAL)
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java
index abf43f79e64..24502c5cce1 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreator.java
@@ -30,7 +30,6 @@ import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactory;
-import org.sonar.core.util.Uuids;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.issue.ImpactDto;
@@ -116,7 +115,7 @@ public class AdHocRuleCreator {
}
private static ImpactDto createImpactDto(SoftwareQuality softwareQuality, Severity severity) {
- return new ImpactDto().setUuid(Uuids.create()).setSoftwareQuality(softwareQuality).setSeverity(severity);
+ return new ImpactDto().setSoftwareQuality(softwareQuality).setSeverity(severity);
}
private RuleDto findOrCreateRuleDto(DbSession dbSession, NewAdHocRule adHoc, RuleDao dao, long now) {
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolverTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolverTest.java
index 726c0ee7e0c..ce48a6b61be 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolverTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/UpdateConflictResolverTest.java
@@ -27,7 +27,6 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
import org.sonar.api.utils.DateUtils;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.issue.ImpactDto;
import org.sonar.db.issue.IssueDto;
@@ -58,7 +57,7 @@ public class UpdateConflictResolverTest {
.setRuleKey("java", "AvoidCycles")
.setProjectUuid("U1")
.setComponentUuid("U2")
- .addImpact(new ImpactDto(UuidFactoryFast.getInstance().create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH))
+ .addImpact(new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH))
.setLine(10)
.setStatus(STATUS_OPEN)
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/pushevent/PushEventFactoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/pushevent/PushEventFactoryTest.java
index d1bccf82745..e5854112628 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/pushevent/PushEventFactoryTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/pushevent/PushEventFactoryTest.java
@@ -43,7 +43,6 @@ import org.sonar.ce.task.projectanalysis.issue.RuleRepository;
import org.sonar.ce.task.projectanalysis.locations.flow.FlowGenerator;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.FieldDiffs;
-import org.sonar.core.util.Uuids;
import org.sonar.db.issue.ImpactDto;
import org.sonar.db.protobuf.DbCommons;
import org.sonar.db.protobuf.DbIssues;
@@ -412,8 +411,8 @@ public class PushEventFactoryTest {
ruleDto.setRuleKey(RuleKey.of("javasecurity", "S123"));
ruleDto.setSecurityStandards(Set.of("owasp-a1"));
ruleDto.setCleanCodeAttribute(CleanCodeAttribute.CONVENTIONAL);
- ruleDto.addDefaultImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.MEDIUM));
- ruleDto.addDefaultImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.HIGH));
+ ruleDto.addDefaultImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.MEDIUM));
+ ruleDto.addDefaultImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.HIGH));
return new org.sonar.ce.task.projectanalysis.issue.RuleImpl(ruleDto);
}
}
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java
index 4ae47c90d5c..b28ad9e957d 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueDaoIT.java
@@ -19,6 +19,7 @@
*/
package org.sonar.db.issue;
+import java.sql.SQLException;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -40,7 +41,6 @@ import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.System2;
-import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.Pagination;
@@ -213,13 +213,15 @@ public class IssueDaoIT {
}
@Test
- public void scrollIndexationIssues_shouldReturnDto() {
+ public void scrollIndexationIssues_shouldReturnDto() throws SQLException {
ComponentDto project = db.components().insertPrivateProject().getMainBranchComponent();
RuleDto rule = db.rules().insert(r -> r.setRepositoryKey("java").setLanguage("java")
- .addDefaultImpact(new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
- .setSoftwareQuality(RELIABILITY)
- .setSeverity(MEDIUM)));
+ .replaceAllDefaultImpacts(List.of(new ImpactDto()
+ .setSoftwareQuality(MAINTAINABILITY)
+ .setSeverity(MEDIUM),
+ new ImpactDto()
+ .setSoftwareQuality(RELIABILITY)
+ .setSeverity(LOW))));
ComponentDto branchA = db.components().insertProjectBranch(project, b -> b.setKey("branchA"));
ComponentDto fileA = db.components().insertComponent(newFileDto(branchA));
@@ -235,8 +237,8 @@ public class IssueDaoIT {
assertThat(next.getRuleDefaultImpacts()).hasSize(2)
.extracting(ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
.containsExactlyInAnyOrder(
- tuple(RELIABILITY, MEDIUM),
- tuple(MAINTAINABILITY, HIGH));
+ tuple(RELIABILITY, LOW),
+ tuple(MAINTAINABILITY, MEDIUM));
assertThat(next.getImpacts())
.extracting(ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
.containsExactlyInAnyOrder(
@@ -596,7 +598,7 @@ public class IssueDaoIT {
@NotNull
private static ImpactDto createImpact(SoftwareQuality softwareQuality, Severity high) {
- return new ImpactDto().setUuid(UuidFactoryFast.getInstance().create()).setSoftwareQuality(softwareQuality).setSeverity(high);
+ return new ImpactDto().setSoftwareQuality(softwareQuality).setSeverity(high);
}
@Test
@@ -660,11 +662,9 @@ public class IssueDaoIT {
@Test
public void insert_shouldInsertBatchIssuesWithImpacts() {
ImpactDto impact1 = new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(MAINTAINABILITY)
.setSeverity(HIGH);
ImpactDto impact2 = new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(SECURITY)
.setSeverity(LOW);
IssueDto issue1 = createIssueWithKey(ISSUE_KEY1)
@@ -686,11 +686,9 @@ public class IssueDaoIT {
@Test
public void deleteIssueImpacts_shouldDeleteOnlyImpactsOfIssue() {
ImpactDto impact1 = new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(MAINTAINABILITY)
.setSeverity(HIGH);
ImpactDto impact2 = new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(SECURITY)
.setSeverity(LOW);
IssueDto issue1 = createIssueWithKey(ISSUE_KEY1)
@@ -709,11 +707,9 @@ public class IssueDaoIT {
@Test
public void updateWithoutIssueImpacts_shouldNotReplaceIssueImpacts() {
ImpactDto impact1 = new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(MAINTAINABILITY)
.setSeverity(HIGH);
ImpactDto impact2 = new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(SECURITY)
.setSeverity(LOW);
IssueDto issue1 = createIssueWithKey(ISSUE_KEY1)
@@ -728,9 +724,9 @@ public class IssueDaoIT {
Optional<IssueDto> issueDto = underTest.selectByKey(db.getSession(), ISSUE_KEY1);
assertThat(issueDto).isPresent()
.get()
- .satisfies(i -> assertThat(i.getResolution()).isEqualTo(RESOLUTION_FALSE_POSITIVE) )
+ .satisfies(i -> assertThat(i.getResolution()).isEqualTo(RESOLUTION_FALSE_POSITIVE))
.extracting(IssueDto::getImpacts)
- .satisfies(impactDtos -> assertThat(impactDtos).extracting(ImpactDto::getSoftwareQuality,ImpactDto::getSeverity)
+ .satisfies(impactDtos -> assertThat(impactDtos).extracting(ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
.containsExactlyInAnyOrder(tuple(MAINTAINABILITY, HIGH), tuple(SECURITY, LOW)));
}
@@ -1031,7 +1027,6 @@ public class IssueDaoIT {
private static ImpactDto newIssueImpact(SoftwareQuality softwareQuality, Severity severity) {
return new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(softwareQuality)
.setSeverity(severity);
}
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueMapperIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueMapperIT.java
index 28f5987b8a4..15188ca5186 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueMapperIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/issue/IssueMapperIT.java
@@ -503,11 +503,9 @@ public class IssueMapperIT {
.setStatus(Issue.STATUS_CLOSED)
.setIssueCloseTime(issueCloseTime)
.addImpact(new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSeverity(Severity.HIGH)
.setSoftwareQuality(SoftwareQuality.MAINTAINABILITY))
.addImpact(new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSeverity(Severity.LOW)
.setSoftwareQuality(SoftwareQuality.SECURITY));
Arrays.asList(consumers).forEach(c -> c.accept(res));
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeCommandsIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeCommandsIT.java
index a44162eb39b..feeed3c5aa8 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeCommandsIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/purge/PurgeCommandsIT.java
@@ -582,7 +582,7 @@ public class PurgeCommandsIT {
int count = 5;
IntStream.range(0, count).forEach(i -> {
IssueDto issue = dbTester.issues().insertIssue(t -> t.setRule(rule).setProject(projectOrView).setComponent(projectOrView)
- .addImpact(new ImpactDto().setUuid(UuidFactoryFast.getInstance().create())
+ .addImpact(new ImpactDto()
.setSoftwareQuality(SoftwareQuality.SECURITY)
.setSeverity(Severity.HIGH)));
issueKeys.add("'" + issue.getKey() + "'");
@@ -590,7 +590,7 @@ public class PurgeCommandsIT {
underTest.deleteIssues(projectOrView.uuid());
- assertThat(dbTester.countSql("select count(uuid) from issues_impacts where issue_key in (" +
+ assertThat(dbTester.countSql("select count(software_quality) from issues_impacts where issue_key in (" +
String.join(", ", issueKeys) + ")")).isZero();
}
diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java
index 920393a32c1..16e2433da01 100644
--- a/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java
+++ b/server/sonar-db-dao/src/it/java/org/sonar/db/rule/RuleDaoIT.java
@@ -132,17 +132,17 @@ public class RuleDaoIT {
RuleDto ruleDto = newRule();
underTest.insertShallow(db.getSession(), ruleDto);
- ImpactDto impact1 = new ImpactDto("uuid1", MAINTAINABILITY, org.sonar.api.issue.impact.Severity.HIGH);
- ImpactDto impact2 = new ImpactDto("uuid2", SECURITY, org.sonar.api.issue.impact.Severity.LOW);
+ ImpactDto impact1 = new ImpactDto(MAINTAINABILITY, org.sonar.api.issue.impact.Severity.HIGH);
+ ImpactDto impact2 = new ImpactDto(SECURITY, org.sonar.api.issue.impact.Severity.LOW);
underTest.insertRuleDefaultImpacts(db.getSession(), ruleDto.getUuid(), Set.of(impact1, impact2));
RuleDto actualRule = underTest.selectByKey(db.getSession(), ruleDto.getKey()).get();
assertThat(actualRule.getDefaultImpacts())
- .extracting(ImpactDto::getUuid, ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
- .containsExactlyInAnyOrder(tuple("uuid1", MAINTAINABILITY, org.sonar.api.issue.impact.Severity.HIGH),
- tuple("uuid2", SECURITY, org.sonar.api.issue.impact.Severity.LOW));
+ .extracting(ImpactDto::getSoftwareQuality, ImpactDto::getSeverity)
+ .containsExactlyInAnyOrder(tuple(MAINTAINABILITY, org.sonar.api.issue.impact.Severity.HIGH),
+ tuple(SECURITY, org.sonar.api.issue.impact.Severity.LOW));
}
@Test
@@ -1359,7 +1359,6 @@ public class RuleDaoIT {
private static ImpactDto newRuleDefaultImpact(SoftwareQuality softwareQuality, org.sonar.api.issue.impact.Severity severity) {
return new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(softwareQuality)
.setSeverity(severity);
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/ImpactDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/ImpactDto.java
index 100fa04e43f..4cf2ec95e1a 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/ImpactDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/ImpactDto.java
@@ -25,7 +25,6 @@ import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
public class ImpactDto implements Serializable {
- private String uuid;
private SoftwareQuality softwareQuality;
private Severity severity;
@@ -33,21 +32,11 @@ public class ImpactDto implements Serializable {
// nothing to do
}
- public ImpactDto(String uuid, SoftwareQuality softwareQuality, Severity severity) {
- this.uuid = uuid;
+ public ImpactDto(SoftwareQuality softwareQuality, Severity severity) {
this.softwareQuality = softwareQuality;
this.severity = severity;
}
- public String getUuid() {
- return uuid;
- }
-
- public ImpactDto setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
public SoftwareQuality getSoftwareQuality() {
return softwareQuality;
}
@@ -77,14 +66,13 @@ public class ImpactDto implements Serializable {
}
ImpactDto impactDto = (ImpactDto) o;
- return Objects.equals(uuid, impactDto.uuid)
- && Objects.equals(softwareQuality, impactDto.softwareQuality)
+ return Objects.equals(softwareQuality, impactDto.softwareQuality)
&& Objects.equals(severity, impactDto.severity);
}
@Override
public int hashCode() {
- return Objects.hash(uuid, softwareQuality, severity);
+ return Objects.hash(softwareQuality, severity);
}
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
index 69379d6a88f..8e3cdb99a69 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
@@ -45,7 +45,6 @@ import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.util.Uuids;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.protobuf.DbIssues;
import org.sonar.db.rule.RuleDto;
@@ -169,7 +168,6 @@ public final class IssueDto implements Serializable {
@NotNull
private static Set<ImpactDto> mapToImpactDto(Map<SoftwareQuality, Severity> impacts) {
return impacts.entrySet().stream().map(e -> new ImpactDto()
- .setUuid(Uuids.create())
.setSoftwareQuality(e.getKey())
.setSeverity(e.getValue()))
.collect(Collectors.toSet());
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
index dd03b461856..fe5563c9ecc 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
@@ -70,7 +70,7 @@ public class IssueTesting {
.setResolution(null)
.setSeverity(Severity.ALL.get(nextInt(Severity.ALL.size())))
//TODO map to correct impact. Will be fixed with persistence of impacts on issues
- .addImpact(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
.setEffort((long) RandomUtils.nextInt(10))
.setAssigneeUuid("assignee-uuid_" + randomAlphabetic(26))
.setAuthorLogin("author_" + randomAlphabetic(5))
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
index 31f459370f3..1b399c4a812 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
@@ -114,12 +114,10 @@
</sql>
<sql id="issueImpactsColumns">
- ii.uuid as "ii_uuid",
ii.software_quality as "ii_softwareQuality",
ii.severity as "ii_severity",
</sql>
<sql id="ruleDefaultImpactsColumns">
- rdi.uuid as "rdi_uuid",
rdi.software_quality as "rdi_softwareQuality",
rdi.severity as "rdi_severity",
</sql>
@@ -127,15 +125,13 @@
<resultMap id="issueResultMap" type="Issue" autoMapping="true">
<id property="kee" column="kee"/>
- <collection property="impacts" column="ii_uuid" notNullColumn="ii_uuid"
+ <collection property="impacts" column="ii_softwareQuality" notNullColumn="ii_softwareQuality"
javaType="java.util.Set" ofType="Impact">
- <id property="uuid" column="ii_uuid"/>
<result property="softwareQuality" column="ii_softwareQuality"/>
<result property="severity" column="ii_severity"/>
</collection>
- <collection property="ruleDefaultImpacts" column="rdi_uuid" notNullColumn="rdi_uuid"
+ <collection property="ruleDefaultImpacts" column="rdi_softwareQuality" notNullColumn="rdi_softwareQuality"
javaType="java.util.Set" ofType="Impact">
- <id property="uuid" column="rdi_uuid"/>
<result property="softwareQuality" column="rdi_softwareQuality"/>
<result property="severity" column="rdi_severity"/>
</collection>
@@ -180,9 +176,8 @@
</insert>
<insert id="insertIssueImpact" parameterType="map" useGeneratedKeys="false">
- INSERT INTO issues_impacts (uuid, issue_key, software_quality, severity)
+ INSERT INTO issues_impacts (issue_key, software_quality, severity)
VALUES (
- #{dto.uuid,jdbcType=VARCHAR},
#{issueKey,jdbcType=VARCHAR},
#{dto.softwareQuality,jdbcType=VARCHAR},
#{dto.severity,jdbcType=VARCHAR})
@@ -326,15 +321,13 @@
<resultMap id="indexedIssueResultMap" type="org.sonar.db.issue.IndexedIssueDto" autoMapping="true">
<id property="issueKey" column="issueKey"/>
- <collection property="impacts" column="ii_uuid" notNullColumn="ii_uuid"
+ <collection property="impacts" column="ii_softwareQuality" notNullColumn="ii_softwareQuality"
javaType="java.util.Set" ofType="Impact">
- <id property="uuid" column="ii_uuid"/>
<result property="softwareQuality" column="ii_softwareQuality"/>
<result property="severity" column="ii_severity"/>
</collection>
- <collection property="ruleDefaultImpacts" column="rdi_uuid" notNullColumn="rdi_uuid"
+ <collection property="ruleDefaultImpacts" column="rdi_softwareQuality" notNullColumn="rdi_softwareQuality"
javaType="java.util.Set" ofType="Impact">
- <id property="uuid" column="rdi_uuid"/>
<result property="softwareQuality" column="rdi_softwareQuality"/>
<result property="severity" column="rdi_severity"/>
</collection>
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml
index c1847669a1e..db9e9b8fc95 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/project/ProjectExportMapper.xml
@@ -73,7 +73,6 @@
r.ad_hoc_severity as "adHocSeverity",
r.ad_hoc_type as "adHocType",
r.clean_code_attribute as "cleanCodeAttribute",
- rdi.uuid as "rdi_uuid",
rdi.rule_uuid as "rdi_ruleUuid",
rdi.software_quality as "rdi_softwareQuality",
rdi.severity as "rdi_severity",
@@ -132,8 +131,6 @@
i.code_variants as codeVariantsString,
ii.software_quality as ii_softwareQuality,
ii.severity as ii_severity,
- ii.uuid as ii_uuid,
- rdi.uuid as rdi_uuid,
rdi.software_quality as rdi_softwareQuality,
rdi.severity as rdi_severity
from issues i
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml
index 0fd03c1c85b..41373d9c5a8 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml
@@ -58,7 +58,6 @@
<sql id="selectJoinedTablesColumns">
<!-- rule default impacts -->
- rdi.uuid as "rdi_uuid",
rdi.rule_uuid as "rdi_ruleUuid",
rdi.software_quality as "rdi_softwareQuality",
rdi.severity as "rdi_severity",
@@ -103,8 +102,7 @@
</constructor>
</association>
</collection>
- <collection property="defaultImpacts" column="rdi_uuid" notNullColumn="rdi_uuid" javaType="java.util.Set" ofType="Impact">
- <id property="uuid" column="rdi_uuid"/>
+ <collection property="defaultImpacts" column="rdi_softwareQuality" notNullColumn="rdi_softwareQuality" javaType="java.util.Set" ofType="Impact">
<result property="softwareQuality" column="rdi_softwareQuality"/>
<result property="severity" column="rdi_severity"/>
</collection>
@@ -382,9 +380,8 @@
</insert>
<insert id="insertRuleDefaultImpact" parameterType="Map" useGeneratedKeys="false">
- INSERT INTO rules_default_impacts (uuid, rule_uuid, software_quality, severity)
+ INSERT INTO rules_default_impacts (rule_uuid, software_quality, severity)
VALUES (
- #{dto.uuid,jdbcType=VARCHAR},
#{ruleUuid,jdbcType=VARCHAR},
#{dto.softwareQuality,jdbcType=VARCHAR},
#{dto.severity,jdbcType=VARCHAR})
diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl
index 4c50b6fe8cc..6c499986410 100644
--- a/server/sonar-db-dao/src/schema/schema-sq.ddl
+++ b/server/sonar-db-dao/src/schema/schema-sq.ddl
@@ -480,12 +480,11 @@ CREATE TABLE "ISSUES_FIXED"(
ALTER TABLE "ISSUES_FIXED" ADD CONSTRAINT "PK_ISSUES_FIXED" PRIMARY KEY("PULL_REQUEST_UUID", "ISSUE_KEY");
CREATE TABLE "ISSUES_IMPACTS"(
- "UUID" CHARACTER VARYING(40) NOT NULL,
"ISSUE_KEY" CHARACTER VARYING(40) NOT NULL,
"SOFTWARE_QUALITY" CHARACTER VARYING(40) NOT NULL,
"SEVERITY" CHARACTER VARYING(40) NOT NULL
);
-ALTER TABLE "ISSUES_IMPACTS" ADD CONSTRAINT "PK_ISSUES_IMPACTS" PRIMARY KEY("UUID");
+ALTER TABLE "ISSUES_IMPACTS" ADD CONSTRAINT "PK_ISSUES_IMPACTS" PRIMARY KEY("ISSUE_KEY", "SOFTWARE_QUALITY");
CREATE UNIQUE NULLS NOT DISTINCT INDEX "UNIQ_ISS_KEY_SOF_QUAL" ON "ISSUES_IMPACTS"("ISSUE_KEY" NULLS FIRST, "SOFTWARE_QUALITY" NULLS FIRST);
CREATE TABLE "LIVE_MEASURES"(
@@ -969,12 +968,11 @@ ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID");
CREATE UNIQUE NULLS NOT DISTINCT INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST);
CREATE TABLE "RULES_DEFAULT_IMPACTS"(
- "UUID" CHARACTER VARYING(40) NOT NULL,
"RULE_UUID" CHARACTER VARYING(40) NOT NULL,
"SOFTWARE_QUALITY" CHARACTER VARYING(40) NOT NULL,
"SEVERITY" CHARACTER VARYING(40) NOT NULL
);
-ALTER TABLE "RULES_DEFAULT_IMPACTS" ADD CONSTRAINT "PK_RULES_DEFAULT_IMPACTS" PRIMARY KEY("UUID");
+ALTER TABLE "RULES_DEFAULT_IMPACTS" ADD CONSTRAINT "PK_RULES_DEFAULT_IMPACTS" PRIMARY KEY("RULE_UUID", "SOFTWARE_QUALITY");
CREATE UNIQUE NULLS NOT DISTINCT INDEX "UNIQ_RUL_UUID_SOF_QUAL" ON "RULES_DEFAULT_IMPACTS"("RULE_UUID" NULLS FIRST, "SOFTWARE_QUALITY" NULLS FIRST);
CREATE TABLE "RULES_PARAMETERS"(
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
index 1de02d240ee..8cf061d70a6 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java
@@ -37,7 +37,6 @@ import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.api.utils.Duration;
import org.sonar.core.issue.DefaultIssue;
-import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.protobuf.DbIssues;
import org.sonar.db.rule.RuleDto;
@@ -402,7 +401,6 @@ public class IssueDtoTest {
public static ImpactDto newImpactDto(SoftwareQuality softwareQuality, Severity severity) {
return new ImpactDto()
- .setUuid(UuidFactoryFast.getInstance().create())
.setSoftwareQuality(softwareQuality)
.setSeverity(severity);
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
index 87799781a20..56b0c279627 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDtoTest.java
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.sonar.api.issue.impact.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
-import org.sonar.core.util.UuidFactoryFast;
import org.sonar.api.rules.RuleType;
import org.sonar.core.util.Uuids;
import org.sonar.db.issue.ImpactDto;
@@ -241,6 +240,6 @@ public class RuleDtoTest {
}
public static ImpactDto newImpactDto(SoftwareQuality softwareQuality, Severity severity) {
- return new ImpactDto(UuidFactoryFast.getInstance().create(), softwareQuality, severity);
+ return new ImpactDto(softwareQuality, severity);
}
}
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
index fa85946b420..b2fae217b51 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java
@@ -97,7 +97,7 @@ public class RuleTesting {
.setDescriptionFormat(RuleDto.Format.HTML)
.setType(CODE_SMELL)
.setCleanCodeAttribute(CleanCodeAttribute.CLEAR)
- .addDefaultImpact(new ImpactDto().setUuid(uuidFactory.create())
+ .addDefaultImpact(new ImpactDto()
.setSoftwareQuality(SoftwareQuality.MAINTAINABILITY)
.setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
.setStatus(RuleStatus.READY)
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java
index 3ab08aa014a..1eb137d93ce 100644
--- a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java
@@ -75,6 +75,21 @@ public class PopulateDefaultImpactsInRulesIT {
}
@Test
+ public void execute_shouldNotBeExecuted_whenImpactsTableHasAlreadyRecords() throws SQLException {
+ insertRuleWithType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
+ insertRuleWithType("uuid2", RuleType.CODE_SMELL, Severity.MAJOR);
+ insertImpact("uuid", SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH);
+
+ underTest.execute();
+
+ assertThat(db.select("select software_quality, severity from rules_default_impacts"))
+ .hasSize(1)
+ .extracting(stringObjectMap -> stringObjectMap.get("software_quality"),
+ stringObjectMap -> stringObjectMap.get("severity"))
+ .containsExactly(tuple(SoftwareQuality.SECURITY.name(), org.sonar.api.issue.impact.Severity.HIGH.name()));
+ }
+
+ @Test
public void execute_whenAdhocRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
insertRuleWithAdHocType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
underTest.execute();
@@ -172,7 +187,7 @@ public class PopulateDefaultImpactsInRulesIT {
private void insertRule(String uuid, @Nullable RuleType ruleType, @Nullable Severity severity, @Nullable RuleType adHocType, @Nullable Severity adHocseverity, boolean isAdhoc) {
db.executeInsert(TABLE_NAME,
"UUID", uuid,
- "PLUGIN_RULE_KEY", "key",
+ "PLUGIN_RULE_KEY", "key" + uuid,
"PLUGIN_NAME", "name",
"SCOPE", "1",
"RULE_TYPE", ruleType != null ? ruleType.getDbConstant() : null,
@@ -187,7 +202,7 @@ public class PopulateDefaultImpactsInRulesIT {
private void insertInvalidRule(String uuid) {
db.executeInsert(TABLE_NAME,
"UUID", uuid,
- "PLUGIN_RULE_KEY", "key",
+ "PLUGIN_RULE_KEY", "key" + uuid,
"PLUGIN_NAME", "name",
"SCOPE", "1",
"RULE_TYPE", 100,
@@ -202,7 +217,7 @@ public class PopulateDefaultImpactsInRulesIT {
private void insertPlaceholderAdhocRule(String uuid) {
db.executeInsert(TABLE_NAME,
"UUID", uuid,
- "PLUGIN_RULE_KEY", "key",
+ "PLUGIN_RULE_KEY", "key" + uuid,
"PLUGIN_NAME", "name",
"SCOPE", "1",
"IS_TEMPLATE", false,
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTableIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTableIT.java
new file mode 100644
index 00000000000..3e295373be1
--- /dev/null
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTableIT.java
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.MigrationDbTester;
+
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnIssuesImpactsTable.ISSUE_KEY_COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnIssuesImpactsTable.PK_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnIssuesImpactsTable.SOFTWARE_QUALITY_COLUMN;
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnIssuesImpactsTable.TABLE_NAME;
+
+public class CreatePrimaryKeyOnIssuesImpactsTableIT {
+ @Rule
+ public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreatePrimaryKeyOnIssuesImpactsTable.class);
+
+ private final CreatePrimaryKeyOnIssuesImpactsTable createIndex = new CreatePrimaryKeyOnIssuesImpactsTable(db.database());
+
+ @Test
+ public void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
+ db.assertNoPrimaryKey(TABLE_NAME);
+
+ createIndex.execute();
+ db.assertPrimaryKey(TABLE_NAME, PK_NAME, ISSUE_KEY_COLUMN_NAME, SOFTWARE_QUALITY_COLUMN);
+ }
+
+ @Test
+ public void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
+ createIndex.execute();
+ createIndex.execute();
+
+ db.assertPrimaryKey(TABLE_NAME, PK_NAME, ISSUE_KEY_COLUMN_NAME, SOFTWARE_QUALITY_COLUMN);
+ }
+}
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTableIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTableIT.java
new file mode 100644
index 00000000000..a2749be32c5
--- /dev/null
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTableIT.java
@@ -0,0 +1,53 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.MigrationDbTester;
+
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.PK_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.RULE_UUID_COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.SOFTWARE_QUALITY_COLUMN;
+import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.TABLE_NAME;
+
+public class CreatePrimaryKeyOnRulesDefaultImpactsTableIT {
+ @Rule
+ public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreatePrimaryKeyOnRulesDefaultImpactsTable.class);
+
+ private final CreatePrimaryKeyOnRulesDefaultImpactsTable createIndex = new CreatePrimaryKeyOnRulesDefaultImpactsTable(db.database());
+
+ @Test
+ public void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
+ db.assertNoPrimaryKey(TABLE_NAME);
+
+ createIndex.execute();
+ db.assertPrimaryKey(TABLE_NAME, PK_NAME, RULE_UUID_COLUMN_NAME, SOFTWARE_QUALITY_COLUMN);
+ }
+
+ @Test
+ public void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
+ createIndex.execute();
+ createIndex.execute();
+
+ db.assertPrimaryKey(TABLE_NAME, PK_NAME, RULE_UUID_COLUMN_NAME, SOFTWARE_QUALITY_COLUMN);
+ }
+}
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTableIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTableIT.java
new file mode 100644
index 00000000000..22c92f8bdcc
--- /dev/null
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTableIT.java
@@ -0,0 +1,58 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.MigrationDbTester;
+import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInIssuesImpactsTable.COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInIssuesImpactsTable.CONSTRAINT_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInIssuesImpactsTable.TABLE_NAME;
+
+public class DropPrimaryKeyConstraintInIssuesImpactsTableIT {
+
+ @Rule
+ public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropPrimaryKeyConstraintInIssuesImpactsTable.class);
+
+ private final DbPrimaryKeyConstraintFinder dbPrimaryKeyConstraintFinder = new DbPrimaryKeyConstraintFinder(db.database());
+ private final DdlChange underTest = new DropPrimaryKeyConstraintInIssuesImpactsTable(db.database(),
+ new DropPrimaryKeySqlGenerator(db.database(), dbPrimaryKeyConstraintFinder), dbPrimaryKeyConstraintFinder);
+
+ @Test
+ public void execute_shouldRemoveExistingPrimaryKey() throws SQLException {
+ db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
+ underTest.execute();
+ db.assertNoPrimaryKey(TABLE_NAME);
+ }
+
+ @Test
+ public void execute_when_reentrant_shouldRemoveExistingPrimaryKey() throws SQLException {
+ db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
+ underTest.execute();
+ underTest.execute();
+ db.assertNoPrimaryKey(TABLE_NAME);
+ }
+
+}
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT.java
new file mode 100644
index 00000000000..4dec602889d
--- /dev/null
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT.java
@@ -0,0 +1,57 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.MigrationDbTester;
+import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInRulesDefaultImpactsTable.COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInRulesDefaultImpactsTable.CONSTRAINT_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInRulesDefaultImpactsTable.TABLE_NAME;
+
+public class DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT {
+
+ @Rule
+ public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropPrimaryKeyConstraintInRulesDefaultImpactsTable.class);
+
+ private final DbPrimaryKeyConstraintFinder dbPrimaryKeyConstraintFinder = new DbPrimaryKeyConstraintFinder(db.database());
+ private final DdlChange underTest = new DropPrimaryKeyConstraintInRulesDefaultImpactsTable(db.database(),
+ new DropPrimaryKeySqlGenerator(db.database(), dbPrimaryKeyConstraintFinder), dbPrimaryKeyConstraintFinder);
+
+ @Test
+ public void execute_shouldRemoveExistingPrimaryKey() throws SQLException {
+ db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
+ underTest.execute();
+ db.assertNoPrimaryKey(TABLE_NAME);
+ }
+
+ @Test
+ public void execute_when_reentrant_shouldRemoveExistingPrimaryKey() throws SQLException {
+ db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
+ underTest.execute();
+ underTest.execute();
+ db.assertNoPrimaryKey(TABLE_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTableIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTableIT.java
new file mode 100644
index 00000000000..ae4dbce13aa
--- /dev/null
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTableIT.java
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.MigrationDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.version.v105.DropUuidColumnInIssuesImpactsTable.COLUMN_NAME;
+import static org.sonar.server.platform.db.migration.version.v105.DropUuidColumnInIssuesImpactsTable.TABLE_NAME;
+
+public class DropUuidColumnInIssuesImpactsTableIT {
+
+ @Rule
+ public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropUuidColumnInIssuesImpactsTable.class);
+ private final DdlChange underTest = new DropUuidColumnInIssuesImpactsTable(db.database());
+
+ @Test
+ public void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
+ underTest.execute();
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTableIT.java b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTableIT.java
new file mode 100644
index 00000000000..6428c67b0ab
--- /dev/null
+++ b/server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTableIT.java
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.MigrationDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropUuidColumnInRulesDefaultImpactsTableIT {
+ private static final String TABLE_NAME = "issues_impacts";
+ private static final String COLUMN_NAME = "uuid";
+
+ @Rule
+ public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropUuidColumnInIssuesImpactsTable.class);
+ private final DdlChange underTest = new DropUuidColumnInIssuesImpactsTable(db.database());
+
+ @Test
+ public void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+
+ @Test
+ public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
+ underTest.execute();
+ underTest.execute();
+ db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java
index dca450e7d82..946afd7fee1 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java
@@ -33,6 +33,7 @@ import org.sonar.server.platform.db.migration.version.v101.DbVersion101;
import org.sonar.server.platform.db.migration.version.v102.DbVersion102;
import org.sonar.server.platform.db.migration.version.v103.DbVersion103;
import org.sonar.server.platform.db.migration.version.v104.DbVersion104;
+import org.sonar.server.platform.db.migration.version.v105.DbVersion105;
public class MigrationConfigurationModule extends Module {
@Override
@@ -46,6 +47,7 @@ public class MigrationConfigurationModule extends Module {
DbVersion102.class,
DbVersion103.class,
DbVersion104.class,
+ DbVersion105.class,
// migration steps
MigrationStepRegistryImpl.class,
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRules.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRules.java
index 7f3b48b75ba..b53ac74af0d 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRules.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRules.java
@@ -30,11 +30,15 @@ import org.sonar.core.util.Uuids;
import org.sonar.db.Database;
import org.sonar.server.platform.db.migration.step.DataChange;
import org.sonar.server.platform.db.migration.step.MassUpdate;
+import org.sonar.server.platform.db.migration.step.Select;
public class PopulateDefaultImpactsInRules extends DataChange {
private static final Logger LOG = LoggerFactory.getLogger(PopulateDefaultImpactsInRules.class);
+ private static final String SELECT_COUNT_QUERY = """
+ SELECT COUNT(*) FROM rules_default_impacts
+ """;
private static final String SELECT_QUERY = """
SELECT r.uuid, rule_type, priority, ad_hoc_type, ad_hoc_severity, is_ad_hoc
FROM rules r
@@ -53,6 +57,9 @@ public class PopulateDefaultImpactsInRules extends DataChange {
@Override
protected void execute(Context context) throws SQLException {
+ if (hasImpactsRecords(context)) {
+ return;
+ }
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.select(SELECT_QUERY);
massUpdate.update(INSERT_QUERY);
@@ -105,4 +112,9 @@ public class PopulateDefaultImpactsInRules extends DataChange {
return true;
});
}
+
+ private static boolean hasImpactsRecords(Context context) throws SQLException {
+ Long recordNumber = context.prepareSelect(SELECT_COUNT_QUERY).get(Select.LONG_READER);
+ return recordNumber != null && recordNumber > 0;
+ }
}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTable.java
new file mode 100644
index 00000000000..96a9cfe5718
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnIssuesImpactsTable.java
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder;
+import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class CreatePrimaryKeyOnIssuesImpactsTable extends DdlChange {
+ @VisibleForTesting
+ static final String PK_NAME = "pk_issues_impacts";
+ @VisibleForTesting
+ static final String TABLE_NAME = "issues_impacts";
+ @VisibleForTesting
+ static final String ISSUE_KEY_COLUMN_NAME = "issue_key";
+ @VisibleForTesting
+ static final String SOFTWARE_QUALITY_COLUMN = "software_quality";
+
+
+ public CreatePrimaryKeyOnIssuesImpactsTable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(DdlChange.Context context) throws SQLException {
+ createPrimaryKey(context);
+ }
+
+ private void createPrimaryKey(DdlChange.Context context) throws SQLException {
+ boolean pkExists = new DbPrimaryKeyConstraintFinder(getDatabase()).findConstraintName(TABLE_NAME).isPresent();
+ if (!pkExists) {
+ context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, ISSUE_KEY_COLUMN_NAME, SOFTWARE_QUALITY_COLUMN).build());
+ }
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTable.java
new file mode 100644
index 00000000000..45ebad6c335
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/CreatePrimaryKeyOnRulesDefaultImpactsTable.java
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder;
+import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class CreatePrimaryKeyOnRulesDefaultImpactsTable extends DdlChange {
+ @VisibleForTesting
+ static final String PK_NAME = "pk_rules_default_impacts";
+ @VisibleForTesting
+ static final String TABLE_NAME = "rules_default_impacts";
+ @VisibleForTesting
+ static final String RULE_UUID_COLUMN_NAME = "rule_uuid";
+ @VisibleForTesting
+ static final String SOFTWARE_QUALITY_COLUMN = "software_quality";
+
+
+ public CreatePrimaryKeyOnRulesDefaultImpactsTable(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ createPrimaryKey(context);
+ }
+
+ private void createPrimaryKey(Context context) throws SQLException {
+ boolean pkExists = new DbPrimaryKeyConstraintFinder(getDatabase()).findConstraintName(TABLE_NAME).isPresent();
+ if (!pkExists) {
+ context.execute(new AddPrimaryKeyBuilder(TABLE_NAME, RULE_UUID_COLUMN_NAME, SOFTWARE_QUALITY_COLUMN).build());
+ }
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105.java
new file mode 100644
index 00000000000..71ab5344d87
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105.java
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+
+// ignoring bad number formatting, as it's indented that we align the migration numbers to SQ versions
+@SuppressWarnings("java:S3937")
+public class DbVersion105 implements DbVersion {
+
+ /**
+ * We use the start of the 10.X cycle as an opportunity to align migration numbers with the SQ version number.
+ * Please follow this pattern:
+ * 10_0_000
+ * 10_0_001
+ * 10_0_002
+ * 10_1_000
+ * 10_1_001
+ * 10_1_002
+ * 10_2_000
+ */
+
+ @Override
+ public void addSteps(MigrationStepRegistry registry) {
+ registry
+ .add(10_5_000, "Drop constraint on 'uuid' from 'issues_impacts' table", DropPrimaryKeyConstraintInIssuesImpactsTable.class)
+ .add(10_5_001, "Drop constraint on 'uuid' from 'rules_default_impacts' table", DropPrimaryKeyConstraintInRulesDefaultImpactsTable.class)
+ .add(10_5_002, "Drop column 'uuid' from 'issues_impacts' table", DropUuidColumnInIssuesImpactsTable.class)
+ .add(10_5_003, "Drop column 'uuid' from 'rules_default_impacts' table", DropUuidColumnInRulesDefaultImpactsTable.class)
+ .add(10_5_004, "Create primary key on 'issues_impacts' table", CreatePrimaryKeyOnIssuesImpactsTable.class)
+ .add(10_5_005, "Create primary key on 'rules_default_impacts' table", CreatePrimaryKeyOnRulesDefaultImpactsTable.class);
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTable.java
new file mode 100644
index 00000000000..8602e830f91
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInIssuesImpactsTable.java
@@ -0,0 +1,61 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Optional;
+import org.sonar.db.Database;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropPrimaryKeyConstraintInIssuesImpactsTable extends DdlChange {
+ @VisibleForTesting
+ static final String TABLE_NAME = "issues_impacts";
+ @VisibleForTesting
+ static final String COLUMN_NAME = "uuid";
+ @VisibleForTesting
+ static final String CONSTRAINT_NAME = "pk_issues_impacts";
+ private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
+ private final DbPrimaryKeyConstraintFinder dbConstraintFinder;
+
+ public DropPrimaryKeyConstraintInIssuesImpactsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator, DbPrimaryKeyConstraintFinder dbConstraintFinder) {
+ super(db);
+ this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
+ this.dbConstraintFinder = dbConstraintFinder;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ try (Connection connection = getDatabase().getDataSource().getConnection()) {
+ if (DatabaseUtils.tableColumnExists(connection, TABLE_NAME, COLUMN_NAME)) {
+ Optional<String> constraintName = dbConstraintFinder.findConstraintName(TABLE_NAME);
+ if (constraintName.isPresent() && constraintName.get().equalsIgnoreCase(CONSTRAINT_NAME)) {
+ List<String> statements = dropPrimaryKeySqlGenerator.generate(TABLE_NAME, COLUMN_NAME, false);
+ context.execute(statements);
+ }
+ }
+ }
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTable.java
new file mode 100644
index 00000000000..cc471247056
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropPrimaryKeyConstraintInRulesDefaultImpactsTable.java
@@ -0,0 +1,61 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Optional;
+import org.sonar.db.Database;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropPrimaryKeyConstraintInRulesDefaultImpactsTable extends DdlChange {
+ @VisibleForTesting
+ static final String TABLE_NAME = "rules_default_impacts";
+ @VisibleForTesting
+ static final String COLUMN_NAME = "uuid";
+ @VisibleForTesting
+ static final String CONSTRAINT_NAME = "pk_rules_default_impacts";
+ private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
+ private final DbPrimaryKeyConstraintFinder dbConstraintFinder;
+
+ public DropPrimaryKeyConstraintInRulesDefaultImpactsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator, DbPrimaryKeyConstraintFinder dbConstraintFinder) {
+ super(db);
+ this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
+ this.dbConstraintFinder = dbConstraintFinder;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ try (Connection connection = getDatabase().getDataSource().getConnection()) {
+ if (DatabaseUtils.tableColumnExists(connection, TABLE_NAME, COLUMN_NAME)) {
+ Optional<String> constraintName = dbConstraintFinder.findConstraintName(TABLE_NAME);
+ if (constraintName.isPresent() && constraintName.get().equalsIgnoreCase(CONSTRAINT_NAME)) {
+ List<String> statements = dropPrimaryKeySqlGenerator.generate(TABLE_NAME, COLUMN_NAME, false);
+ context.execute(statements);
+ }
+ }
+ }
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTable.java
new file mode 100644
index 00000000000..c158193df58
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInIssuesImpactsTable.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import com.google.common.annotations.VisibleForTesting;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropUuidColumnInIssuesImpactsTable extends DropColumnChange {
+ @VisibleForTesting
+ static final String COLUMN_NAME = "uuid";
+ @VisibleForTesting
+ static final String TABLE_NAME = "issues_impacts";
+
+ protected DropUuidColumnInIssuesImpactsTable(Database db) {
+ super(db, TABLE_NAME, COLUMN_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTable.java
new file mode 100644
index 00000000000..6cbc8ceb531
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/DropUuidColumnInRulesDefaultImpactsTable.java
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DropColumnChange;
+
+public class DropUuidColumnInRulesDefaultImpactsTable extends DropColumnChange {
+ private static final String COLUMN_NAME = "uuid";
+ private static final String TABLE_NAME = "rules_default_impacts";
+
+ protected DropUuidColumnInRulesDefaultImpactsTable(Database db) {
+ super(db, TABLE_NAME, COLUMN_NAME);
+ }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/package-info.java
new file mode 100644
index 00000000000..e4768ed1a05
--- /dev/null
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v105/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.platform.db.migration.version.v105;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105Test.java
new file mode 100644
index 00000000000..b58181e8861
--- /dev/null
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v105/DbVersion105Test.java
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 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.v105;
+
+import org.junit.Test;
+
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty;
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber;
+
+public class DbVersion105Test {
+
+ private final DbVersion105 underTest = new DbVersion105();
+
+ @Test
+ public void migrationNumber_starts_at_10_5_000() {
+ verifyMinimumMigrationNumber(underTest, 10_5_000);
+ }
+
+ @Test
+ public void verify_migration_is_not_empty() {
+ verifyMigrationNotEmpty(underTest);
+ }
+
+}
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java
index c365acd4b36..a7be47d330e 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexIT.java
@@ -807,7 +807,7 @@ public class RuleIndexIT {
@Test
public void search_by_software_quality() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
RuleDto phpRule = createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
index();
@@ -822,7 +822,7 @@ public class RuleIndexIT {
@Test
public void search_by_severity() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
RuleDto phpRule = createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
index();
@@ -867,8 +867,8 @@ public class RuleIndexIT {
@Test
public void search_should_support_software_quality_facet() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
- ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW).setUuid("uuid2");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
+ ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW);
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto2)));
index();
@@ -887,8 +887,8 @@ public class RuleIndexIT {
@Test
public void search_should_support_software_quality_facet_with_filtering() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
- ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW).setUuid("uuid2");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
+ ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW);
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto2)));
index();
@@ -907,9 +907,9 @@ public class RuleIndexIT {
@Test
public void search_whenFilteringOnSeverityAndSoftwareQuality_shouldReturnFacet() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH).setUuid("uuid");
- ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW).setUuid("uuid2");
- ImpactDto impactDto3 = new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.LOW).setUuid("uuid3");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH);
+ ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW);
+ ImpactDto impactDto3 = new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.LOW);
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto2, impactDto3)));
index();
@@ -936,8 +936,8 @@ public class RuleIndexIT {
@Test
public void search_should_support_severity_facet() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
- ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW).setUuid("uuid2");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
+ ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW);
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto2)));
index();
@@ -952,8 +952,8 @@ public class RuleIndexIT {
@Test
public void search_should_support_severity_facet_with_filters() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
- ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW).setUuid("uuid2");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
+ ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW);
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto2)));
index();
@@ -968,8 +968,8 @@ public class RuleIndexIT {
@Test
public void search_should_support_software_quality_and_severity_facets_with_filtering() {
- ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH).setUuid("uuid");
- ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW).setUuid("uuid2");
+ ImpactDto impactDto = new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(Severity.HIGH);
+ ImpactDto impactDto2 = new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.LOW);
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto)));
createRule(setRepositoryKey("php"), setImpacts(List.of(impactDto2)));
index();
diff --git a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/rule/RuleCreator.java b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/rule/RuleCreator.java
index 167c6d3410a..90513cf5687 100644
--- a/server/sonar-webserver-common/src/main/java/org/sonar/server/common/rule/RuleCreator.java
+++ b/server/sonar-webserver-common/src/main/java/org/sonar/server/common/rule/RuleCreator.java
@@ -242,7 +242,7 @@ public class RuleCreator {
if (!CollectionUtils.isEmpty(newRule.getImpacts())) {
newRule.getImpacts().stream()
- .map(impact -> new ImpactDto(uuidFactory.create(), impact.softwareQuality(), impact.severity()))
+ .map(impact -> new ImpactDto(impact.softwareQuality(), impact.severity()))
.forEach(ruleDto::addDefaultImpact);
// Back-map old type and severity from the impact
Map.Entry<SoftwareQuality, org.sonar.api.issue.impact.Severity> impact = ImpactMapper.getBestImpactForBackmapping(
@@ -253,7 +253,7 @@ public class RuleCreator {
// Map old type and severity to impact
SoftwareQuality softwareQuality = ImpactMapper.convertToSoftwareQuality(RuleType.valueOf(type));
org.sonar.api.issue.impact.Severity impactSeverity = ImpactMapper.convertToImpactSeverity(severity);
- ruleDto.addDefaultImpact(new ImpactDto().setUuid(uuidFactory.create())
+ ruleDto.addDefaultImpact(new ImpactDto()
.setSoftwareQuality(softwareQuality)
.setSeverity(impactSeverity))
.setType(type)
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/NewRuleCreator.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/NewRuleCreator.java
index 3e6f5d392fb..49664e6d51b 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/NewRuleCreator.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/NewRuleCreator.java
@@ -79,7 +79,7 @@ public class NewRuleCreator {
ruleDto.setCleanCodeAttribute(cleanCodeAttribute != null ? cleanCodeAttribute : CleanCodeAttribute.defaultCleanCodeAttribute());
ruleDto.replaceAllDefaultImpacts(ruleDef.defaultImpacts().entrySet()
.stream()
- .map(e -> new ImpactDto().setUuid(uuidFactory.create()).setSoftwareQuality(e.getKey()).setSeverity(e.getValue()))
+ .map(e -> new ImpactDto().setSoftwareQuality(e.getKey()).setSeverity(e.getValue()))
.collect(Collectors.toSet()));
}
diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/StartupRuleUpdater.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/StartupRuleUpdater.java
index 20f42ac2a16..80c41708866 100644
--- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/StartupRuleUpdater.java
+++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/StartupRuleUpdater.java
@@ -203,7 +203,7 @@ public class StartupRuleUpdater {
if (!Objects.equals(impactsFromDb, impactsFromPlugin)) {
dto.replaceAllDefaultImpacts(impactsFromPlugin.entrySet()
.stream()
- .map(e -> new ImpactDto().setUuid(uuidFactory.create()).setSoftwareQuality(e.getKey()).setSeverity(e.getValue()))
+ .map(e -> new ImpactDto().setSoftwareQuality(e.getKey()).setSeverity(e.getValue()))
.collect(Collectors.toSet()));
ruleChange.addImpactsChange(removeDuplicatedImpacts(impactsFromDb, impactsFromPlugin), removeDuplicatedImpacts(impactsFromPlugin, impactsFromDb));
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/StartupRuleUpdaterTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/StartupRuleUpdaterTest.java
index 15cb04a3e5f..f6583588583 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/StartupRuleUpdaterTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/StartupRuleUpdaterTest.java
@@ -34,8 +34,8 @@ import org.sonar.db.DbClient;
import org.sonar.db.issue.ImpactDto;
import org.sonar.db.rule.RuleDto;
import org.sonar.server.rule.RuleDescriptionSectionsGeneratorResolver;
+
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -58,7 +58,7 @@ public class StartupRuleUpdaterTest {
RuleDto rule = getDefaultRuleDto();
when(rule.getCleanCodeAttribute()).thenReturn(CleanCodeAttribute.COMPLETE);
- Set<ImpactDto> oldImpacts = Set.of(new ImpactDto("uuid", SoftwareQuality.RELIABILITY, Severity.LOW));
+ Set<ImpactDto> oldImpacts = Set.of(new ImpactDto(SoftwareQuality.RELIABILITY, Severity.LOW));
when(rule.getDefaultImpacts()).thenReturn(oldImpacts);
StartupRuleUpdater.RuleChange changesAndUpdateRule = underTest.findChangesAndUpdateRule(ruleDef, rule);
@@ -79,9 +79,8 @@ public class StartupRuleUpdaterTest {
RuleDto rule = getDefaultRuleDto();
when(rule.getCleanCodeAttribute()).thenReturn(CleanCodeAttribute.COMPLETE);
- Set<ImpactDto> oldImpacts = Set.of(new ImpactDto("uuid",
- SoftwareQuality.RELIABILITY, Severity.LOW),
- new ImpactDto("uuid2", SoftwareQuality.SECURITY, Severity.HIGH));
+ Set<ImpactDto> oldImpacts = Set.of(new ImpactDto(SoftwareQuality.RELIABILITY, Severity.LOW),
+ new ImpactDto(SoftwareQuality.SECURITY, Severity.HIGH));
when(rule.getDefaultImpacts()).thenReturn(oldImpacts);
StartupRuleUpdater.RuleChange changesAndUpdateRule = underTest.findChangesAndUpdateRule(ruleDef, rule);
@@ -100,8 +99,7 @@ public class StartupRuleUpdaterTest {
RuleDto rule = getDefaultRuleDto();
when(rule.getCleanCodeAttribute()).thenReturn(CleanCodeAttribute.COMPLETE);
- Set<ImpactDto> oldImpacts = Set.of(new ImpactDto("uuid",
- SoftwareQuality.MAINTAINABILITY, Severity.LOW));
+ Set<ImpactDto> oldImpacts = Set.of(new ImpactDto(SoftwareQuality.MAINTAINABILITY, Severity.LOW));
when(rule.getDefaultImpacts()).thenReturn(oldImpacts);
StartupRuleUpdater.RuleChange changesAndUpdateRule = underTest.findChangesAndUpdateRule(ruleDef, rule);
@@ -123,4 +121,4 @@ public class StartupRuleUpdaterTest {
when(ruleDto.getScope()).thenReturn(RuleDto.Scope.TEST);
return ruleDto;
}
-} \ No newline at end of file
+}
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
index 9060e79de8f..856923416cb 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/issue/ws/SearchActionIT.java
@@ -686,13 +686,13 @@ public class SearchActionIT {
c -> c.setKey("PROJECT_KEY").setName("NAME_PROJECT_ID").setLongName("LONG_NAME_PROJECT_ID").setLanguage("java")).getMainBranchComponent();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
IssueDto issue1 = db.issues().insertIssue(rule, project, file, i -> i
- .addImpact(new ImpactDto(uuidFactory.create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH))
- .addImpact(new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH)));
+ .addImpact(new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH))
+ .addImpact(new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH)));
IssueDto issue2 = db.issues().insertIssue(rule, project, file, i -> i
- .addImpact(new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH)));
+ .addImpact(new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH)));
IssueDto issue3 = db.issues().insertIssue(rule, project, file, i -> i
- .addImpact(new ImpactDto(uuidFactory.create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.MEDIUM))
- .addImpact(new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW)));
+ .addImpact(new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.MEDIUM))
+ .addImpact(new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW)));
indexPermissionsAndIssues();
SearchWsResponse response = ws.newRequest()
@@ -722,13 +722,13 @@ public class SearchActionIT {
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
IssueDto issue1 = db.issues().insertIssue(rule, project, file, i -> i
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH).setUuid(uuidFactory.create()))
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH).setUuid(uuidFactory.create())));
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH))
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH)));
IssueDto issue2 = db.issues().insertIssue(rule, project, file, i -> i
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH).setUuid(uuidFactory.create())));
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.HIGH)));
IssueDto issue3 = db.issues().insertIssue(rule, project, file, i -> i
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(org.sonar.api.issue.impact.Severity.MEDIUM).setUuid(uuidFactory.create()))
- .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.LOW).setUuid(uuidFactory.create())));
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.SECURITY).setSeverity(org.sonar.api.issue.impact.Severity.MEDIUM))
+ .addImpact(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(org.sonar.api.issue.impact.Severity.LOW)));
indexPermissionsAndIssues();
Map<Common.SoftwareQuality, Common.ImpactSeverity> expectedImpacts = Map.of(Common.SoftwareQuality.SECURITY, Common.ImpactSeverity.MEDIUM,
Common.SoftwareQuality.RELIABILITY, Common.ImpactSeverity.LOW,
@@ -769,14 +769,14 @@ public class SearchActionIT {
c -> c.setKey("PROJECT_KEY").setName("NAME_PROJECT_ID").setLongName("LONG_NAME_PROJECT_ID").setLanguage("java")).getMainBranchComponent();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
IssueDto issue1 = db.issues().insertIssue(rule, project, file, i -> i.replaceAllImpacts(List.of(
- new ImpactDto(uuidFactory.create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH),
- new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
+ new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH),
+ new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
IssueDto issue2 = db.issues().insertIssue(rule, project, file, i -> i.replaceAllImpacts(List.of(
- new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
+ new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
IssueDto issue3 = db.issues().insertIssue(rule, project, file, i -> i.replaceAllImpacts(List.of(
- new ImpactDto(uuidFactory.create(), SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.LOW),
- new ImpactDto(uuidFactory.create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.MEDIUM),
- new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW))));
+ new ImpactDto(SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.LOW),
+ new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.MEDIUM),
+ new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW))));
indexPermissionsAndIssues();
SearchWsResponse response = ws.newRequest()
@@ -805,14 +805,14 @@ public class SearchActionIT {
c -> c.setKey("PROJECT_KEY").setName("NAME_PROJECT_ID").setLongName("LONG_NAME_PROJECT_ID").setLanguage("java")).getMainBranchComponent();
ComponentDto file = db.components().insertComponent(newFileDto(project, null, "FILE_ID").setKey("FILE_KEY").setLanguage("java"));
IssueDto issue1 = db.issues().insertIssue(rule, project, file, i -> i.replaceAllImpacts(List.of(
- new ImpactDto(uuidFactory.create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH),
- new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
+ new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH),
+ new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
db.issues().insertIssue(rule, project, file, i -> i.replaceAllImpacts(List.of(
- new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
+ new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.HIGH))));
IssueDto issue3 = db.issues().insertIssue(rule, project, file, i -> i.replaceAllImpacts(List.of(
- new ImpactDto(uuidFactory.create(), SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.LOW),
- new ImpactDto(uuidFactory.create(), SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.MEDIUM),
- new ImpactDto(uuidFactory.create(), SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW))));
+ new ImpactDto(SoftwareQuality.MAINTAINABILITY, org.sonar.api.issue.impact.Severity.LOW),
+ new ImpactDto(SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.MEDIUM),
+ new ImpactDto(SoftwareQuality.RELIABILITY, org.sonar.api.issue.impact.Severity.LOW))));
indexPermissionsAndIssues();
SearchWsResponse response = ws.newRequest()
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java
index 328812ed803..ac4918b6b0f 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/ChangelogActionIT.java
@@ -452,7 +452,7 @@ public class ChangelogActionIT {
system2.setNow(DateUtils.parseDateTime("2015-02-23T17:58:39+0100").getTime());
RuleDto rule1 = db.rules().insert(RuleKey.of("java", "S2438"), r -> r.setName("\"Threads\" should not be used where \"Runnables\" are expected")
- .addDefaultImpact(new ImpactDto(Uuids.createFast(), SECURITY, LOW)));
+ .addDefaultImpact(new ImpactDto(SECURITY, LOW)));
UserDto user1 = db.users().insertUser(u -> u.setLogin("anakin.skywalker").setName("Anakin Skywalker"));
insertChange(c -> c.setRulesProfileUuid(profileUuid)
.setUserUuid(user1.getUuid())
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CompareActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CompareActionIT.java
index 173cd139af6..ce2dd1cea50 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CompareActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/CompareActionIT.java
@@ -233,7 +233,7 @@ public class CompareActionIT {
.setScope(Scope.MAIN)
.setStatus(RuleStatus.READY)
.setCleanCodeAttribute(CleanCodeAttribute.EFFICIENT)
- .addDefaultImpact(new ImpactDto(Uuids.createFast(), SoftwareQuality.RELIABILITY, HIGH));
+ .addDefaultImpact(new ImpactDto(SoftwareQuality.RELIABILITY, HIGH));
RuleDto ruleDto = rule;
dbClient.ruleDao().insert(session, ruleDto);
return ruleDto;
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java
index 5e9ce8accf1..8d25bc05a23 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/RuleUpdaterIT.java
@@ -38,7 +38,6 @@ import org.sonar.api.server.debt.DebtRemediationFunction;
import org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactoryFast;
-import org.sonar.core.util.Uuids;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import org.sonar.db.issue.ImpactDto;
@@ -344,7 +343,7 @@ public class RuleUpdaterIT {
RuleDto customRule = newCustomRule(templateRule, "Old description")
.setName("Old name")
.setType(RuleType.CODE_SMELL)
- .replaceAllDefaultImpacts(List.of(new ImpactDto().setUuid(Uuids.createFast())
+ .replaceAllDefaultImpacts(List.of(new ImpactDto()
.setSoftwareQuality(SoftwareQuality.MAINTAINABILITY)
.setSeverity(org.sonar.api.issue.impact.Severity.LOW)))
.setSeverity(Severity.MINOR)
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
index ae606fc543b..2cb0ccec836 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java
@@ -50,7 +50,6 @@ import org.sonar.api.utils.Version;
import org.sonar.core.platform.SonarQubeVersion;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
-import org.sonar.core.util.Uuids;
import org.sonar.db.DbTester;
import org.sonar.db.issue.ImpactDto;
import org.sonar.db.qualityprofile.ActiveRuleParamDto;
@@ -482,9 +481,9 @@ public class SearchActionIT {
@Test
public void execute_whenFacetIsSoftwareQuality_shouldReturnCorrectMatch() {
db.rules().insert(
- r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH))));
+ r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH))));
db.rules().insert(
- r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.MEDIUM))));
+ r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.MEDIUM))));
indexRules();
SearchResponse result = ws.newRequest()
@@ -498,9 +497,9 @@ public class SearchActionIT {
@Test
public void execute_whenFacetIsImpactSeverity_shouldReturnCorrectMatch() {
db.rules().insert(
- r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH))));
+ r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setSoftwareQuality(SoftwareQuality.MAINTAINABILITY).setSeverity(Severity.HIGH))));
db.rules().insert(
- r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.MEDIUM))));
+ r -> r.replaceAllDefaultImpacts(List.of(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.MEDIUM))));
indexRules();
SearchResponse result = ws.newRequest()
@@ -515,7 +514,7 @@ public class SearchActionIT {
public void execute_whenFacetIsCleanCodeAttributeCategories_shouldReturnCorrectMatch() {
db.rules().insert(
r -> r.setCleanCodeAttribute(CleanCodeAttribute.COMPLETE)
- .replaceAllDefaultImpacts(List.of(new ImpactDto().setUuid(Uuids.createFast()).setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.HIGH))));
+ .replaceAllDefaultImpacts(List.of(new ImpactDto().setSoftwareQuality(SoftwareQuality.RELIABILITY).setSeverity(Severity.HIGH))));
db.rules().insert(
r -> r.setCleanCodeAttribute(CleanCodeAttribute.CONVENTIONAL));
indexRules();