]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2453 Update the way "FALSE-POSITIVE" reviews are managed
authorFabrice Bellingard <bellingard@gmail.com>
Mon, 30 May 2011 17:18:32 +0000 (19:18 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Mon, 30 May 2011 17:19:12 +0000 (19:19 +0200)
Add the violation id on a review JSON/XML format so that we don't
have to add it later when we implement manual reviews.

sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewCreateQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewDeleteQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshaller.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewDeleteQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java
sonar-ws-client/src/test/resources/reviews/reviews-2.9.json

index d28b1de6a738885662c38c69f876013865364dcc..e44ce280a5575a2b430e877006fb7d03fb96cb88 100644 (file)
@@ -257,6 +257,7 @@ class Review < ActiveRecord::Base
       xml.severity(severity)
       xml.resource(resource.kee)  if resource
       xml.line(resource_line) if resource_line && resource_line>0
+      xml.violationId(rule_failure_permanent_id) if rule_failure_permanent_id
       xml.comments do
         review_comments.each do |comment|
           xml.comment do
@@ -291,6 +292,7 @@ class Review < ActiveRecord::Base
     json['severity'] = severity
     json['resource'] = resource.kee if resource
     json['line'] = resource_line if resource_line && resource_line>0
+    json['violationId'] = rule_failure_permanent_id if rule_failure_permanent_id
     comments = []
     review_comments.each do |comment|
       comments << {
index ba17f28d376d49319af205cfad0dc8e4b7c280bd..596b2763639e8f403f67be2981e769b29c62c8ce 100644 (file)
@@ -40,6 +40,7 @@ public class Review extends Model {
   private String resourceKee = null;
   private Integer line = null;
   private Boolean falsePositive = null;
+  private Long violationId;
   private List<Review.Comment> comments = new ArrayList<Review.Comment>();
 
   /**
@@ -243,6 +244,23 @@ public class Review extends Model {
     this.falsePositive = falsePositive;
     return this;
   }
+  
+  /**
+   * @since 2.9
+   * @return the violation id
+   */
+  public Long getViolationId() {
+    return violationId;
+  }
+
+  /**
+   * @param id
+   *          the violation id to set
+   */
+  public Review setViolationId(Long violationId) {
+    this.violationId = violationId;
+    return this;
+  }
 
   /**
    * @return the comments
index 96d7a57c66a06ab91a1832bb6d16c4b2e52345f8..f48eb971e19efd0be9e5d3b3aa579cbf714a3c68 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.wsclient.services;
 /**
  * @since 2.9
  */
-public class ReviewCreateQuery extends UpdateQuery<Review> {
+public class ReviewCreateQuery extends CreateQuery<Review> {
 
   private Long violationId;
   private String text;
index fc919b00ea574e73734deecaa85e1b039718b198..5a21766660776eb57974487b8212f7933db8c8ca 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.wsclient.services;
 /**
  * @since 2.9
  */
-public class ReviewDeleteQuery extends CreateQuery<Review> {
+public class ReviewDeleteQuery extends DeleteQuery<Review> {
 
   private Long reviewId;
   private Long commentId;
@@ -74,9 +74,4 @@ public class ReviewDeleteQuery extends CreateQuery<Review> {
     appendUrlParameter(url, "comment_id", getCommentId());
     return url.toString();
   }
-
-  @Override
-  public Class<Review> getModelClass() {
-    return Review.class;
-  }
 }
index a6701d4a18e508b60f4f5146651a940d881f90cd..800bc048e04594e92c2ef8e6976d2de696a6fa8a 100644 (file)
@@ -264,6 +264,10 @@ public class ReviewQuery extends Query<Review> {
     return Review.class;
   }
 
+  public static ReviewQuery createForReview(Long id) {
+    return new ReviewQuery().setId(id);
+  }
+
   public static ReviewQuery createForResource(Resource resource) {
     return new ReviewQuery().setResourceKeysOrIds(resource.getId().toString());
   }
index 328ec295216e7d3bb5f1771ae25ee356b92a3dc2..244ef0b5b4d35d26f4f8a7b130d8fbaef1f9ec8c 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.wsclient.services;
 /**
  * @since 2.9
  */
-public class ReviewUpdateQuery extends CreateQuery<Review> {
+public class ReviewUpdateQuery extends UpdateQuery<Review> {
 
   private Long reviewId;
   private String text;
index f3fbb3a57e4060482abcf0b1a44c4e9e4183c6aa..3ea023700eafdf7aea204375a20c39c3151c6961 100644 (file)
@@ -43,6 +43,7 @@ public class ReviewUnmarshaller extends AbstractUnmarshaller<Review> {
     review.setResourceKee(utils.getString(json, "resource"));
     review.setLine(utils.getInteger(json, "line"));
     review.setFalsePositive(utils.getBoolean(json, "falsePositive"));
+    review.setViolationId(utils.getLong(json, "violationId"));
     review.setType(utils.getString(json, "type"));
 
     Object comments = utils.getField(json, "comments");
index ff2b22dadf8e9a510245978fa3f61e0b0f5406c0..d78bcf39baf7d2b84cc095854ac31ac80ccad148 100644 (file)
@@ -30,7 +30,6 @@ public class ReviewDeleteQueryTest extends QueryTestCase {
   public void testAddComment() {
     ReviewDeleteQuery query = ReviewDeleteQuery.deleteCommentQuery(13L, 2L);
     assertThat(query.getUrl(), is("/api/reviews/?id=13&comment_id=2&"));
-    assertThat(query.getModelClass().getName(), is(Review.class.getName()));
   }
 
 }
\ No newline at end of file
index d2c4cc7356490a9605c020cd466d112407e0d50f..9041c11a06acc7c670db81ba72bda48832fcb8f9 100644 (file)
@@ -55,6 +55,7 @@ public class ReviewUnmarshallerTest extends UnmarshallerTestCase {
     assertThat(review.getSeverity(), is("MINOR"));
     assertThat(review.getResourceKee(), is("org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReaderConfiguration"));
     assertThat(review.getLine(), is(33));
+    assertThat(review.getViolationId(), is(1L));
     List<Comment> comments = review.getComments();
     assertThat(comments.size(), is(4));
     Comment comment = comments.get(0);
index 707438bbd310392da34c74b9eae2bc60c0c665bf..8b1f11c62a866bfd6a7db069560e1e0543e7026d 100644 (file)
@@ -1 +1 @@
-[{"id":3,"createdAt":"2011-04-26T15:44:42+0200","updatedAt":"2011-04-26T15:44:42+0200","author":"admin","assignee":"admin","title":"'static' modifier out of order with the JLS suggestions.","falsePositive":false,"status":"OPEN","severity":"MINOR","resource":"org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReaderConfiguration","line":33,"comments":[{"id":1,"author":"admin","updatedAt":"2011-04-26T15:44:42+0200","text":"This is a review.<br/>And this is on multiple lines...<br/><br/><code>Wouhou!!!!!</code>"},{"id":2,"author":"admin","updatedAt":"2011-04-26T17:10:19+0200","text":"<em>Bold on multiple line?</em>"},{"id":3,"author":"admin","updatedAt":"2011-04-26T17:11:02+0200","text":"And the bullets:<br/><ul><li>1 bullet</li>\n<li>2 bullets</li></ul>"},{"id":4,"author":"admin","updatedAt":"2011-04-26T17:27:37+0200","text":"Wazzaa"}]},{"id":9,"createdAt":"2011-04-27T14:37:20+0200","updatedAt":"2011-04-27T14:37:20+0200","author":"admin","title":"New exception is thrown in catch block, original stack trace may be lost","falsePositive":true,"status":"OPEN","severity":"MAJOR","resource":"org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReader","line":84,"comments":[{"id":5,"author":"admin","updatedAt":"2011-04-27T14:37:20+0200","text":"Wazzaaaa"}]}]
\ No newline at end of file
+[{"id":3,"createdAt":"2011-04-26T15:44:42+0200","updatedAt":"2011-04-26T15:44:42+0200","author":"admin","assignee":"admin","title":"'static' modifier out of order with the JLS suggestions.","falsePositive":false,"status":"OPEN","severity":"MINOR","resource":"org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReaderConfiguration","line":33,"violationId":1,"comments":[{"id":1,"author":"admin","updatedAt":"2011-04-26T15:44:42+0200","text":"This is a review.<br/>And this is on multiple lines...<br/><br/><code>Wouhou!!!!!</code>"},{"id":2,"author":"admin","updatedAt":"2011-04-26T17:10:19+0200","text":"<em>Bold on multiple line?</em>"},{"id":3,"author":"admin","updatedAt":"2011-04-26T17:11:02+0200","text":"And the bullets:<br/><ul><li>1 bullet</li>\n<li>2 bullets</li></ul>"},{"id":4,"author":"admin","updatedAt":"2011-04-26T17:27:37+0200","text":"Wazzaa"}]},{"id":9,"createdAt":"2011-04-27T14:37:20+0200","updatedAt":"2011-04-27T14:37:20+0200","author":"admin","title":"New exception is thrown in catch block, original stack trace may be lost","falsePositive":true,"status":"OPEN","severity":"MAJOR","resource":"org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReader","line":84,"violationId":2,"comments":[{"id":5,"author":"admin","updatedAt":"2011-04-27T14:37:20+0200","text":"Wazzaaaa"}]}]
\ No newline at end of file