diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-23 14:59:34 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-05-23 17:46:59 +0200 |
commit | f1187355aa041dc5dd183574bf43a52ca535db5f (patch) | |
tree | 216884f51336af7941227496ecd0606b9f9e26e7 /sonar-ws-client/src/test/java/org/sonar | |
parent | 6a0ee5725ed9fd514f177d9c07ade38cf1cf8272 (diff) | |
download | sonarqube-f1187355aa041dc5dd183574bf43a52ca535db5f.tar.gz sonarqube-f1187355aa041dc5dd183574bf43a52ca535db5f.zip |
SONAR-3755 remove code related to reviews and violations
Diffstat (limited to 'sonar-ws-client/src/test/java/org/sonar')
6 files changed, 8 insertions, 342 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 deleted file mode 100644 index a3fa37b3a78..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewCreateQueryTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class ReviewCreateQueryTest extends QueryTestCase { - - @Test - 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 = 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 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!")); - } - -} 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 deleted file mode 100644 index 6573973c64c..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.Test; - -public class ReviewQueryTest extends QueryTestCase { - - @Test - public void queryForResource() { - Resource resource = mock(Resource.class); - when(resource.getId()).thenReturn(69); - ReviewQuery query = ReviewQuery.createForResource(resource); - assertThat(query.getUrl(), is("/api/reviews?resources=69&")); - assertThat(query.getModelClass().getName(), is(Review.class.getName())); - } - - @Test - public void queryById() { - assertThat(new ReviewQuery().setId(13L).getUrl(), is("/api/reviews?ids=13&")); - assertThat(new ReviewQuery().setIds(10L, 11L).getUrl(), is("/api/reviews?ids=10,11&")); - } - - @Test - public void queryByResolution() { - ReviewQuery query = new ReviewQuery().setStatuses("RESOLVED").setResolutions("FALSE-POSITIVE"); - assertThat(query.getUrl(), is("/api/reviews?statuses=RESOLVED&resolutions=FALSE-POSITIVE&")); - } - - @Test - public void resourceTreeViolations() { - ReviewQuery query = new ReviewQuery() - .setStatuses("OPEN") - .setSeverities("MINOR", "INFO") - .setProjectKeysOrIds("com.sonar.foo:bar") - .setResourceKeysOrIds("2", "3") - .setAuthorLogins("foo") - .setAssigneeLogins("admin") - .setOutput("html"); - assertThat( - query.getUrl(), - is("/api/reviews?statuses=OPEN&severities=MINOR,INFO&projects=com.sonar.foo%3Abar&resources=2,3&authors=foo&assignees=admin&output=html&")); - } - - @Test - public void resourceTreeViolationsForSonar2_8() { - ReviewQuery query = new ReviewQuery(); - query.setIds(10L, 11L).setReviewType("FALSE_POSITIVE").setStatuses("OPEN").setSeverities("MINOR", "INFO") - .setProjectKeysOrIds("com.sonar.foo:bar").setResourceKeysOrIds("2", "3").setAuthorLogins("foo").setAssigneeLogins("admin") - .setOutput("html"); - assertThat( - query.getUrl(), - is("/api/reviews?ids=10,11&statuses=OPEN&severities=MINOR,INFO&projects=com.sonar.foo%3Abar&resources=2,3&authors=foo&assignees=admin&output=html&review_type=FALSE_POSITIVE&")); - } - - // http://jira.codehaus.org/browse/SONAR-3283 - @Test - public void testDeprecatedQueryByUserOrAssigneeId() throws Exception { - // the de deprecated setters - ReviewQuery query = new ReviewQuery() - .setAuthorLoginsOrIds("20") - .setAssigneeLoginsOrIds("40"); - assertThat(query.getAuthorLogins(), is(new String[] {"20"})); - assertThat(query.getAssigneeLogins(), is(new String[] {"40"})); - - // and test the deprecated getters - query = new ReviewQuery() - .setAuthorLogins("foo") - .setAssigneeLogins("bar"); - assertThat(query.getAuthorLoginsOrIds(), is(new String[] {"foo"})); - assertThat(query.getAssigneeLoginsOrIds(), is(new String[] {"bar"})); - } -} 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 deleted file mode 100644 index e81e3f91534..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewUpdateQueryTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class ReviewUpdateQueryTest extends QueryTestCase { - - @Test - public void testAddComment() { - 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 testReassign() { - ReviewUpdateQuery query = ReviewUpdateQuery.reassign(13, "fabrice"); - assertThat(query.getUrl(), is("/api/reviews/reassign/13?assignee=fabrice&")); - assertThat(query.getBody(), nullValue()); - } - - @Test - 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 testResolveAsFixed() { - ReviewUpdateQuery query = ReviewUpdateQuery.resolve(13, "FIXED"); - assertThat(query.getUrl(), is("/api/reviews/resolve/13?resolution=FIXED&")); - assertThat(query.getBody(), nullValue()); - } - - @Test - public void testReopen() { - ReviewUpdateQuery query = ReviewUpdateQuery.reopen(13); - assertThat(query.getUrl(), is("/api/reviews/reopen/13?")); - assertThat(query.getBody(), nullValue()); - } - -} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java index 0acea23d356..6da64d96cc1 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java @@ -40,10 +40,9 @@ public class ViolationQueryTest extends QueryTestCase { .setLimit(20) .setSeverities("MAJOR", "BLOCKER") .setQualifiers("FIL") - .setRuleKeys("checkstyle:foo", "pmd:bar") - .setOutput("html"); + .setRuleKeys("checkstyle:foo", "pmd:bar"); assertThat( query.getUrl(), - is("/api/violations?resource=myproject&depth=-1&limit=20&qualifiers=FIL&rules=checkstyle%3Afoo,pmd%3Abar&priorities=MAJOR,BLOCKER&output=html&")); + is("/api/violations?resource=myproject&depth=-1&limit=20&qualifiers=FIL&rules=checkstyle%3Afoo,pmd%3Abar&priorities=MAJOR,BLOCKER&")); } } 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 deleted file mode 100644 index 1d3492862b9..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ReviewUnmarshallerTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -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 - public void testEmptyJSON() { - Review review = new ReviewUnmarshaller().toModel("[]"); - assertThat(review, nullValue()); - } - - @Test - public void testToModels() { - List<Review> reviews = new ReviewUnmarshaller().toModels(loadFile("/reviews/reviews-2.9.json")); - assertThat(reviews.size(), is(2)); - - Review review = reviews.get(0); - assertThat(review.getId(), is(3L)); - assertNotNull(review.getCreatedAt()); - assertNotNull(review.getUpdatedAt()); - 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.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)); - assertThat(review.getViolationId(), is(1L)); - List<Comment> comments = review.getComments(); - assertThat(comments.size(), is(4)); - Comment comment = comments.get(0); - assertThat(comment.getId(), is(1L)); - assertNotNull(comment.getUpdatedAt()); - assertThat(comment.getAuthorLogin(), is("admin")); - assertThat(comment.getText(), is("This is a review.<br/>And this is on multiple lines...<br/><br/><code>Wouhou!!!!!</code>")); - - review = reviews.get(1); - assertThat(review.getAssigneeLogin(), nullValue()); - assertThat(review.getStatus(), is("OPEN")); - assertThat(review.getResolution(), nullValue()); - } - - /* - * Test Unmarshaller with JSON data received from a Sonar 2.8 - */ - @Test - public void testToModelsForSonar2_8() { - List<Review> reviews = new ReviewUnmarshaller().toModels(loadFile("/reviews/reviews-2.8.json")); - assertThat(reviews.size(), is(2)); - - Review review = reviews.get(0); - assertThat(review.getAssigneeLogin(), nullValue()); - - review = reviews.get(1); - assertThat(review.getId(), is(3L)); - assertNotNull(review.getCreatedAt()); - assertNotNull(review.getUpdatedAt()); - 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.getType(), is("VIOLATION")); - assertThat(review.getStatus(), is("OPEN")); - assertThat(review.getSeverity(), is("MINOR")); - assertThat(review.getResourceKee(), is("org.codehaus.sonar:sonar-channel:org.sonar.channel.CodeReaderConfiguration")); - assertThat(review.getLine(), is(33)); - List<Comment> comments = review.getComments(); - assertThat(comments.size(), is(4)); - Comment comment = comments.get(0); - assertNotNull(comment.getUpdatedAt()); - assertThat(comment.getAuthorLogin(), is("admin")); - assertThat(comment.getText(), is("This is a review.<br/>And this is on multiple lines...<br/><br/><code>Wouhou!!!!!</code>")); - } - -} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java index d6449899f5d..1eccd7e3158 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java @@ -29,9 +29,13 @@ 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.Violation; +/** + * @deprecated in 3.6. Replaced by issues. + */ +@Deprecated + public class ViolationUnmarshallerTest extends UnmarshallerTestCase { @Test @@ -43,7 +47,7 @@ public class ViolationUnmarshallerTest extends UnmarshallerTestCase { assertThat(violations.size(), is(2)); violation = violations.get(0); - assertThat(violation.getId(), is(1L)); + assertThat(violation.getKey(), is("1")); assertThat(violation.getMessage(), is("throw java.lang.Exception")); assertThat(violation.hasLine(), is(true)); assertThat(violation.getLine(), is(97)); @@ -55,9 +59,7 @@ public class ViolationUnmarshallerTest extends UnmarshallerTestCase { is("org.apache.excalibur.components:excalibur-pool-instrumented:org.apache.avalon.excalibur.pool.TraceableResourceLimitingPool")); assertThat(violation.getResourceName(), is("TraceableResourceLimitingPool")); assertThat(violation.getResourceQualifier(), is("CLA")); - assertThat(violation.getResourceScope(), is("FIL")); assertThat(violation.isSwitchedOff(), is(false)); - assertThat(violation.getReview(), nullValue()); } @Test @@ -75,16 +77,6 @@ public class ViolationUnmarshallerTest extends UnmarshallerTestCase { assertThat(violation.isSwitchedOff(), is(true)); } - @Test - public void testViolationDecoratedWithReview() { - Violation violation = new ViolationUnmarshaller().toModel(loadFile("/violations/violation-with-review.json")); - Review review = violation.getReview(); - assertNotNull(review); - assertThat(review.getId(), is(3L)); - assertThat(review.getComments().size(), is(4)); - assertThat(review.getComments().get(1).getText(), is("<em>Bold on multiple line?</em>")); - } - /** * See http://jira.codehaus.org/browse/SONAR-2386 */ |