aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-12-14 18:56:53 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-12-15 14:45:04 +0100
commit6e6f004f24142e3739c892bbee9153c26a51d0a1 (patch)
treeb62be7b9d99be931fdf3cb996c63d8b5ea5dc0ab /sonar-ws
parentf708dfbad7bacac33b18bb5c7c1221565b803fa5 (diff)
downloadsonarqube-6e6f004f24142e3739c892bbee9153c26a51d0a1.tar.gz
sonarqube-6e6f004f24142e3739c892bbee9153c26a51d0a1.zip
SONAR-7294 Replace Ruby WS api/issues/edit_comment
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java10
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java42
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java11
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java2
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java12
5 files changed, 71 insertions, 6 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java
index 291180845c0..e13e7dc945f 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/AddCommentRequest.java
@@ -25,18 +25,18 @@ import static java.util.Objects.requireNonNull;
public class AddCommentRequest {
private final String issue;
- private final String comment;
+ private final String text;
- public AddCommentRequest(String issue, String comment) {
+ public AddCommentRequest(String issue, String text) {
this.issue = requireNonNull(issue, "Issue key cannot be null");
- this.comment = requireNonNull(comment, "Comment cannot be null");
+ this.text = requireNonNull(text, "Text cannot be null");
}
public String getIssue() {
return issue;
}
- public String getComment() {
- return comment;
+ public String getText() {
+ return text;
}
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java
new file mode 100644
index 00000000000..06c95b4e89d
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/EditCommentRequest.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonarqube.ws.client.issue;
+
+import static java.util.Objects.requireNonNull;
+
+public class EditCommentRequest {
+
+ private final String comment;
+ private final String text;
+
+ public EditCommentRequest(String comment, String text) {
+ this.comment = requireNonNull(comment, "Comment key cannot be null");
+ this.text = requireNonNull(text, "Text cannot be null");
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public String getText() {
+ return text;
+ }
+}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java
index f0f8aa3b948..7bd9b0f8d6f 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesService.java
@@ -35,6 +35,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_ADD_COMMEN
import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_ASSIGN;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_CHANGELOG;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_DO_TRANSITION;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_EDIT_COMMENT;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SEARCH;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_SEVERITY;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.ACTION_SET_TYPE;
@@ -47,6 +48,7 @@ import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNED;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEE;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_ASSIGNEES;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_AUTHORS;
+import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMMENT;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_KEYS;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENT_ROOTS;
@@ -88,7 +90,7 @@ public class IssuesService extends BaseService {
public Issues.Operation addComment(AddCommentRequest request) {
return call(new PostRequest(path(ACTION_ADD_COMMENT))
.setParam(PARAM_ISSUE, request.getIssue())
- .setParam(PARAM_TEXT, request.getComment()),
+ .setParam(PARAM_TEXT, request.getText()),
Issues.Operation.parser());
}
@@ -112,6 +114,13 @@ public class IssuesService extends BaseService {
Issues.Operation.parser());
}
+ public Issues.Operation editComment(EditCommentRequest request) {
+ return call(new PostRequest(path(ACTION_EDIT_COMMENT))
+ .setParam(PARAM_COMMENT, request.getComment())
+ .setParam(PARAM_TEXT, request.getText()),
+ Issues.Operation.parser());
+ }
+
public SearchWsResponse search(SearchWsRequest request) {
return call(
new GetRequest(path(ACTION_SEARCH))
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java
index 223f43451bb..bc20871b002 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssuesWsParameters.java
@@ -32,6 +32,7 @@ public class IssuesWsParameters {
public static final String ACTION_SEARCH = "search";
public static final String ACTION_CHANGELOG = "changelog";
public static final String ACTION_ADD_COMMENT = "add_comment";
+ public static final String ACTION_EDIT_COMMENT = "edit_comment";
public static final String ACTION_ASSIGN = "assign";
public static final String ACTION_AUTHORS = "authors";
public static final String ACTION_DO_TRANSITION = "do_transition";
@@ -41,6 +42,7 @@ public class IssuesWsParameters {
public static final String ACTION_SET_TYPE = "set_type";
public static final String PARAM_ISSUE = "issue";
+ public static final String PARAM_COMMENT = "comment";
public static final String PARAM_TEXT = "text";
public static final String PARAM_ASSIGNEE = "assignee";
public static final String PARAM_TRANSITION = "transition";
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java
index b5d13772212..34416229f5c 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/issue/IssuesServiceTest.java
@@ -86,6 +86,18 @@ public class IssuesServiceTest {
}
@Test
+ public void edit_comment() {
+ underTest.editComment(new EditCommentRequest("ABCD", "Please help me to fix this issue"));
+ PostRequest request = serviceTester.getPostRequest();
+
+ assertThat(serviceTester.getPostParser()).isSameAs(Issues.Operation.parser());
+ serviceTester.assertThat(request)
+ .hasParam("comment", "ABCD")
+ .hasParam("text", "Please help me to fix this issue")
+ .andNoOtherParam();
+ }
+
+ @Test
public void set_severity() {
underTest.setSeverity(new SetSeverityRequest("ABCD", "confirm"));
PostRequest request = serviceTester.getPostRequest();