aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-05-16 23:05:25 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-05-16 23:05:25 +0200
commit6c263271502929862a6fde7846408c4576640614 (patch)
tree8a43fafc37659e513047b0eedfc7f63f3eab41f3 /sonar-ws-client
parentfc063e7aa96c11db5cbc68b6794532193b13d4d7 (diff)
downloadsonarqube-6c263271502929862a6fde7846408c4576640614.tar.gz
sonarqube-6c263271502929862a6fde7846408c4576640614.zip
SONAR-4304 better form of manual issue
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java25
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/issue/NewIssueTest.java16
2 files changed, 27 insertions, 14 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java
index f4b43a39385..4b8932c2a11 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java
@@ -19,6 +19,7 @@
*/
package org.sonar.wsclient.issue;
+import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -40,7 +41,10 @@ public class NewIssue {
return params;
}
- public NewIssue severity(String s) {
+ /**
+ * Optionally set the severity, in INFO, MINOR, MAJOR, CRITICAL or BLOCKER. Default value is MAJOR.
+ */
+ public NewIssue severity(@Nullable String s) {
params.put("severity", s);
return this;
}
@@ -50,31 +54,28 @@ public class NewIssue {
return this;
}
+ /**
+ * Rule key prefixed by the repository, for example "checkstyle:AvoidCycle".
+ */
public NewIssue rule(String s) {
params.put("rule", s);
return this;
}
/**
- * Optional line
+ * Optional line, starting from 1.
*/
- public NewIssue line(int i) {
+ public NewIssue line(@Nullable Integer i) {
params.put("line", i);
return this;
}
- public NewIssue description(String s) {
- params.put("desc", s);
- return this;
- }
-
- // TODO to be removed
- public NewIssue cost(Double d) {
- params.put("cost", d);
+ public NewIssue message(@Nullable String s) {
+ params.put("message", s);
return this;
}
- public NewIssue effortToFix(double d) {
+ public NewIssue effortToFix(@Nullable Double d) {
params.put("effortToFix", d);
return this;
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/NewIssueTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/NewIssueTest.java
index a6e2e9d7d40..75c9d3c3738 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/NewIssueTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/NewIssueTest.java
@@ -35,7 +35,7 @@ public class NewIssueTest {
NewIssue newIssue = NewIssue.create()
.component("Action.java")
.effortToFix(4.2)
- .description("the desc")
+ .message("the message")
.line(123)
.rule("squid:AvoidCycle")
.severity("BLOCKER")
@@ -44,11 +44,23 @@ public class NewIssueTest {
assertThat(newIssue.urlParams()).hasSize(7).includes(
entry("component", "Action.java"),
entry("effortToFix", 4.2),
- entry("desc", "the desc"),
+ entry("message", "the message"),
entry("line", 123),
entry("rule", "squid:AvoidCycle"),
entry("severity", "BLOCKER"),
entry("attr[JIRA]", "FOO-123")
);
}
+
+ @Test
+ public void create_with_only_required_parameters() {
+ NewIssue newIssue = NewIssue.create()
+ .component("Action.java")
+ .rule("squid:AvoidCycle");
+
+ assertThat(newIssue.urlParams()).hasSize(2).includes(
+ entry("component", "Action.java"),
+ entry("rule", "squid:AvoidCycle")
+ );
+ }
}