]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6013 Return severity, manualSeverity and creationDate
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 23 Jan 2015 13:59:40 +0000 (14:59 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 23 Jan 2015 14:32:05 +0000 (15:32 +0100)
12 files changed:
server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java
server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/db/IssueDaoTest.java
server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/issues_on_module-expected.json
server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/issues_on_project-expected.json
server/sonar-server/src/test/resources/org/sonar/server/batch/IssuesActionTest/return_only_manual_severity-expected.json
sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/issues/PreviousIssue.java
sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/issues/PreviousIssueHelperTest.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
sonar-batch/src/test/java/org/sonar/batch/mediumtest/issues/ReportsMediumTest.java
sonar-core/src/main/java/org/sonar/core/issue/db/BatchIssueDto.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml

index b8dc23cee32e1d69b991a88f3eccdc33f756a1b2..d3a26ebaff0906e3b2f74fbe1cfa1fff1746b1fc 100644 (file)
@@ -118,8 +118,10 @@ public class IssuesAction implements RequestHandler {
           .setRuleKey(batchIssueDto.getRuleRepo(), batchIssueDto.getRuleKey())
           .setMessage(batchIssueDto.getMessage())
           .setResolution(batchIssueDto.getResolution())
-          .setOverriddenSeverity(batchIssueDto.isManualSeverity() ? batchIssueDto.getSeverity() : null)
-          .setStatus(batchIssueDto.getStatus());
+          .setSeverity(batchIssueDto.getSeverity())
+          .setManualSeverity(batchIssueDto.isManualSeverity())
+          .setStatus(batchIssueDto.getStatus())
+          .setCreationDate(batchIssueDto.getCreationDate());
       }
       return null;
     }
index bd70521030860472fc4181286a6d869481aac9e2..f7db3d0126b1570afdece6f490d19ae5d178ae45 100644 (file)
@@ -80,7 +80,7 @@ public class IssuesActionTest {
     MockUserSession.set().setLogin("henry").setGlobalPermissions(GlobalPermissions.PREVIEW_EXECUTION).addComponentPermission(UserRole.USER, PROJECT_KEY, PROJECT_KEY);
 
     WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", PROJECT_KEY);
-    request.execute().assertJson(getClass(), "issues_on_project-expected.json");
+    request.execute().assertJson(getClass(), "issues_on_project-expected.json", false);
   }
 
   @Test
@@ -90,7 +90,7 @@ public class IssuesActionTest {
     MockUserSession.set().setLogin("henry").setGlobalPermissions(GlobalPermissions.PREVIEW_EXECUTION).addComponentPermission(UserRole.USER, PROJECT_KEY, PROJECT_KEY);
 
     WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", PROJECT_KEY);
-    request.execute().assertJson(getClass(), "return_only_manual_severity-expected.json");
+    request.execute().assertJson(getClass(), "return_only_manual_severity-expected.json", false);
   }
 
   @Test
@@ -100,7 +100,7 @@ public class IssuesActionTest {
     MockUserSession.set().setLogin("henry").setGlobalPermissions(GlobalPermissions.PREVIEW_EXECUTION).addComponentPermission(UserRole.USER, PROJECT_KEY, MODULE_KEY);
 
     WsTester.TestRequest request = tester.newGetRequest("batch", "issues").setParam("key", MODULE_KEY);
-    request.execute().assertJson(getClass(), "issues_on_module-expected.json");
+    request.execute().assertJson(getClass(), "issues_on_module-expected.json", false);
   }
 
   @Test(expected = ForbiddenException.class)
index 0b6c5b2f4fb3780ec0ead176514aad29ca89b56c..0a51301d34ae42519b31eb07201323951e2dac7a 100644 (file)
@@ -161,6 +161,7 @@ public class IssueDaoTest extends AbstractDaoTestCase {
     assertThat(batchIssueDto.getComponentKey()).isEqualTo("Sample.java");
     assertThat(batchIssueDto.getChecksum()).isEqualTo("123456");
     assertThat(batchIssueDto.getAssigneeLogin()).isEqualTo("john");
+    assertThat(batchIssueDto.getCreationDate()).isNotNull();
   }
 
   @Test
@@ -190,6 +191,7 @@ public class IssueDaoTest extends AbstractDaoTestCase {
     assertThat(batchIssueDto.getComponentKey()).isEqualTo("Sample.java");
     assertThat(batchIssueDto.getChecksum()).isEqualTo("123456");
     assertThat(batchIssueDto.getAssigneeLogin()).isEqualTo("john");
+    assertThat(batchIssueDto.getCreationDate()).isNotNull();
   }
 
   @Test
