]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2382 Create a new "reviews" web service API
authorFabrice Bellingard <bellingard@gmail.com>
Fri, 29 Apr 2011 11:50:38 +0000 (13:50 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Fri, 29 Apr 2011 11:52:03 +0000 (13:52 +0200)
- 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)

sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java

index 0df5e0195d468ab1ef3b0893df5095b89c5237f6..21dc8d0d0d5d02bbf3fab8afb04b0ef7bc976098 100644 (file)
@@ -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();
   }
index 340a27d390050e6347d6726639f7ff06f19edc10..0dc688784c1b3494e282aa5128601bece434f108 100644 (file)
@@ -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&"));
   }
 }