.setComponentKey(batchIssueDto.getComponentKey())
.setChecksum(batchIssueDto.getChecksum())
.setAssigneeLogin(batchIssueDto.getAssigneeLogin())
- .setAssigneeFullname(batchIssueDto.getAssigneeName())
.setLine(batchIssueDto.getLine())
.setRuleKey(batchIssueDto.getRuleRepo(), batchIssueDto.getRuleKey())
.setMessage(batchIssueDto.getMessage())
.setResolution(batchIssueDto.getResolution())
+ .setOverriddenSeverity(batchIssueDto.isManualSeverity() ? batchIssueDto.getSeverity() : null)
.setStatus(batchIssueDto.getStatus());
}
return null;
request.execute().assertJson(getClass(), "issues_on_project-expected.json");
}
+ @Test
+ public void return_only_manual_severity() throws Exception {
+ db.prepareDbUnit(getClass(), "return_only_manual_severity.xml");
+
+ 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");
+ }
+
@Test
public void return_issues_on_module() throws Exception {
db.prepareDbUnit(getClass(), "shared.xml");
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rule.Severity;
import org.sonar.api.utils.DateUtils;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.issue.db.BatchIssueDto;
assertThat(batchIssueDto.getLine()).isEqualTo(200);
assertThat(batchIssueDto.getResolution()).isEqualTo(Issue.RESOLUTION_FALSE_POSITIVE);
assertThat(batchIssueDto.getStatus()).isEqualTo(Issue.STATUS_RESOLVED);
+ assertThat(batchIssueDto.getSeverity()).isEqualTo(Severity.BLOCKER);
+ assertThat(batchIssueDto.isManualSeverity()).isTrue();
assertThat(batchIssueDto.getComponentKey()).isEqualTo("Sample.java");
assertThat(batchIssueDto.getChecksum()).isEqualTo("123456");
assertThat(batchIssueDto.getAssigneeLogin()).isEqualTo("john");
- assertThat(batchIssueDto.getAssigneeName()).isEqualTo("John Doo");
}
@Test
assertThat(batchIssueDto.getLine()).isEqualTo(200);
assertThat(batchIssueDto.getResolution()).isEqualTo(Issue.RESOLUTION_FALSE_POSITIVE);
assertThat(batchIssueDto.getStatus()).isEqualTo(Issue.STATUS_RESOLVED);
+ assertThat(batchIssueDto.getSeverity()).isEqualTo(Severity.BLOCKER);
+ assertThat(batchIssueDto.isManualSeverity()).isTrue();
assertThat(batchIssueDto.getComponentKey()).isEqualTo("Sample.java");
assertThat(batchIssueDto.getChecksum()).isEqualTo("123456");
assertThat(batchIssueDto.getAssigneeLogin()).isEqualTo("john");
- assertThat(batchIssueDto.getAssigneeName()).isEqualTo("John Doo");
}
@Test
"resolution": "FALSE-POSITIVE",
"status": "RESOLVED",
"checksum": "123456",
- "assigneeLogin": "john",
- "assigneeFullname": "John Doo"
+ "assigneeLogin": "john"
}
]
"resolution": "FALSE-POSITIVE",
"status": "RESOLVED",
"checksum": "123456",
- "assigneeLogin": "john",
- "assigneeFullname": "John Doo"
+ "assigneeLogin": "john"
}
]
--- /dev/null
+[
+ {
+ "key": "FGHI",
+ "componentKey": "Action.java",
+ "ruleKey": "API",
+ "ruleRepo": "manual",
+ "line": 201,
+ "message": "Do not use this method",
+ "status": "OPEN",
+ "overriddenSeverity": "CRITICAL",
+ "checksum": "234567",
+ "assigneeLogin": "john"
+ }
+]
+
--- /dev/null
+<dataset>
+
+ <!-- Multi module project -->
+ <projects id="399" kee="struts" root_id="[null]" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/>
+ <projects id="400" kee="struts-core" root_id="399" qualifier="BRC" scope="PRJ" uuid="BCDE" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD.BCDE."
+ path="struts-core"/>
+ <projects id="401" kee="Action.java" root_id="400" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="BCDE" module_uuid_path=".ABCD.BCDE."
+ path="src/main/java/Action.java"/>
+
+ <rules id="501" tags="[null]" system_tags="[null]" plugin_rule_key="API" plugin_name="manual" language="[null]"/>
+
+ <!-- Open Issue with manual severity on a file -->
+ <issues
+ id="101"
+ kee="FGHI"
+ component_id="401"
+ root_component_id="399"
+ rule_id="501"
+ severity="CRITICAL"
+ manual_severity="[true]"
+ message="Do not use this method"
+ line="201"
+ effort_to_fix="[null]"
+ status="OPEN"
+ resolution="[null]"
+ checksum="234567"
+ reporter="user"
+ assignee="john"
+ author_login="[null]"
+ issue_attributes="[null]"
+ issue_creation_date="2013-04-16"
+ issue_update_date="2013-04-16"
+ issue_close_date="2013-04-16"
+ created_at="1400000000000"
+ updated_at="[null]"
+ />
+
+</dataset>
<rules id="500" tags="[null]" system_tags="[null]" plugin_rule_key="AvoidCycle" plugin_name="squid" language="java"/>
- <users id="10" login="john" name="John Doo" active="[true]"/>
-
<!-- Open Issue on a file -->
<issues
id="100"
root_component_id="1000"
rule_id="500"
severity="BLOCKER"
- manual_severity="[false]"
+ manual_severity="[true]"
message="Avoid this"
line="200"
effort_to_fix="[null]"
root_component_id="1000"
rule_id="500"
severity="BLOCKER"
- manual_severity="[false]"
+ manual_severity="[true]"
message="Avoid this"
line="200"
effort_to_fix="[null]"
*/
package org.sonar.batch.protocol.input.issues;
+import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
public class PreviousIssue {
private String ruleRepo;
private Integer line;
private String message;
- private String severity;
+ private String overriddenSeverity;
private String resolution;
private String status;
private String checksum;
private String assigneeLogin;
- private String assigneeFullname;
public PreviousIssue setKey(String key) {
this.key = key;
return status;
}
- public PreviousIssue setSeverity(String severity) {
- this.severity = severity;
+ public PreviousIssue setOverriddenSeverity(@Nullable String overriddenSeverity) {
+ this.overriddenSeverity = overriddenSeverity;
return this;
}
- public String severity() {
- return severity;
+ @CheckForNull
+ public String overriddenSeverity() {
+ return overriddenSeverity;
}
public PreviousIssue setChecksum(String checksum) {
return assigneeLogin;
}
- public PreviousIssue setAssigneeFullname(String assigneeFullname) {
- this.assigneeFullname = assigneeFullname;
- return this;
- }
-
- public String assigneeFullname() {
- return assigneeFullname;
- }
-
public PreviousIssue setRuleKey(String ruleRepo, String ruleKey) {
this.ruleRepo = ruleRepo;
this.ruleKey = ruleKey;
issue1.setRuleKey("repokey", "rulekey");
issue1.setLine(2);
issue1.setMessage("message");
- issue1.setSeverity("severity");
+ issue1.setOverriddenSeverity("severity");
issue1.setResolution("resolution");
issue1.setStatus("status");
issue1.setChecksum("checksum");
issue1.setAssigneeLogin("login");
- issue1.setAssigneeFullname("fullname");
PreviousIssue issue2 = new PreviousIssue();
issue2.setKey("key2");
JSONAssert
.assertEquals(
- "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", \"severity\": \"severity\", \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\", \"assigneeFullname\": \"fullname\"},"
+ "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", \"overriddenSeverity\": \"severity\", \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\"},"
+
"{\"key\": \"key2\"}]",
out.getBuffer().toString(), true);
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\", \"severity\": \"severity\", \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\", \"assigneeFullname\": \"fullname\"},"
+ "[{\"key\": \"key1\", \"componentKey\": \"key\", \"ruleKey\": \"rulekey\", \"ruleRepo\": \"repokey\", \"line\": 2,\"message\": \"message\", \"overriddenSeverity\": \"severity\", \"resolution\": \"resolution\", \"status\": \"status\", \"checksum\": \"checksum\",\"assigneeLogin\": \"login\"},"
+
"{\"key\": \"key2\"}]");
assertThat(issue1.ruleKey()).isEqualTo("rulekey");
assertThat(issue1.line()).isEqualTo(2);
assertThat(issue1.message()).isEqualTo("message");
- assertThat(issue1.severity()).isEqualTo("severity");
+ assertThat(issue1.overriddenSeverity()).isEqualTo("severity");
assertThat(issue1.resolution()).isEqualTo("resolution");
assertThat(issue1.status()).isEqualTo("status");
assertThat(issue1.checksum()).isEqualTo("checksum");
assertThat(issue1.assigneeLogin()).isEqualTo("login");
- assertThat(issue1.assigneeFullname()).isEqualTo("fullname");
assertThat(issue2.key()).isEqualTo("key2");
helper.close();
private String message;
private Integer line;
private String status;
+ private String severity;
+ private boolean manualSeverity;
private String resolution;
private String checksum;
private String assigneeLogin;
- private String assigneeName;
private String componentKey;
private String ruleKey;
private String ruleRepo;
return this;
}
- public String getAssigneeName() {
- return assigneeName;
- }
-
- public BatchIssueDto setAssigneeName(String assigneeName) {
- this.assigneeName = assigneeName;
- return this;
- }
-
public String getChecksum() {
return checksum;
}
this.status = status;
return this;
}
+
+ public boolean isManualSeverity() {
+ return manualSeverity;
+ }
+
+ public BatchIssueDto setManualSeverity(boolean manualSeverity) {
+ this.manualSeverity = manualSeverity;
+ return this;
+ }
+
+ public String getSeverity() {
+ return severity;
+ }
+
+ public BatchIssueDto setSeverity(String severity) {
+ this.severity = severity;
+ return this;
+ }
}
i.message as message,
i.line as line,
i.status as status,
+ i.severity as severity,
+ i.manual_severity as manualSeverity,
i.resolution as resolution,
i.checksum as checksum,
+ i.assignee as assigneeLogin,
r.plugin_rule_key as ruleKey,
r.plugin_name as ruleRepo,
- component.kee as componentKey,
- i.assignee as assigneeLogin,
- u.name as assigneeName
+ component.kee as componentKey
FROM issues i
INNER JOIN (SELECT p.id,p.kee FROM projects p WHERE p.module_uuid=#{uuid} OR p.uuid=#{uuid}) component ON component.id=i.component_id
INNER JOIN rules r ON r.id=i.rule_id
- LEFT OUTER JOIN users u ON u.login=i.assignee
WHERE i.status <> 'CLOSED'
</select>
i.message as message,
i.line as line,
i.status as status,
+ i.severity as severity,
+ i.manual_severity as manualSeverity,
i.resolution as resolution,
i.checksum as checksum,
+ i.assignee as assigneeLogin,
r.plugin_rule_key as ruleKey,
r.plugin_name as ruleRepo,
- component.kee as componentKey,
- i.assignee as assigneeLogin,
- u.name as assigneeName
+ component.kee as componentKey
FROM issues i
INNER JOIN projects component on component.id=i.component_id
INNER JOIN projects project on project.uuid=component.project_uuid AND project.uuid=#{uuid}
INNER JOIN rules r ON r.id=i.rule_id
- LEFT OUTER JOIN users u ON u.login=i.assignee
WHERE i.status <> 'CLOSED'
</select>