index a19dad630434953a28665713b130904bf3961880..12bf1eae5e323a2235d2a4951afe72752f946fbc 100644 (file)
@@ -8,6 +8,8 @@
     "message": "Do not use this method",
     "resolution": "FALSE-POSITIVE",
     "status": "RESOLVED",
+    "severity": "BLOCKER",
+    "manualSeverity": false,
     "checksum": "123456",
     "assigneeLogin": "john"
   }
index a19dad630434953a28665713b130904bf3961880..12bf1eae5e323a2235d2a4951afe72752f946fbc 100644 (file)
@@ -8,6 +8,8 @@
     "message": "Do not use this method",
     "resolution": "FALSE-POSITIVE",
     "status": "RESOLVED",
+    "severity": "BLOCKER",
+    "manualSeverity": false,
     "checksum": "123456",
     "assigneeLogin": "john"
   }
index 3716f04e9f2b4daee6c075839177521f2cb1e34f..d95db3a786deaf9e92efb636a201a4f6efdbada5 100644 (file)
@@ -7,7 +7,8 @@
     "line": 201,
     "message": "Do not use this method",
     "status": "OPEN",
-    "overriddenSeverity": "CRITICAL",
+    "severity": "CRITICAL",
+    "manualSeverity": true,
     "checksum": "234567",
     "assigneeLogin": "john"
   }
index 10f44f1e39018739a9443a12a62cc966a8de86f7..8239717deb0c62e01d2055061f04d5f5f52a58bc 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.batch.protocol.input.issues;
 import javax.annotation.Nullable;
 
 import java.io.Serializable;
