]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16611 Adapt project import/export to handle DB field issues.rule_description_co...
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Wed, 6 Jul 2022 13:36:01 +0000 (15:36 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 8 Jul 2022 20:02:48 +0000 (20:02 +0000)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java
server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepTest.java

index 0351bd6c1a0d8c6335efebca5da96e042a51093b..b34a38d220b1a55a703f5887abf7c991d851b390 100644 (file)
@@ -26,6 +26,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Objects;
+import java.util.Optional;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.ce.task.projectexport.component.ComponentRepository;
@@ -56,7 +57,8 @@ public class ExportIssuesStep implements ComputationStep {
     " i.component_uuid, i.message, i.line, i.checksum, i.status," +
     " i.resolution, i.severity, i.manual_severity, i.gap, effort," +
     " i.assignee, i.author_login, i.tags, i.issue_creation_date," +
-    " i.issue_update_date, i.issue_close_date, i.locations, i.project_uuid" +
+    " i.issue_update_date, i.issue_close_date, i.locations, i.project_uuid," +
+    " i.rule_description_context_key " +
     " from issues i" +
     " join rules r on r.uuid = i.rule_uuid and r.status <> ?" +
     " join components p on p.uuid = i.project_uuid" +
@@ -144,6 +146,7 @@ public class ExportIssuesStep implements ComputationStep {
       .setIssueUpdatedAt(rs.getLong(20))
       .setIssueClosedAt(rs.getLong(21))
       .setProjectUuid(rs.getString(23));
+    Optional.ofNullable(rs.getString(24)).ifPresent(builder::setRuleDescriptionContextKey);
     setLocations(builder, rs, issueUuid);
     return builder.build();
   }
index 358d1041e0b2bd03ebb407167e7ae9d65aefac83..b1e5066d8fefe6e4e89bb28fec3d683fd4b166a7 100644 (file)
@@ -121,6 +121,8 @@ message Issue {
   int64 issue_closed_at = 21;
   string project_uuid = 22;
   string rule_ref = 23;
+
+  optional string ruleDescriptionContextKey = 24;
 }
 
 // Stream of issues changelog stored in file issues_changelog.pb
index 0eccab91c481ab88fb9267ab9e3a1cc494edc179..437996f023f0610e97523822c09d8f197ff37d7f 100644 (file)
@@ -219,6 +219,7 @@ public class ExportIssuesStepTest {
       .setAssigneeUuid("assignee-uuid")
       .setAuthorLogin("author")
       .setTagsString("tags")
+      .setRuleDescriptionContextKey("test_rule_description_context_key")
       .setIssueCreationTime(963L)
       .setIssueUpdateTime(852L)
       .setIssueCloseTime(741L);
@@ -251,6 +252,7 @@ public class ExportIssuesStepTest {
     assertThat(issue.getAssignee()).isEqualTo(issueDto.getAssigneeUuid());
     assertThat(issue.getAuthor()).isEqualTo(issueDto.getAuthorLogin());
     assertThat(issue.getTags()).isEqualTo(issueDto.getTagsString());
+    assertThat(issue.getRuleDescriptionContextKey()).isEqualTo(issue.getRuleDescriptionContextKey());
     assertThat(issue.getIssueCreatedAt()).isEqualTo(issueDto.getIssueCreationTime());
     assertThat(issue.getIssueUpdatedAt()).isEqualTo(issueDto.getIssueUpdateTime());
     assertThat(issue.getIssueClosedAt()).isEqualTo(issueDto.getIssueCloseTime());
@@ -271,6 +273,7 @@ public class ExportIssuesStepTest {
     assertThat(issue.getIssueCreatedAt()).isEqualTo(DumpElement.NO_DATETIME);
     assertThat(issue.getIssueUpdatedAt()).isEqualTo(DumpElement.NO_DATETIME);
     assertThat(issue.getIssueClosedAt()).isEqualTo(DumpElement.NO_DATETIME);
+    assertThat(issue.hasRuleDescriptionContextKey()).isFalse();
   }
 
   @Test