aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-05 18:24:51 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-06 09:25:17 +0200
commite6de0291526bcffff77a1ed43274907c392a33f3 (patch)
treeab5a1b2dc8c70741ab32aef9eb716653dc8f17e5 /sonar-ws-client
parentfc0d11260208d0e8c5f02c36963851da3c33c2f9 (diff)
downloadsonarqube-e6de0291526bcffff77a1ed43274907c392a33f3.tar.gz
sonarqube-e6de0291526bcffff77a1ed43274907c392a33f3.zip
SONAR-5271 Delete /api/violations WS
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java201
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java146
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java1
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java52
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java62
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java88
6 files changed, 0 insertions, 550 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java
deleted file mode 100644
index 58331369f8b..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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 javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.Date;
-
-/**
- * @deprecated in 3.6. Replaced by issues.
- */
-@Deprecated
-public class Violation extends Model {
-
- private String message = null;
- private String severity = null;
- private Integer line = null;
- private String ruleKey = null;
- private String ruleName = null;
- private String resourceKey = null;
- private String resourceName = null;
- private String resourceQualifier = null;
- private Date createdAt = null;
- private boolean switchedOff;
-
- @CheckForNull
- public String getMessage() {
- return message;
- }
-
- public void setMessage(@Nullable String message) {
- this.message = message;
- }
-
- /**
- * @since 2.5
- */
- @CheckForNull
- public String getSeverity() {
- return severity;
- }
-
- /**
- * @since 2.5
- */
- public void setSeverity(@Nullable String severity) {
- this.severity = severity;
- }
-
- /**
- * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public String getPriority() {
- return severity;
- }
-
- /**
- * @deprecated since 2.5 use {@link #setSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public void setPriority(String priority) {
- this.severity = priority;
- }
-
- /**
- * @return line number (numeration starts from 1), or <code>null</code> if violation doesn't belong to concrete line
- * @see #hasLine()
- */
- @CheckForNull
- public Integer getLine() {
- return line;
- }
-
- public void setLine(@Nullable Integer line) {
- if (line != null && line < 1) {
- /*
- * This shouldn't happen, however line would be normalized to null if web service returns incorrect value (less than 1) in compliance
- * with a contract for getLine method. Normalization added in 2.8 - see http://jira.codehaus.org/browse/SONAR-2386
- */
- this.line = null;
- } else {
- this.line = line;
- }
- }
-
- /**
- * @return <code>true<code> if violation belongs to concrete line
- * @since 2.8
- */
- public boolean hasLine() {
- return line != null;
- }
-
- @Nullable
- public String getResourceKey() {
- return resourceKey;
- }
-
- public void setResourceKey(@Nullable String resourceKey) {
- this.resourceKey = resourceKey;
- }
-
- @CheckForNull
- public String getRuleKey() {
- return ruleKey;
- }
-
- public Violation setRuleKey(@Nullable String s) {
- this.ruleKey = s;
- return this;
- }
-
- @CheckForNull
- public String getRuleName() {
- return ruleName;
- }
-
- public Violation setRuleName(@Nullable String ruleName) {
- this.ruleName = ruleName;
- return this;
- }
-
- @CheckForNull
- public String getResourceName() {
- return resourceName;
- }
-
- public Violation setResourceName(@Nullable String resourceName) {
- this.resourceName = resourceName;
- return this;
- }
-
- @CheckForNull
- public String getResourceQualifier() {
- return resourceQualifier;
- }
-
- public Violation setResourceQualifier(@Nullable String resourceQualifier) {
- this.resourceQualifier = resourceQualifier;
- return this;
- }
-
- /**
- * @since 2.5
- */
- @CheckForNull
- public Date getCreatedAt() {
- return createdAt;
- }
-
- /**
- * @since 2.5
- */
- public Violation setCreatedAt(@Nullable Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public boolean isCreatedAfter(Date date) {
- return createdAt != null && date != null && createdAt.after(date);
- }
-
- /**
- * @since 2.8
- */
- public Violation setSwitchedOff(@Nullable Boolean b) {
- this.switchedOff = (b != null && b);
- return this;
- }
-
- /**
- * @since 2.8
- */
- @Nullable
- public boolean isSwitchedOff() {
- return switchedOff;
- }
-
-}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
deleted file mode 100644
index db753d01ece..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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;
-
-/**
- * @deprecated in 3.6. Replaced by issues.
- */
-@Deprecated
-public class ViolationQuery extends Query<Violation> {
-
- public static final String BASE_URL = "/api/violations";
-
- private String resourceKey;
- private int depth = 0;
- private String[] qualifiers;
- private String[] ruleKeys;
- private String[] severities;
- private Integer limit;
-
- public ViolationQuery(String resourceKey) {
- this.resourceKey = resourceKey;
- }
-
- public String[] getQualifiers() {
- return qualifiers;
- }
-
- public ViolationQuery setQualifiers(String... qualifiers) {
- this.qualifiers = qualifiers;
- return this;
- }
-
- public String[] getRuleKeys() {
- return ruleKeys;
- }
-
- public ViolationQuery setRuleKeys(String... ruleKeys) {
- this.ruleKeys = ruleKeys;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public String[] getSeverities() {
- return severities;
- }
-
- /**
- * @since 2.5
- */
- public ViolationQuery setSeverities(String... severities) {
- this.severities = severities;
- return this;
- }
-
- /**
- * @deprecated since 2.5 use {@link #getSeverities()} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public String[] getPriorities() {
- return severities;
- }
-
- /**
- * @deprecated since 2.5 use {@link #setSeverities(String...)} instead. See http://jira.codehaus.org/browse/SONAR-1829
- */
- @Deprecated
- public ViolationQuery setPriorities(String... priorities) {
- this.severities = priorities;
- return this;
- }
-
- public int getDepth() {
- return depth;
- }
-
- public ViolationQuery setDepth(int depth) {
- this.depth = depth;
- return this;
- }
-
- /**
- * @since 2.5
- */
- public Integer getLimit() {
- return limit;
- }
-
- /**
- * @since 2.5
- */
- public ViolationQuery setLimit(Integer limit) {
- this.limit = limit;
- return this;
- }
-
- @Override
- public String getUrl() {
- StringBuilder url = new StringBuilder(BASE_URL);
- url.append('?');
- appendUrlParameter(url, "resource", resourceKey);
- if (depth != 0) {
- url.append("depth=").append(depth).append("&");
- }
- appendUrlParameter(url, "limit", limit);
- appendUrlParameter(url, "qualifiers", qualifiers);
- appendUrlParameter(url, "rules", ruleKeys);
- appendUrlParameter(url, "priorities", severities);
- return url.toString();
- }
-
- @Override
- public Class<Violation> getModelClass() {
- return Violation.class;
- }
-
- public static ViolationQuery createForResource(Resource resource) {
- Integer id = resource.getId();
- if (id == null) {
- throw new IllegalArgumentException("id must be set");
- }
- return new ViolationQuery(id.toString());
- }
-
- public static ViolationQuery createForResource(String resourceIdOrKey) {
- return new ViolationQuery(resourceIdOrKey);
- }
-}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java
index 503fd1d35dd..db799b35c86 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java
@@ -37,7 +37,6 @@ public final class Unmarshallers {
unmarshallers.put(Resource.class, new ResourceUnmarshaller());
unmarshallers.put(Property.class, new PropertyUnmarshaller());
unmarshallers.put(Source.class, new SourceUnmarshaller());
- unmarshallers.put(Violation.class, new ViolationUnmarshaller());
unmarshallers.put(Server.class, new ServerUnmarshaller());
unmarshallers.put(ServerSetup.class, new ServerSetupUnmarshaller());
unmarshallers.put(DependencyTree.class, new DependencyTreeUnmarshaller());
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java
deleted file mode 100644
index 007cd4dd7fb..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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 org.sonar.wsclient.services.Violation;
-import org.sonar.wsclient.services.WSUtils;
-
-public class ViolationUnmarshaller extends AbstractUnmarshaller<Violation> {
-
- @Override
- protected Violation parse(Object json) {
- WSUtils utils = WSUtils.getINSTANCE();
-
- Violation violation = new Violation();
- violation.setMessage(utils.getString(json, "message"));
- violation.setLine(utils.getInteger(json, "line"));
- violation.setSeverity(utils.getString(json, "priority"));
- violation.setCreatedAt(utils.getDateTime(json, "createdAt"));
- violation.setSwitchedOff(utils.getBoolean(json, "switchedOff"));
-
- Object rule = utils.getField(json, "rule");
- if (rule != null) {
- violation.setRuleKey(utils.getString(rule, "key"));
- violation.setRuleName(utils.getString(rule, "name"));
- }
-
- Object resource = utils.getField(json, "resource");
- if (resource != null) {
- violation.setResourceKey(utils.getString(resource, "key"));
- violation.setResourceName(utils.getString(resource, "name"));
- violation.setResourceQualifier(utils.getString(resource, "qualifier"));
- }
- return violation;
- }
-}
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
deleted file mode 100644
index 8ee353258a1..00000000000
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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 org.junit.Test;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class ViolationQueryTest extends QueryTestCase {
-
- @Test
- public void should_create_query() {
- ViolationQuery query = ViolationQuery.createForResource("myproject:org.foo:bar");
- assertThat(query.getUrl()).isEqualTo("/api/violations?resource=myproject%3Aorg.foo%3Abar&");
- assertThat(query.getModelClass().getName()).isEqualTo(Violation.class.getName());
- }
-
- @Test
- public void should_create_query_tree() {
- ViolationQuery query = ViolationQuery.createForResource("myproject")
- .setDepth(-1)
- .setLimit(20)
- .setSeverities("MAJOR", "BLOCKER")
- .setQualifiers("FIL")
- .setRuleKeys("checkstyle:foo", "pmd:bar");
- assertThat(query.getUrl()).isEqualTo(
- "/api/violations?resource=myproject&depth=-1&limit=20&qualifiers=FIL&rules=checkstyle%3Afoo,pmd%3Abar&priorities=MAJOR,BLOCKER&");
- }
-
- @Test
- public void should_create_query_from_resource() {
- ViolationQuery query = ViolationQuery.createForResource(new Resource().setId(1));
- assertThat(query.getUrl()).isEqualTo("/api/violations?resource=1&");
- assertThat(query.getModelClass().getName()).isEqualTo(Violation.class.getName());
- }
-
- @Test
- public void should_not_create_query_from_resource_without_id() {
- try {
- ViolationQuery.createForResource(new Resource());
- } catch (Exception e) {
- assertThat(e).isInstanceOf(IllegalArgumentException.class);
- }
- }
-}
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
deleted file mode 100644
index 45168d09de9..00000000000
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.core.IsNot.not;
-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.Violation;
-
-/**
- * @deprecated in 3.6. Replaced by issues.
- */
-@Deprecated
-
-public class ViolationUnmarshallerTest extends UnmarshallerTestCase {
-
- @Test
- public void testToModels() {
- Violation violation = new ViolationUnmarshaller().toModel("[]");
- assertThat(violation, nullValue());
-
- List<Violation> violations = new ViolationUnmarshaller().toModels(loadFile("/violations/violations.json"));
- assertThat(violations.size(), is(2));
-
- violation = violations.get(0);
- assertThat(violation.getMessage(), is("throw java.lang.Exception"));
- assertThat(violation.hasLine(), is(true));
- assertThat(violation.getLine(), is(97));
- assertThat(violation.getCreatedAt(), notNullValue());
- assertThat(violation.getSeverity(), is("MAJOR"));
- assertThat(violation.getRuleKey(), is("pmd:SignatureDeclareThrowsException"));
- assertThat(violation.getRuleName(), is("Signature Declare Throws Exception"));
- assertThat(violation.getResourceKey(),
- 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.isSwitchedOff(), is(false));
- }
-
- @Test
- public void testViolationWithoutLineNumber() {
- Violation violation = new ViolationUnmarshaller().toModel(loadFile("/violations/violation-without-optional-fields.json"));
- assertThat(violation.getMessage(), not(nullValue()));
- assertThat(violation.hasLine(), is(false));
- assertThat(violation.getLine(), nullValue());
- assertThat(violation.getCreatedAt(), nullValue());
- }
-
- @Test
- public void testSwitchedOff() {
- Violation violation = new ViolationUnmarshaller().toModel(loadFile("/violations/false-positive.json"));
- assertThat(violation.isSwitchedOff(), is(true));
- }
-
- /**
- * See http://jira.codehaus.org/browse/SONAR-2386
- */
- @Test
- public void testIncorrectLine() {
- Violation violation = new ViolationUnmarshaller().toModel(loadFile("/violations/violation-with-incorrect-line.json"));
- assertThat(violation.hasLine(), is(false));
- assertThat(violation.getLine(), nullValue());
- }
-}