aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-04-29 13:50:38 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-04-29 13:52:03 +0200
commit4f21ba8d2162a383cab0324c45c85564cb7dcede (patch)
tree96e3cdec536a4e42a76106926c1f9e84d2c288fc
parent693a1f7bb5071178546d2d2d636e0965aa226ef2 (diff)
downloadsonarqube-4f21ba8d2162a383cab0324c45c85564cb7dcede.tar.gz
sonarqube-4f21ba8d2162a383cab0324c45c85564cb7dcede.zip
SONAR-2382 Create a new "reviews" web service API
- Add possibility to use keys or ids for resources/projects - Add possibility to use logins or ids for authors/assignees - Remove the "html" parameter on the ReviewQuery (comments will always be returned in HTML)
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java103
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java11
2 files changed, 45 insertions, 69 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
index 0df5e0195d4..21dc8d0d0d5 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
@@ -31,11 +31,10 @@ public class ReviewQuery extends Query<Review> {
private Long[] ids;
private String[] statuses;
private String[] severities;
- private Long[] projects;
- private Long[] resources;
- private Long[] authors;
- private Long[] assignees;
- private Boolean html;
+ private String[] projectKeysOrIds;
+ private String[] resourceKeysOrIds;
+ private String[] authorLoginsOrIds;
+ private String[] assigneeLoginsOrIds;
public ReviewQuery() {
}
@@ -119,93 +118,72 @@ public class ReviewQuery extends Query<Review> {
this.severities = severities;
return this;
}
-
+
+
/**
- * @return the projects
+ * @return the projectKeysOrIds
*/
- public Long[] getProjects() {
- return projects;
+ public String[] getProjectKeysOrIds() {
+ return projectKeysOrIds;
}
+
/**
- * Specify the IDs of the projects.
- *
- * @param projects
- * the project IDs to set
+ * @param projectKeysOrIds the projectKeysOrIds to set
*/
- public ReviewQuery setProjects(Long... projects) {
- this.projects = projects;
+ public ReviewQuery setProjectKeysOrIds(String... projectKeysOrIds) {
+ this.projectKeysOrIds = projectKeysOrIds;
return this;
}
+
/**
- * @return the resources
+ * @return the resourceKeysOrIds
*/
- public Long[] getResources() {
- return resources;
+ public String[] getResourceKeysOrIds() {
+ return resourceKeysOrIds;
}
+
/**
- * Specify the IDs of the resources.
- *
- * @param resources
- * the resource IDs to set
+ * @param resourceKeysOrIds the resourceKeysOrIds to set
*/
- public ReviewQuery setResources(Long... resources) {
- this.resources = resources;
+ public ReviewQuery setResourceKeysOrIds(String... resourceKeysOrIds) {
+ this.resourceKeysOrIds = resourceKeysOrIds;
return this;
}
+
/**
- * @return the authors
+ * @return the authorLoginsOrIds
*/
- public Long[] getAuthors() {
- return authors;
+ public String[] getAuthorLoginsOrIds() {
+ return authorLoginsOrIds;
}
+
/**
- * Specify the IDs of the authors.
- *
- * @param authors
- * the author IDs to set
+ * @param authorLoginsOrIds the authorLoginsOrIds to set
*/
- public ReviewQuery setAuthors(Long... authors) {
- this.authors = authors;
+ public ReviewQuery setAuthorLoginsOrIds(String... authorLoginsOrIds) {
+ this.authorLoginsOrIds = authorLoginsOrIds;
return this;
}
- /**
- * @return the assignees
- */
- public Long[] getAssignees() {
- return assignees;
- }
-
- /**
- * Specify the IDs of the assignees.
- *
- * @param assignees
- * the assignee IDs to set
- */
- public ReviewQuery setAssignees(Long... assignees) {
- this.assignees = assignees;
- return this;
- }
/**
- * @return the html
+ * @return the assigneeLoginsOrIds
*/
- public Boolean getHtml() {
- return html;
+ public String[] getAssigneeLoginsOrIds() {
+ return assigneeLoginsOrIds;
}
+
/**
- * If true, the comments will be generated in HTML. Otherwise, they will be in raw text.
- *
- * @param html the html to set
+ * @param assigneeLoginsOrIds the assigneeLoginsOrIds to set
*/
- public ReviewQuery setHtml(Boolean html) {
- this.html = html;
+ public ReviewQuery setAssigneeLoginsOrIds(String... assigneeLoginsOrIds) {
+ this.assigneeLoginsOrIds = assigneeLoginsOrIds;
return this;
}
@@ -221,11 +199,10 @@ public class ReviewQuery extends Query<Review> {
appendUrlParameter(url, "review_type", reviewType);
appendUrlParameter(url, "statuses", statuses);
appendUrlParameter(url, "severities", severities);
- appendUrlParameter(url, "projects", projects);
- appendUrlParameter(url, "resources", resources);
- appendUrlParameter(url, "authors", authors);
- appendUrlParameter(url, "assignees", assignees);
- appendUrlParameter(url, "html", html);
+ appendUrlParameter(url, "projects", projectKeysOrIds);
+ appendUrlParameter(url, "resources", resourceKeysOrIds);
+ appendUrlParameter(url, "authors", authorLoginsOrIds);
+ appendUrlParameter(url, "assignees", assigneeLoginsOrIds);
return url.toString();
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java
index 340a27d3900..0dc688784c1 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java
@@ -44,13 +44,12 @@ public class ReviewQueryTest extends QueryTestCase {
query.setReviewType("FALSE_POSITIVE");
query.setStatuses("OPEN");
query.setSeverities("MINOR", "INFO");
- query.setProjects(1L);
- query.setResources(2L, 3L);
- query.setAuthors(20L);
- query.setAssignees(21L);
- query.setHtml(Boolean.TRUE);
+ query.setProjectKeysOrIds("com.sonar.foo:bar");
+ query.setResourceKeysOrIds("2", "3");
+ query.setAuthorLoginsOrIds("20");
+ query.setAssigneeLoginsOrIds("admin");
assertThat(
query.getUrl(),
- is("/api/reviews?ids=10,11&review_type=FALSE_POSITIVE&statuses=OPEN&severities=MINOR,INFO&projects=1&resources=2,3&authors=20&assignees=21&html=true&"));
+ is("/api/reviews?ids=10,11&review_type=FALSE_POSITIVE&statuses=OPEN&severities=MINOR,INFO&projects=com.sonar.foo%3Abar&resources=2,3&authors=20&assignees=admin&"));
}
}