aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-06-23 17:50:52 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-06-27 20:26:26 +0400
commit595485bb2bf8b327cb50e24597894d97d28c178d (patch)
treea2cd2ba9563e2baf5e043a4ef64923a067be6817 /sonar-ws-client
parent7be54b4df2a55f180620775659bcd888f5249183 (diff)
downloadsonarqube-595485bb2bf8b327cb50e24597894d97d28c178d.tar.gz
sonarqube-595485bb2bf8b327cb50e24597894d97d28c178d.zip
SONAR-2404 Refactor reviews API - web-service and sonar-ws-client
* Remove ability to edit and delete comments. * Fix bug - comment should be transferred in body. * Fix XML/JSON output - new attribute 'resolution'.
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java102
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewCreateQuery.java87
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewDeleteQuery.java77
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java156
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshaller.java2
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewCreateQueryTest.java30
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewDeleteQueryTest.java35
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewUpdateQueryTest.java36
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java11
-rw-r--r--sonar-ws-client/src/test/resources/reviews/reviews-2.9.json2
10 files changed, 143 insertions, 395 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
index 646e2b2a7a1..f399788eef3 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
@@ -39,109 +39,84 @@ public class Review extends Model {
private String severity = null;
private String resourceKee = null;
private Integer line = null;
- private Boolean falsePositive = null;
+ private String resolution = null;
private Long violationId;
private List<Review.Comment> comments = new ArrayList<Review.Comment>();
/**
- * @return the id
+ * @return id
*/
public Long getId() {
return id;
}
- /**
- * @param id
- * the id to set
- */
public Review setId(Long id) {
this.id = id;
return this;
}
/**
- * @return the createdAt
+ * @return date of creation
*/
public Date getCreatedAt() {
return createdAt;
}
- /**
- * @param createdAt
- * the createdAt to set
- */
public Review setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
return this;
}
/**
- * @return the updatedAt
+ * @return date of last modification
*/
public Date getUpdatedAt() {
return updatedAt;
}
- /**
- * @param updatedAt
- * the updatedAt to set
- */
public Review setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
return this;
}
/**
- * @return the authorLogin
+ * @return user that initiated review
*/
public String getAuthorLogin() {
return authorLogin;
}
- /**
- * @param s
- * the authorLogin to set
- */
public Review setAuthorLogin(String s) {
this.authorLogin = s;
return this;
}
/**
- * @return the assigneeLogin
+ * @return assignee
*/
public String getAssigneeLogin() {
return assigneeLogin;
}
- /**
- * @param s
- * the assigneeLogin to set
- */
public Review setAssigneeLogin(String s) {
this.assigneeLogin = s;
return this;
}
/**
- * @return the title
+ * @return title
*/
public String getTitle() {
return title;
}
- /**
- * @param s
- * the title to set
- */
public Review setTitle(String s) {
this.title = s;
return this;
}
/**
- * @deprecated since 2.9. Use {@link #getFalsePositive()} instead.
- * @return the type
+ * @deprecated since 2.9.
*/
@Deprecated
public String getType() {
@@ -149,81 +124,57 @@ public class Review extends Model {
}
/**
- * @deprecated since 2.9. Use {@link #setFalsePositive(Boolean)} instead.
- * @param s
- * the type to set
+ * @deprecated since 2.9.
*/
@Deprecated
public Review setType(String s) {
this.type = s;
- // the following code is only here to ensure backward compatibility with 2.8
- if ("FALSE_POSITIVE".equals(type)) {
- falsePositive = Boolean.TRUE;
- } else if ("VIOLATION".equals(type)) {
- falsePositive = Boolean.FALSE;
- }
return this;
}
/**
- * @return the status
+ * @return status
*/
public String getStatus() {
return status;
}
- /**
- * @param status
- * the status to set
- */
public Review setStatus(String status) {
this.status = status;
return this;
}
/**
- * @return the severity
+ * @return severity
*/
public String getSeverity() {
return severity;
}
- /**
- * @param severity
- * the severity to set
- */
public Review setSeverity(String severity) {
this.severity = severity;
return this;
}
/**
- * @return the resourceKee
+ * @return resourceKee
*/
public String getResourceKee() {
return resourceKee;
}
- /**
- * @param resourceKee
- * the resourceKee to set
- */
public Review setResourceKee(String resourceKee) {
this.resourceKee = resourceKee;
return this;
}
/**
- * @return the line
+ * @return line
*/
public Integer getLine() {
return line;
}
- /**
- * @param line
- * the line to set
- */
public Review setLine(Integer line) {
this.line = line;
return this;
@@ -231,41 +182,34 @@ public class Review extends Model {
/**
* @since 2.9
- * @return the falsePositive
*/
- public Boolean getFalsePositive() {
- return falsePositive;
+ public String getResolution() {
+ return resolution;
}
/**
* @since 2.9
- * @param falsePositive
- * true if false positive
*/
- public Review setFalsePositive(Boolean falsePositive) {
- this.falsePositive = falsePositive;
+ public Review setResolution(String resolution) {
+ this.resolution = resolution;
return this;
}
/**
* @since 2.9
- * @return the violation id
+ * @return 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
+ * @return comments
*/
public List<Review.Comment> getComments() {
return comments;
@@ -295,28 +239,28 @@ public class Review extends Model {
/**
* @since 2.9
- * @return the id
+ * @return id
*/
public Long getId() {
return id;
}
/**
- * @return the authorLogin
+ * @return user that created this comment
*/
public String getAuthorLogin() {
return authorLogin;
}
/**
- * @return the updatedAt
+ * @return date of last modification
*/
public Date getUpdatedAt() {
return updatedAt;
}
/**
- * @return the text
+ * @return text
*/
public String getText() {
return text;
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewCreateQuery.java
index f48eb971e19..11fc0b5afa3 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewCreateQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewCreateQuery.java
@@ -25,58 +25,14 @@ package org.sonar.wsclient.services;
public class ReviewCreateQuery extends CreateQuery<Review> {
private Long violationId;
- private String text;
+ private String comment;
private String assignee;
- private Boolean falsePositive;
+ private String status;
+ private String resolution;
public ReviewCreateQuery() {
}
- /**
- * Builds a request that will create a simple review on a violation, without any assignee.
- *
- * @param violationId
- * The id of the violation that is reviewed
- * @param text
- * The comment of the review
- */
- public static ReviewCreateQuery createSimpleReviewQuery(Long violationId, String text) {
- ReviewCreateQuery query = new ReviewCreateQuery();
- query.setText(text);
- query.setViolationId(violationId);
- return query;
- }
-
- /**
- * Builds a request that will create a simple review on a violation and that will be assigned to the given user.
- *
- * @param violationId
- * The id of the violation that is reviewed
- * @param text
- * The comment of the review
- * @param userLogin
- * The login of the user whom this review will be assigned to
- */
- public static ReviewCreateQuery createAssignedReviewQuery(Long violationId, String text, String userLogin) {
- ReviewCreateQuery query = createSimpleReviewQuery(violationId, text);
- query.setAssignee(userLogin);
- return query;
- }
-
- /**
- * Builds a request that will create a false-positive review on a violation.
- *
- * @param violationId
- * The id of the violation that is reviewed
- * @param text
- * The comment of the review
- */
- public static ReviewCreateQuery createFalsePositiveReviewQuery(Long violationId, String text) {
- ReviewCreateQuery query = createSimpleReviewQuery(violationId, text);
- query.setFalsePositive(Boolean.TRUE);
- return query;
- }
-
public Long getViolationId() {
return violationId;
}
@@ -86,12 +42,12 @@ public class ReviewCreateQuery extends CreateQuery<Review> {
return this;
}
- public String getText() {
- return text;
+ public String getComment() {
+ return comment;
}
- public ReviewCreateQuery setText(String text) {
- this.text = text;
+ public ReviewCreateQuery setComment(String comment) {
+ this.comment = comment;
return this;
}
@@ -104,34 +60,41 @@ public class ReviewCreateQuery extends CreateQuery<Review> {
return this;
}
- public Boolean getFalsePositive() {
- return falsePositive;
+ public String getStatus() {
+ return status;
+ }
+
+ public ReviewCreateQuery setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+
+ public String getResolution() {
+ return resolution;
}
- public ReviewCreateQuery setFalsePositive(Boolean falsePositive) {
- this.falsePositive = falsePositive;
+ public ReviewCreateQuery setResolution(String resolution) {
+ this.resolution = resolution;
return this;
}
@Override
public String getUrl() {
StringBuilder url = new StringBuilder();
- url.append(ReviewQuery.BASE_URL);
- url.append("/");
- url.append('?');
+ url.append(ReviewQuery.BASE_URL).append('?');
appendUrlParameter(url, "violation_id", getViolationId());
- appendUrlParameter(url, "text", getText());
appendUrlParameter(url, "assignee", getAssignee());
- appendUrlParameter(url, "false_positive", getFalsePositive());
+ appendUrlParameter(url, "status", getStatus());
+ appendUrlParameter(url, "resolution", getResolution());
return url.toString();
}
/**
- * Property 'text' is transmitted through request body as content may exceed URL size allowed by the server.
+ * Property {@link #comment} is transmitted through request body as content may exceed URL size allowed by the server.
*/
@Override
public String getBody() {
- return text;
+ return comment;
}
@Override
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewDeleteQuery.java
deleted file mode 100644
index 5a217666607..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewDeleteQuery.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.wsclient.services;
-
-/**
- * @since 2.9
- */
-public class ReviewDeleteQuery extends DeleteQuery<Review> {
-
- private Long reviewId;
- private Long commentId;
-
- public ReviewDeleteQuery() {
- }
-
- /**
- * Builds a request that will delete the comment of a review. For the moment, only the last comment can be deleted, and only the author of
- * this comment is allowed to do so.
- *
- * @param reviewId
- * the id of the review
- * @param commentId
- * the id of the comment to delete
- */
- public static ReviewDeleteQuery deleteCommentQuery(Long reviewId, Long commentId) {
- ReviewDeleteQuery query = new ReviewDeleteQuery();
- query.reviewId = reviewId;
- query.commentId = commentId;
- return query;
- }
-
- public Long getReviewId() {
- return reviewId;
- }
-
- public ReviewDeleteQuery setReviewId(Long reviewId) {
- this.reviewId = reviewId;
- return this;
- }
-
- public Long getCommentId() {
- return commentId;
- }
-
- public ReviewDeleteQuery setCommentId(Long commentId) {
- this.commentId = commentId;
- return this;
- }
-
- @Override
- public String getUrl() {
- StringBuilder url = new StringBuilder();
- url.append(ReviewQuery.BASE_URL);
- url.append("/");
- url.append('?');
- appendUrlParameter(url, "id", getReviewId());
- appendUrlParameter(url, "comment_id", getCommentId());
- return url.toString();
- }
-}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
index 262cc9e4bfe..62e8cdd583a 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
@@ -24,121 +24,63 @@ package org.sonar.wsclient.services;
*/
public class ReviewUpdateQuery extends UpdateQuery<Review> {
- private Long reviewId;
- private String text;
- private String newText;
+ private long reviewId;
+ private String action;
+ private String comment;
private String assignee;
- private Boolean falsePositive;
- private String status;
-
- public ReviewUpdateQuery() {
- }
+ private String resolution;
/**
- * Builds a request that will add a comment on a an existing review.
- *
- * @param reviewId
- * The id of the review
- * @param text
- * The new comment
+ * Creates query to add comment to review.
*/
- public static ReviewUpdateQuery addCommentQuery(Long reviewId, String text) {
- ReviewUpdateQuery query = new ReviewUpdateQuery();
- query.setReviewId(reviewId);
- query.setNewText(text);
- return query;
+ public static ReviewUpdateQuery addComment(long id, String comment) {
+ return new ReviewUpdateQuery(id, "add_comment").setComment(comment);
}
/**
- * Builds a request that will update the false-positive status of an existing review.
- *
- * @param reviewId
- * The id of the review
- * @param text
- * The comment for this modification
- * @param falsePositive
- * the new false positive status of the review
+ * Creates query to reassign review.
*/
- public static ReviewUpdateQuery updateFalsePositiveQuery(Long reviewId, String text, Boolean falsePositive) {
- ReviewUpdateQuery query = addCommentQuery(reviewId, text);
- query.setFalsePositive(falsePositive);
- return query;
+ public static ReviewUpdateQuery reassign(long id, String assignee) {
+ return new ReviewUpdateQuery(id, "reassign").setAssignee(assignee);
}
/**
- * Builds a request that will reassign an existing review to the given user. <br/>
- * <br/>
- * To unassign the review, simply pass "none" for the user login.
+ * Creates query to resolve review.
+ * If resolution "FALSE-POSITIVE", then you must provide comment using {@link #setComment(String)}.
+ * Otherwise comment is optional.
*
- * @param reviewId
- * The id of the review that is reviewed
- * @param userLogin
- * The login of the user whom this review will be assigned to, or "none" to unassign
+ * @param resolution
+ * can be "FIXED" or "FALSE-POSITIVE"
*/
- public static ReviewUpdateQuery reassignQuery(Long reviewId, String userLogin) {
- ReviewUpdateQuery query = new ReviewUpdateQuery();
- query.setReviewId(reviewId);
- query.setAssignee(userLogin);
- return query;
+ public static ReviewUpdateQuery resolve(long id, String resolution) {
+ return new ReviewUpdateQuery(id, "resolve").setResolution(resolution);
}
/**
- * Builds a request that will edit the last comment of a an existing review (if the last comment belongs to the current user).
- *
- * @param reviewId
- * The id of the review
- * @param text
- * The new text for the last comment
+ * Creates query to reopen review.
+ * If review was resolved as "FALSE-POSITIVE", then you must provide comment using {@link #setComment(String)}.
+ * Otherwise comment is optional.
*/
- public static ReviewUpdateQuery editLastCommentQuery(Long reviewId, String text) {
- ReviewUpdateQuery query = new ReviewUpdateQuery();
- query.setReviewId(reviewId);
- query.setText(text);
- return query;
+ public static ReviewUpdateQuery reopen(long id) {
+ return new ReviewUpdateQuery(id, "reopen");
}
- /**
- * Builds a request that will change the status of a an existing review.<br/>
- * <br/>
- * Currently, only "RESOLVED" and "REOPENED" are supported.
- *
- * @param reviewId
- * The id of the review
- * @param status
- * The new status
- */
- public static ReviewUpdateQuery changeStatusQuery(Long reviewId, String status) {
- ReviewUpdateQuery query = new ReviewUpdateQuery();
- query.setReviewId(reviewId);
- query.setStatus(status);
- return query;
+ private ReviewUpdateQuery(long id, String action) {
+ this.reviewId = id;
+ this.action = action;
}
- public Long getReviewId() {
+ public long getReviewId() {
return reviewId;
}
- public ReviewUpdateQuery setReviewId(Long reviewId) {
- this.reviewId = reviewId;
+ public ReviewUpdateQuery setComment(String comment) {
+ this.comment = comment;
return this;
}
- public String getText() {
- return text;
- }
-
- public ReviewUpdateQuery setText(String text) {
- this.text = text;
- return this;
- }
-
- public String getNewText() {
- return newText;
- }
-
- public ReviewUpdateQuery setNewText(String text) {
- this.newText = text;
- return this;
+ public String getComment() {
+ return comment;
}
public String getAssignee() {
@@ -150,45 +92,37 @@ public class ReviewUpdateQuery extends UpdateQuery<Review> {
return this;
}
- public Boolean getFalsePositive() {
- return falsePositive;
+ public String getResolution() {
+ return resolution;
}
- public ReviewUpdateQuery setFalsePositive(Boolean falsePositive) {
- this.falsePositive = falsePositive;
- return this;
- }
-
- public String getStatus() {
- return status;
- }
-
- public ReviewUpdateQuery setStatus(String status) {
- this.status = status;
+ /**
+ * @param resolution
+ * can be "FIXED" or "FALSE-POSITIVE"
+ */
+ public ReviewUpdateQuery setResolution(String resolution) {
+ this.resolution = resolution;
return this;
}
@Override
public String getUrl() {
StringBuilder url = new StringBuilder();
- url.append(ReviewQuery.BASE_URL);
- url.append("/");
- url.append('?');
- appendUrlParameter(url, "id", getReviewId());
- appendUrlParameter(url, "text", getText());
- appendUrlParameter(url, "new_text", getNewText());
+ url.append(ReviewQuery.BASE_URL)
+ .append('/').append(action)
+ .append('/').append(reviewId)
+ .append('?');
appendUrlParameter(url, "assignee", getAssignee());
- appendUrlParameter(url, "false_positive", getFalsePositive());
- appendUrlParameter(url, "status", getStatus());
+ appendUrlParameter(url, "resolution", getResolution());
return url.toString();
}
/**
- * Properties 'text' or 'new_text' are transmitted through request body as content may exceed URL size allowed by the server.
+ * Property {@link #comment} transmitted through request body as content may exceed URL size allowed by the server.
*/
@Override
public String getBody() {
- return text == null ? newText : text;
+ return comment;
}
@Override
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshaller.java
index 3ea023700ea..a757c551a0d 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshaller.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshaller.java
@@ -42,7 +42,7 @@ public class ReviewUnmarshaller extends AbstractUnmarshaller<Review> {
review.setSeverity(utils.getString(json, "severity"));
review.setResourceKee(utils.getString(json, "resource"));
review.setLine(utils.getInteger(json, "line"));
- review.setFalsePositive(utils.getBoolean(json, "falsePositive"));
+ review.setResolution(utils.getString(json, "resolution"));
review.setViolationId(utils.getLong(json, "violationId"));
review.setType(utils.getString(json, "type"));
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewCreateQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewCreateQueryTest.java
index fd3ae931612..5559755a1fc 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewCreateQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewCreateQueryTest.java
@@ -27,22 +27,34 @@ import org.junit.Test;
public class ReviewCreateQueryTest extends QueryTestCase {
@Test
- public void testCreateSimpleReview() {
- ReviewCreateQuery query = ReviewCreateQuery.createSimpleReviewQuery(13L, "Hello World!");
- assertThat(query.getUrl(), is("/api/reviews/?violation_id=13&text=Hello+World%21&"));
+ public void testCreateReview() {
+ ReviewCreateQuery query = new ReviewCreateQuery()
+ .setViolationId(13L)
+ .setComment("Hello World!");
+ assertThat(query.getUrl(), is("/api/reviews?violation_id=13&"));
+ assertThat(query.getBody(), is("Hello World!"));
assertThat(query.getModelClass().getName(), is(Review.class.getName()));
}
@Test
public void testCreateAssignedReview() {
- ReviewCreateQuery query = ReviewCreateQuery.createAssignedReviewQuery(13L, "Hello World!", "fabrice");
- assertThat(query.getUrl(), is("/api/reviews/?violation_id=13&text=Hello+World%21&assignee=fabrice&"));
+ ReviewCreateQuery query = new ReviewCreateQuery()
+ .setViolationId(13L)
+ .setAssignee("fabrice")
+ .setComment("Hello World!");
+ assertThat(query.getUrl(), is("/api/reviews?violation_id=13&assignee=fabrice&"));
+ assertThat(query.getBody(), is("Hello World!"));
}
@Test
- public void testCreateFalsePositiveReview() {
- ReviewCreateQuery query = ReviewCreateQuery.createFalsePositiveReviewQuery(13L, "Hello World!");
- assertThat(query.getUrl(), is("/api/reviews/?violation_id=13&text=Hello+World%21&false_positive=true&"));
+ public void testCreateResolvedReview() {
+ ReviewCreateQuery query = new ReviewCreateQuery()
+ .setViolationId(13L)
+ .setStatus("RESOLVED")
+ .setResolution("FALSE-POSITIVE")
+ .setComment("Hello World!");
+ assertThat(query.getUrl(), is("/api/reviews?violation_id=13&status=RESOLVED&resolution=FALSE-POSITIVE&"));
+ assertThat(query.getBody(), is("Hello World!"));
}
-} \ No newline at end of file
+}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewDeleteQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewDeleteQueryTest.java
deleted file mode 100644
index d78bcf39baf..00000000000
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewDeleteQueryTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.wsclient.services;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-public class ReviewDeleteQueryTest extends QueryTestCase {
-
- @Test
- public void testAddComment() {
- ReviewDeleteQuery query = ReviewDeleteQuery.deleteCommentQuery(13L, 2L);
- assertThat(query.getUrl(), is("/api/reviews/?id=13&comment_id=2&"));
- }
-
-} \ No newline at end of file
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewUpdateQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewUpdateQueryTest.java
index 10620d92b82..bb0d783dd31 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewUpdateQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewUpdateQueryTest.java
@@ -19,6 +19,7 @@
*/
package org.sonar.wsclient.services;
+import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
@@ -28,33 +29,38 @@ public class ReviewUpdateQueryTest extends QueryTestCase {
@Test
public void testAddComment() {
- ReviewUpdateQuery query = ReviewUpdateQuery.addCommentQuery(13L, "Hello World!");
- assertThat(query.getUrl(), is("/api/reviews/?id=13&new_text=Hello+World%21&"));
+ ReviewUpdateQuery query = ReviewUpdateQuery.addComment(13, "Hello World!");
+ assertThat(query.getUrl(), is("/api/reviews/add_comment/13?"));
+ assertThat(query.getBody(), is("Hello World!"));
assertThat(query.getModelClass().getName(), is(Review.class.getName()));
}
@Test
- public void testEditLastComment() {
- ReviewUpdateQuery query = ReviewUpdateQuery.editLastCommentQuery(13L, "Hello World!");
- assertThat(query.getUrl(), is("/api/reviews/?id=13&text=Hello+World%21&"));
+ public void testReassign() {
+ ReviewUpdateQuery query = ReviewUpdateQuery.reassign(13, "fabrice");
+ assertThat(query.getUrl(), is("/api/reviews/reassign/13?assignee=fabrice&"));
+ assertThat(query.getBody(), nullValue());
}
@Test
- public void testReassign() {
- ReviewUpdateQuery query = ReviewUpdateQuery.reassignQuery(13L, "fabrice");
- assertThat(query.getUrl(), is("/api/reviews/?id=13&assignee=fabrice&"));
+ public void testResolveAsFalsePositive() {
+ ReviewUpdateQuery query = ReviewUpdateQuery.resolve(13, "FALSE-POSITIVE").setComment("Hello World!");
+ assertThat(query.getUrl(), is("/api/reviews/resolve/13?resolution=FALSE-POSITIVE&"));
+ assertThat(query.getBody(), is("Hello World!"));
}
@Test
- public void testUpdateFalsePositive() {
- ReviewUpdateQuery query = ReviewUpdateQuery.updateFalsePositiveQuery(13L, "Hello World!", Boolean.TRUE);
- assertThat(query.getUrl(), is("/api/reviews/?id=13&new_text=Hello+World%21&false_positive=true&"));
+ public void testResolveAsFixed() {
+ ReviewUpdateQuery query = ReviewUpdateQuery.resolve(13, "FIXED");
+ assertThat(query.getUrl(), is("/api/reviews/resolve/13?resolution=FIXED&"));
+ assertThat(query.getBody(), nullValue());
}
@Test
- public void testChangeStatus() {
- ReviewUpdateQuery query = ReviewUpdateQuery.changeStatusQuery(13L, "RESOLVED");
- assertThat(query.getUrl(), is("/api/reviews/?id=13&status=RESOLVED&"));
+ public void testReopen() {
+ ReviewUpdateQuery query = ReviewUpdateQuery.reopen(13);
+ assertThat(query.getUrl(), is("/api/reviews/reopen/13?"));
+ assertThat(query.getBody(), nullValue());
}
-} \ No newline at end of file
+}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java
index 9041c11a06a..dc9b512ed90 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java
@@ -24,12 +24,12 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-import java.util.List;
-
import org.junit.Test;
import org.sonar.wsclient.services.Review;
import org.sonar.wsclient.services.Review.Comment;
+import java.util.List;
+
public class ReviewUnmarshallerTest extends UnmarshallerTestCase {
@Test
@@ -50,8 +50,8 @@ public class ReviewUnmarshallerTest extends UnmarshallerTestCase {
assertThat(review.getAuthorLogin(), is("admin"));
assertThat(review.getAssigneeLogin(), is("admin"));
assertThat(review.getTitle(), is("'static' modifier out of order with the JLS suggestions."));
- assertThat(review.getFalsePositive(), is(Boolean.FALSE));
- assertThat(review.getStatus(), is("OPEN"));
+ assertThat(review.getStatus(), is("RESOLVED"));
+ assertThat(review.getResolution(), is("FALSE-POSITIVE"));
assertThat(review.getSeverity(), is("MINOR"));
assertThat(review.getResourceKee(), is("org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReaderConfiguration"));
assertThat(review.getLine(), is(33));
@@ -66,7 +66,8 @@ public class ReviewUnmarshallerTest extends UnmarshallerTestCase {
review = reviews.get(1);
assertThat(review.getAssigneeLogin(), nullValue());
- assertThat(review.getFalsePositive(), is(Boolean.TRUE));
+ assertThat(review.getStatus(), is("OPEN"));
+ assertThat(review.getResolution(), nullValue());
}
/*
diff --git a/sonar-ws-client/src/test/resources/reviews/reviews-2.9.json b/sonar-ws-client/src/test/resources/reviews/reviews-2.9.json
index 8b1f11c62a8..919b7ff9d8e 100644
--- a/sonar-ws-client/src/test/resources/reviews/reviews-2.9.json
+++ b/sonar-ws-client/src/test/resources/reviews/reviews-2.9.json
@@ -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,"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
+[{"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.","status":"RESOLVED","resolution":"FALSE-POSITIVE","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","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