]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3321 IssueMapper#updateIfBeforeSelectedDate updates componentUuid
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 27 May 2016 14:10:24 +0000 (16:10 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 2 Jun 2016 08:37:54 +0000 (10:37 +0200)
this is now possible because issues can move from one component to another if a file move has been detected

sonar-db/src/main/java/org/sonar/db/issue/IssueDto.java
sonar-db/src/main/resources/org/sonar/db/issue/IssueMapper.xml
sonar-db/src/test/java/org/sonar/db/issue/IssueMapperTest.java

index 0f753731ac12ff321c1850a8eba3900ce8a9e782..2647192eeacac7371fef4716956dddca8aa36626 100644 (file)
@@ -122,7 +122,6 @@ public final class IssueDto implements Serializable {
       .setComponentKey(issue.componentKey())
       .setModuleUuid(issue.moduleUuid())
       .setModuleUuidPath(issue.moduleUuidPath())
-      .setComponentUuid(issue.componentUuid())
       .setProjectUuid(issue.projectUuid())
       .setProjectKey(issue.projectKey())
       .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
index cc440f77446fd65f7c0b298c5f78485a31d6753c..2888c9aa272a12d6589c2092038776fbd12567b9 100644 (file)
     assignee=#{assignee,jdbcType=VARCHAR},
     author_login=#{authorLogin,jdbcType=VARCHAR},
     tags=#{tagsString,jdbcType=VARCHAR},
+    component_uuid=#{componentUuid,jdbcType=VARCHAR},
     project_uuid=#{projectUuid,jdbcType=VARCHAR},
     issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
     issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
index 8c3da1c63ff73fdbd5a021b5664364aa6aac3f77..20aec627ab33ccb03d0e3878a574381af64cd0b8 100644 (file)
@@ -41,7 +41,7 @@ public class IssueMapperTest {
 
   IssueMapper underTest = dbSession.getMapper(IssueMapper.class);
 
-  ComponentDto project, file;
+  ComponentDto project, file, file2;
   RuleDto rule;
 
   @Before
@@ -50,6 +50,8 @@ public class IssueMapperTest {
     dbTester.getDbClient().componentDao().insert(dbSession, project);
     file = ComponentTesting.newFileDto(project);
     dbTester.getDbClient().componentDao().insert(dbSession, file);
+    file2 = ComponentTesting.newFileDto(project).setUuid("file2 uuid");
+    dbTester.getDbClient().componentDao().insert(dbSession, file2);
     rule = RuleTesting.newXooX1();
     dbTester.getDbClient().ruleDao().insert(dbSession, rule);
     dbSession.commit();
@@ -94,7 +96,7 @@ public class IssueMapperTest {
 
     IssueDto update = new IssueDto();
     update.setKee("ABCDE");
-    update.setComponentUuid(file.uuid());
+    update.setComponentUuid("other component uuid");
     update.setProjectUuid(project.uuid());
     update.setRuleId(rule.getId());
     update.setType(3);
@@ -151,6 +153,7 @@ public class IssueMapperTest {
     underTest.insert(newIssue());
 
     IssueDto dto = newIssue()
+      .setComponentUuid(file2.uuid())
       .setType(3)
       .setLine(600)
       .setGap(1.12d)
@@ -167,6 +170,7 @@ public class IssueMapperTest {
 
     IssueDto result = underTest.selectByKey("ABCDE");
     assertThat(result).isNotNull();
+    assertThat(result.getComponentUuid()).isEqualTo(file2.uuid());
     assertThat(result.getType()).isEqualTo(3);
     assertThat(result.getLine()).isEqualTo(600);
     assertThat(result.getGap()).isEqualTo(1.12d);
@@ -180,6 +184,7 @@ public class IssueMapperTest {
     underTest.insert(newIssue());
 
     IssueDto dto = newIssue()
+        .setComponentUuid(file2.uuid())
       .setType(3)
       .setLine(600)
       .setGap(1.12d)
@@ -197,6 +202,7 @@ public class IssueMapperTest {
     // No change
     IssueDto result = underTest.selectByKey("ABCDE");
     assertThat(result).isNotNull();
+    assertThat(result.getComponentUuid()).isEqualTo(file.uuid());
     assertThat(result.getType()).isEqualTo(2);
     assertThat(result.getLine()).isEqualTo(500);
     assertThat(result.getGap()).isEqualTo(3.14d);