aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-ws-client/src/test')
-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
5 files changed, 49 insertions, 65 deletions
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