+import java.util.Date;
 
 public class PreviousIssue implements Serializable {
 
@@ -31,12 +32,13 @@ public class PreviousIssue implements Serializable {
   private String ruleRepo;
   private Integer line;
   private String message;
-  // For manual issues and when user has overriden severity
-  private String overriddenSeverity;
+  private String severity;
+  private Boolean manualSeverity;
   private String resolution;
   private String status;
   private String checksum;
   private String assigneeLogin;
+  private Date creationDate;
 
   public PreviousIssue setKey(String key) {
     this.key = key;
@@ -92,13 +94,22 @@ public class PreviousIssue implements Serializable {
     return status;
   }
 
-  public PreviousIssue setOverriddenSeverity(@Nullable String overriddenSeverity) {
-    this.overriddenSeverity = overriddenSeverity;
+  public PreviousIssue setSeverity(@Nullable String severity) {
+    this.severity = severity;
     return this;
   }
 
-  public String overriddenSeverity() {
-    return overriddenSeverity;
+  public String severity() {
+    return severity;
+  }
+
+  public boolean isManualSeverity() {
+    return manualSeverity;
+  }
+
+  public PreviousIssue setManualSeverity(boolean manualSeverity) {
+    this.manualSeverity = manualSeverity;
+    return this;
   }
 
   public PreviousIssue setChecksum(String checksum) {
@@ -133,4 +144,12 @@ public class PreviousIssue implements Serializable {
     return ruleKey;
   }
 
+  public Date getCreationDate() {
+    return creationDate;
+  }
+
+  public PreviousIssue setCreationDate(Date creationDate) {
+    this.creationDate = creationDate;
+    return this;
+  }
 }
index c36431c7e14cec70da78dcd654672ba2f27cfb6f..750b35f82808712b9629c05c4bf3068c6bae034d 100644 (file)
@@ -42,7 +42,8 @@ public class PreviousIssueHelperTest {
     issue1.setRuleKey("repokey", "rulekey");
     issue1.setLine(2);
     issue1.setMessage("message");
-    issue1.setOverriddenSeverity("severity");
+    issue1.setSeverity("severity");
+    issue1.setManualSeverity(true);
     issue1.setResolution("resolution");
     issue1.setStatus("status");
     issue1.setChecksum("checksum");
@@ -57,11 +58,11 @@ public class PreviousIssueHelperTest {
 
     JSONAssert
       .assertEquals(
-        "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", \"overriddenSeverity\": \"severity\", \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\"},"
+        "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", " +
+          "\"severity\": \"severity\", \"manualSeverity\": true, \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\"},"
           +
           "{\"key\": \"key2\"}]",
         out.getBuffer().toString(), true);
-
   }
 
   private static class PreviousIssueFunction implements PreviousIssueHelper.Function<PreviousIssue, PreviousIssue> {
@@ -76,7 +77,8 @@ public class PreviousIssueHelperTest {
     StringWriter out = new StringWriter();
     PreviousIssueHelper helper = PreviousIssueHelper.create(out);
     StringReader reader = new StringReader(
-      "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", \"overriddenSeverity\": \"severity\", \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\"},"
+      "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", " +
+        "\"severity\": \"severity\", \"manualSeverity\": true, \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\"},"
         +
         "{\"key\": \"key2\"}]");
 
@@ -92,7 +94,8 @@ public class PreviousIssueHelperTest {
     assertThat(issue1.ruleKey()).isEqualTo("rulekey");
     assertThat(issue1.line()).isEqualTo(2);
     assertThat(issue1.message()).isEqualTo("message");
-    assertThat(issue1.overriddenSeverity()).isEqualTo("severity");
+    assertThat(issue1.severity()).isEqualTo("severity");
+    assertThat(issue1.isManualSeverity()).isTrue();
     assertThat(issue1.resolution()).isEqualTo("resolution");
     assertThat(issue1.status()).isEqualTo("status");
     assertThat(issue1.checksum()).isEqualTo("checksum");
index 99542db8cb6b7dcacc9cd69106af04e8b6063e3c..e1ed38a1e071a9cb80410146ffd3d4913cee8068 100644 (file)
@@ -141,7 +141,7 @@ public class LocalIssueTracking implements BatchComponent {
       issue.setStatus(ref.status());
       issue.setAssignee(ref.assigneeLogin());
 
-      String overriddenSeverity = ref.overriddenSeverity();
+      String overriddenSeverity = ref.severity();
       if (overriddenSeverity != null) {
         // Severity overriden by user
         issue.setSeverity(overriddenSeverity);
@@ -177,7 +177,7 @@ public class LocalIssueTracking implements BatchComponent {
     issue.setResolution(previous.resolution());
     issue.setMessage(previous.message());
     issue.setLine(previous.line());
-    String overriddenSeverity = previous.overriddenSeverity();
+    String overriddenSeverity = previous.severity();
     if (overriddenSeverity != null) {
       issue.setSeverity(overriddenSeverity);
     } else {
index 04c588ad63f13eb5c39edd454a41be1c39e8cd67..701ef85d02d4aeff1ed7e69b102bf8edcfd38a32 100644 (file)
@@ -49,7 +49,7 @@ public class ReportsMediumTest {
       .setComponentKey("sample:xources/hello/HelloJava.xoo")
       .setRuleKey("xoo", "OneIssuePerLine")
       .setLine(1)
-      .setOverriddenSeverity("MAJOR")
+      .setSeverity("MAJOR")
       .setChecksum(DigestUtils.md5Hex("packagehello;"))
       .setStatus("OPEN"))
     .build();
index e9c4ed7f516e5b69e470ff5aa27154f65f8a2d90..4bdb30e5e8242d85bb0407e76b249903c3c3d73a 100644 (file)
@@ -20,6 +20,8 @@
 
 package org.sonar.core.issue.db;
 
+import java.util.Date;
+
 public class BatchIssueDto {
 
   private String kee;
@@ -34,6 +36,7 @@ public class BatchIssueDto {
   private String componentKey;
   private String ruleKey;
   private String ruleRepo;
+  private Date creationDate;
 
   public String getAssigneeLogin() {
     return assigneeLogin;
@@ -142,4 +145,13 @@ public class BatchIssueDto {
     this.severity = severity;
     return this;
   }
+
+  public Date getCreationDate() {
+    return creationDate;
+  }
+
+  public BatchIssueDto setCreationDate(Date creationDate) {
+    this.creationDate = creationDate;
+    return this;
+  }
 }
index fd487317b1f8e6371d61ddd83a3b6094fdf4db57..5ea815e5c94c96967f590915da5bea06c99524ff 100644 (file)
     i.resolution as resolution,
     i.checksum as checksum,
     i.assignee as assigneeLogin,
+    i.issue_creation_date as creationDate,
     r.plugin_rule_key as ruleKey,
     r.plugin_name as ruleRepo,
     component.kee as componentKey
     i.resolution as resolution,
     i.checksum as checksum,
     i.assignee as assigneeLogin,
+    i.issue_creation_date as creationDate,
     r.plugin_rule_key as ruleKey,
     r.plugin_name as ruleRepo,
     component.kee as componentKey