]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19197 Support code variants in project import/export
authorEric Giffon <eric.giffon@sonarsource.com>
Wed, 10 May 2023 10:35:19 +0000 (12:35 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 16 May 2023 20:02:49 +0000 (20:02 +0000)
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
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

index 014ad779980cbafb9c2ffcf0f03bae47ed6876ac..af669dcc2601f9be64d805b43c63016696120318 100644 (file)
@@ -27,6 +27,7 @@ import com.tngtech.java.junit.dataprovider.UseDataProvider;
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.util.List;
 import java.util.Random;
 import org.apache.commons.io.FileUtils;
 import org.junit.After;
@@ -228,7 +229,8 @@ public class ExportIssuesStepIT {
       .setRuleDescriptionContextKey("test_rule_description_context_key")
       .setIssueCreationTime(963L)
       .setIssueUpdateTime(852L)
-      .setIssueCloseTime(741L);
+      .setIssueCloseTime(741L)
+      .setCodeVariants(List.of("v1", "v2"));
 
     // fields tested separately and/or required to match SQL request
     issueDto
@@ -265,6 +267,7 @@ public class ExportIssuesStepIT {
     assertThat(issue.getLocations()).isNotEmpty();
     assertThat(issue.getMessageFormattingsList())
       .isEqualTo(ExportIssuesStep.dbToDumpMessageFormatting(messageFormattings.getMessageFormattingList()));
+    assertThat(issue.getCodeVariants()).isEqualTo(issueDto.getCodeVariantsString());
   }
 
   @Test
index 4331ea365988b15f1c53b73f23c0384415b6860d..17655c74112595e94559a60301009056f78b8336 100644 (file)
@@ -60,7 +60,7 @@ public class ExportIssuesStep implements ComputationStep {
     " 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.rule_description_context_key, i.message_formattings " +
+    " i.rule_description_context_key, i.message_formattings, i.code_variants " +
     " from issues i" +
     " join rules r on r.uuid = i.rule_uuid and r.status <> ?" +
     " join components p on p.uuid = i.project_uuid" +
@@ -147,7 +147,8 @@ public class ExportIssuesStep implements ComputationStep {
       .setIssueCreatedAt(rs.getLong(19))
       .setIssueUpdatedAt(rs.getLong(20))
       .setIssueClosedAt(rs.getLong(21))
-      .setProjectUuid(rs.getString(23));
+      .setProjectUuid(rs.getString(23))
+      .setCodeVariants(emptyIfNull(rs, 26));
     Optional.ofNullable(rs.getString(24)).ifPresent(builder::setRuleDescriptionContextKey);
     setLocations(builder, rs, issueUuid);
     setMessageFormattings(builder, rs, issueUuid);
index d18b27cd1df434ac699adea954a77564c2528093..91a9495631cb704e89246ab35c5436d36b84c17a 100644 (file)
@@ -126,6 +126,7 @@ message Issue {
   optional string ruleDescriptionContextKey = 24;
 
   repeated MessageFormatting messageFormattings = 25;
+  string codeVariants = 26;
 }
 
 // Stream of issues changelog stored in file issues_changelog.pb