aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-05-22 19:02:07 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-05-22 19:02:17 +0200
commita6f343fe406d85b585609d2c93d3a7c9dad84a17 (patch)
tree26866c9d204542c137dca1590ff96534cfc5f978 /sonar-ws-client
parent4f9419017c1d412b6ed8a5652f1a5069ba2485ed (diff)
downloadsonarqube-a6f343fe406d85b585609d2c93d3a7c9dad84a17.tar.gz
sonarqube-a6f343fe406d85b585609d2c93d3a7c9dad84a17.zip
SONAR-5007 remove wsclient of deleted api/rules/index
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java9
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java26
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Rule.java124
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleParam.java66
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleQuery.java113
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/RuleUnmarshaller.java90
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java1
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java12
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java30
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java44
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java59
-rw-r--r--sonar-ws-client/src/test/resources/rules/rules.json8
12 files changed, 0 insertions, 582 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java
index e7189251c11..c59588f1e73 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java
@@ -25,13 +25,4 @@ package org.sonar.wsclient.rule;
*/
public interface RuleClient {
- /**
- * Associate new tags to a rule
- */
- void addTags(String key, String... tags);
-
- /**
- * Remove tags from a rule
- */
- void removeTags(String key, String... tags);
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java
index 6955d32c871..e6d7f98ec0e 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java
@@ -22,17 +22,12 @@ package org.sonar.wsclient.rule.internal;
import org.sonar.wsclient.internal.HttpRequestFactory;
import org.sonar.wsclient.rule.RuleClient;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#ruleClient()}.
*/
public class DefaultRuleClient implements RuleClient {
private static final String ROOT_URL = "/api/rules";
- private static final String ADD_TAGS_URL = ROOT_URL + "/add_tags";
- private static final String REMOVE_TAGS_URL = ROOT_URL + "/remove_tags";
private final HttpRequestFactory requestFactory;
@@ -40,25 +35,4 @@ public class DefaultRuleClient implements RuleClient {
this.requestFactory = requestFactory;
}
- @Override
- public void addTags(String key, String... tags) {
- requestFactory.post(ADD_TAGS_URL, buildQueryParams(key, tags));
- }
-
- @Override
- public void removeTags(String key, String... tags) {
- requestFactory.post(REMOVE_TAGS_URL, buildQueryParams(key, tags));
- }
-
- private Map<String, Object> buildQueryParams(String key, String... tags) {
- Map<String, Object> params = new HashMap<String, Object>();
- params.put("key", key);
- StringBuilder tagsBuilder = new StringBuilder();
- for (int i=0; i < tags.length - 1; i++) {
- tagsBuilder.append(tags[i]).append(",");
- }
- tagsBuilder.append(tags[tags.length - 1]);
- params.put("tags", tagsBuilder.toString());
- return params;
- }
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Rule.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Rule.java
deleted file mode 100644
index a32bddc4f9f..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Rule.java
+++ /dev/null
@@ -1,124 +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.List;
-
-/**
- * @since 2.5
- */
-public class Rule extends Model {
-
- private String title = null;
- private String key = null;
- private String configKey = null;
- private String repository = null;
- private String description = null;
- private String severity = null;
- private List<RuleParam> params;
- private boolean active;
-
- @CheckForNull
- public String getTitle() {
- return title;
- }
-
- public Rule setTitle(@Nullable String title) {
- this.title = title;
- return this;
- }
-
- @CheckForNull
- public String getKey() {
- return key;
- }
-
- public Rule setKey(@Nullable String key) {
- this.key = key;
- return this;
- }
-
- /**
- * @since 2.7
- */
- @CheckForNull
- public String getConfigKey() {
- return configKey;
- }
-
- /**
- * @since 2.7
- */
-
- public Rule setConfigKey(@Nullable String s) {
- this.configKey = s;
- return this;
- }
-
- @CheckForNull
- public String getRepository() {
- return repository;
- }
-
- public Rule setRepository(@Nullable String s) {
- this.repository = s;
- return this;
- }
-
- @CheckForNull
- public String getDescription() {
- return description;
- }
-
- public Rule setDescription(@Nullable String description) {
- this.description = description;
- return this;
- }
-
- @CheckForNull
- public String getSeverity() {
- return severity;
- }
-
- public Rule setSeverity(@Nullable String severity) {
- this.severity = severity;
- return this;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- public boolean isActive() {
- return active;
- }
-
- public List<RuleParam> getParams() {
- return params;
- }
-
- public void setParams(List<RuleParam> params) {
- this.params = params;
- }
-
-}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleParam.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleParam.java
deleted file mode 100644
index e70281e9e98..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleParam.java
+++ /dev/null
@@ -1,66 +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;
-
-/**
- * @since 2.5
- */
-public class RuleParam {
-
- private String name;
-
- private String description;
-
- private String value;
-
- @CheckForNull
- public String getName() {
- return name;
- }
-
- public RuleParam setName(@Nullable String name) {
- this.name = name;
- return this;
- }
-
- @CheckForNull
- public String getDescription() {
- return description;
- }
-
- public RuleParam setDescription(@Nullable String description) {
- this.description = description;
- return this;
- }
-
- @CheckForNull
- public String getValue() {
- return value;
- }
-
- public RuleParam setValue(@Nullable String value) {
- this.value = value;
- return this;
- }
-
-}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleQuery.java
deleted file mode 100644
index 377dbf03fdf..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/RuleQuery.java
+++ /dev/null
@@ -1,113 +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;
-
-/**
- * @since 2.5
- */
-public class RuleQuery extends Query<Rule> {
- public static final String BASE_URL = "/api/rules";
-
- private String language;
- private String[] repositories;
- private String searchText;
- private String profile;
- private String[] severities;
- private Boolean active;
-
- public RuleQuery(String language) {
- this.language = language;
- }
-
- public RuleQuery setLanguage(String language) {
- this.language = language;
- return this;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public RuleQuery setRepositories(String... s) {
- this.repositories = s;
- return this;
- }
-
- public String[] getRepositories() {
- return repositories;
- }
-
- public RuleQuery setSearchText(String searchText) {
- this.searchText = searchText;
- return this;
- }
-
- public String getSearchText() {
- return searchText;
- }
-
- public RuleQuery setProfile(String profile) {
- this.profile = profile;
- return this;
- }
-
- public String getProfile() {
- return profile;
- }
-
- public RuleQuery setSeverities(String... severities) {
- this.severities = severities;
- return this;
- }
-
- public String[] getSeverities() {
- return severities;
- }
-
- public RuleQuery setActive(Boolean active) {
- this.active = active;
- return this;
- }
-
- public Boolean getStatus() {
- return active;
- }
-
- @Override
- public String getUrl() {
- StringBuilder url = new StringBuilder(BASE_URL);
- url.append('?');
- appendUrlParameter(url, "language", language);
- appendUrlParameter(url, "plugins", repositories);
- appendUrlParameter(url, "searchtext", searchText);
- appendUrlParameter(url, "profile", profile);
- appendUrlParameter(url, "priorities", severities);
- if (active != null) {
- appendUrlParameter(url, "status", active ? "ACTIVE" : "INACTIVE");
- }
- return url.toString();
- }
-
- @Override
- public Class<Rule> getModelClass() {
- return Rule.class;
- }
-
-}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/RuleUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/RuleUnmarshaller.java
deleted file mode 100644
index 2a9adb5c8e5..00000000000
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/RuleUnmarshaller.java
+++ /dev/null
@@ -1,90 +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.Rule;
-import org.sonar.wsclient.services.RuleParam;
-import org.sonar.wsclient.services.WSUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @since 2.5
- */
-public class RuleUnmarshaller extends AbstractUnmarshaller<Rule> {
-
- private static final String DESCRIPTION = "description";
-
- @Override
- protected Rule parse(Object json) {
- Rule rule = new Rule();
- parseRuleFields(json, rule);
- parseParams(json, rule);
- return rule;
- }
-
- private void parseRuleFields(Object json, Rule rule) {
- WSUtils utils = WSUtils.getINSTANCE();
-
- rule.setTitle(utils.getString(json, "title"))
- .setKey(utils.getString(json, "key"))
- .setConfigKey(utils.getString(json, "config_key"))
- .setRepository(utils.getString(json, "plugin"))
- .setDescription(utils.getString(json, DESCRIPTION))
- .setSeverity(utils.getString(json, "priority"))
- .setActive("ACTIVE".equals(utils.getString(json, "status")));
- }
-
- private void parseParams(Object json, Rule rule) {
- WSUtils utils = WSUtils.getINSTANCE();
-
- Object paramsJson = utils.getField(json, "params");
- if (paramsJson != null) {
- rule.setParams(parseParams(paramsJson));
- }
- }
-
- private List<RuleParam> parseParams(Object paramsJson) {
- WSUtils utils = WSUtils.getINSTANCE();
-
- List<RuleParam> ruleParams = new ArrayList<RuleParam>();
- int len = utils.getArraySize(paramsJson);
- for (int i = 0; i < len; i++) {
- Object paramJson = utils.getArrayElement(paramsJson, i);
- if (paramJson != null) {
- RuleParam param = parseParam(paramJson);
- ruleParams.add(param);
- }
- }
- return ruleParams;
- }
-
- private RuleParam parseParam(Object json) {
- WSUtils utils = WSUtils.getINSTANCE();
-
- RuleParam param = new RuleParam();
- param.setName(utils.getString(json, "name"))
- .setDescription(utils.getString(json, DESCRIPTION))
- .setValue(utils.getString(json, "value"));
- return param;
- }
-
-}
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 db799b35c86..094bc270cd3 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
@@ -43,7 +43,6 @@ public final class Unmarshallers {
unmarshallers.put(Event.class, new EventUnmarshaller());
unmarshallers.put(Favourite.class, new FavouriteUnmarshaller());
unmarshallers.put(Plugin.class, new PluginUnmarshaller());
- unmarshallers.put(Rule.class, new RuleUnmarshaller());
unmarshallers.put(TimeMachine.class, new TimeMachineUnmarshaller());
unmarshallers.put(Profile.class, new ProfileUnmarshaller());
unmarshallers.put(ManualMeasure.class, new ManualMeasureUnmarshaller());
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
index 31003b9090f..e35edc16be9 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
@@ -30,7 +30,6 @@ import org.sonar.wsclient.connectors.HttpClient4Connector;
import org.sonar.wsclient.services.Metric;
import org.sonar.wsclient.services.MetricQuery;
import org.sonar.wsclient.services.Query;
-import org.sonar.wsclient.services.RuleQuery;
import org.sonar.wsclient.services.Server;
import org.sonar.wsclient.services.ServerQuery;
import org.sonar.wsclient.unmarshallers.UnmarshalException;
@@ -116,17 +115,6 @@ public class SonarTest {
assertThat(server.getVersion(), is("2.0"));
}
- @Test
- public void shouldPropagateUnmarshalContext() {
- try {
- sonar.findAll(new RuleQuery("java"));
- fail();
- } catch (UnmarshalException ue) {
- assertThat(ue.getMessage(), containsString("/api/rules")); // contains request url
- assertThat(ue.getMessage(), containsString(BadRulesServlet.JSON)); // contains response
- }
- }
-
static class EmptyQuery extends Query<Metric> {
@Override
public String getUrl() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java
index 287fda23351..ac27da21700 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java
@@ -21,13 +21,9 @@ package org.sonar.wsclient.rule.internal;
import org.junit.Before;
import org.junit.Rule;
-import org.junit.Test;
import org.sonar.wsclient.MockHttpServerInterceptor;
import org.sonar.wsclient.internal.HttpRequestFactory;
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.MapAssert.entry;
-
public class DefaultRuleClientTest {
@Rule
@@ -41,30 +37,4 @@ public class DefaultRuleClientTest {
this.client = new DefaultRuleClient(requestFactory);
}
- @Test
- public void should_add_tags() {
- httpServer.stubStatusCode(200);
-
- final String ruleKey = "repo:rule1";
- client.addTags(ruleKey, "tag1", "tag2", "tag3");
-
- assertThat(httpServer.requestedPath()).isEqualTo("/api/rules/add_tags");
- assertThat(httpServer.requestParams()).includes(
- entry("key", ruleKey),
- entry("tags", "tag1,tag2,tag3"));
- }
-
- @Test
- public void should_remove_tags() {
- httpServer.stubStatusCode(200);
-
- final String ruleKey = "repo:rule1";
- client.removeTags(ruleKey, "tag1", "tag2", "tag3");
-
- assertThat(httpServer.requestedPath()).isEqualTo("/api/rules/remove_tags");
- assertThat(httpServer.requestParams()).includes(
- entry("key", ruleKey),
- entry("tags", "tag1,tag2,tag3"));
- }
-
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java
deleted file mode 100644
index aadbcceeeaa..00000000000
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java
+++ /dev/null
@@ -1,44 +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 static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-public class RuleQueryTest extends QueryTestCase {
-
- @Test
- public void languageRules() {
- RuleQuery query = new RuleQuery("java");
- assertThat(query.getUrl(), is("/api/rules?language=java&"));
- assertThat(query.getModelClass().getName(), is(Rule.class.getName()));
- }
-
- @Test
- public void inactiveRules() {
- assertThat(new RuleQuery("java").setActive(true).getUrl(),
- is("/api/rules?language=java&status=ACTIVE&"));
- assertThat(new RuleQuery("java").setActive(false).getUrl(),
- is("/api/rules?language=java&status=INACTIVE&"));
- }
-
-}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java
deleted file mode 100644
index ab77feada02..00000000000
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java
+++ /dev/null
@@ -1,59 +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.junit.Test;
-import org.sonar.wsclient.services.Rule;
-
-import java.util.List;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-public class RuleUnmarshallerTest extends UnmarshallerTestCase {
-
- @Test
- public void toModels() {
- Rule rule = new RuleUnmarshaller().toModel("[]");
- assertThat(rule, nullValue());
-
- List<Rule> rules = new RuleUnmarshaller().toModels("[]");
- assertThat(rules.size(), is(0));
-
- rules = new RuleUnmarshaller().toModels(loadFile("/rules/rules.json"));
- assertThat(rules.size(), is(6));
-
- rule = rules.get(0);
- assertThat(rule.getTitle(), is("Indentation"));
- assertThat(rule.getKey(), is("checkstyle:com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"));
- assertThat(rule.getRepository(), is("checkstyle"));
- assertThat(rule.getDescription(), is("Checks correct indentation of Java Code."));
- assertThat(rule.getSeverity(), is("MINOR"));
- assertThat(rule.isActive(), is(false));
- assertThat(rule.getParams().size(), is(3));
- assertThat(rule.getParams().get(0).getName(), is("basicOffset"));
- assertThat(rule.getParams().get(0).getDescription(), is("how many spaces to use for new indentation level. Default is 4."));
-
- rule = rules.get(1);
- assertThat(rule.isActive(), is(true));
- }
-
-}
diff --git a/sonar-ws-client/src/test/resources/rules/rules.json b/sonar-ws-client/src/test/resources/rules/rules.json
deleted file mode 100644
index d82255f571a..00000000000
--- a/sonar-ws-client/src/test/resources/rules/rules.json
+++ /dev/null
@@ -1,8 +0,0 @@
-[
- {"title":"Indentation","key":"checkstyle:com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck","category":"Usability","plugin":"checkstyle","description":"Checks correct indentation of Java Code.","priority":"MINOR","status":"INACTIVE","params":[{"name":"basicOffset","description":"how many spaces to use for new indentation level. Default is 4."},{"name":"braceAdjustment","description":"how far brace should be indented when on next line. Default is 0."},{"name":"caseIndent","description":"how much to indent a case label. Default is 4."}]},
- {"title":"Javadoc Method","key":"checkstyle:com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck","category":"Usability","plugin":"checkstyle","description":"Checks the Javadoc of a method or constructor. By default, does not check for unused throws. \n To allow documented java.lang.RuntimeExceptions that are not declared, set property allowUndeclaredRTE to true. \n The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE. \n To verify another scope, set property scope to a different scope.\n \n <br><br>Error messages about parameters and type parameters for which no param tags are present can be suppressed by defining property allowMissingParamTags. \n Error messages about exceptions which are declared to be thrown, but for which no throws tag is present can be suppressed by defining property allowMissingThrowsTags. \n Error messages about methods which return non-void but for which no return tag is present can be suppressed by defining property allowMissingReturnTag.\n\n <br><br>Javadoc is not required on a method that is tagged with the @Override annotation. \n However under Java 5 it is not possible to mark a method required for an interface (this was corrected under Java 6). \n Hence Checkstyle supports using the convention of using a single {@inheritDoc} tag instead of all the other tags.\n \n <br><br>Note that only inheritable items will allow the {@inheritDoc} tag to be used in place of comments. \n Static methods at all visibilities, private non-static methods and constructors are not inheritable.","priority":"MAJOR","status":"ACTIVE","params":[{"name":"scope","description":"visibility scope where Javadoc comments are checked"},{"name":"excludeScope","description":"visibility scope where Javadoc comments are not checked"},{"name":"allowUndeclaredRTE","description":"whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException. Default is false."},{"name":"allowThrowsTagsForSubclasses","description":"whether to allow documented exceptions that are subclass of one of declared exception. Default is false."},{"name":"allowMissingParamTags","description":"whether to ignore errors when a method has parameters but does not have matching param tags in the javadoc. Default is false."},{"name":"allowMissingThrowsTags","description":"whether to ignore errors when a method declares that it throws exceptions but does have matching throws tags in the javadoc. Default is false."},{"name":"allowMissingReturnTag","description":"whether to ignore errors when a method returns non-void type does have a return tag in the javadoc. Default is false."},{"name":"allowMissingJavadoc","description":"whether to ignore errors when a method javadoc is missed. Default is false."},{"name":"allowMissingPropertyJavadoc","description":"Whether to allow missing Javadoc on accessor methods for properties (setters and getters). The setter and getter methods must match exactly the structures below. <code> public void setNumber(final int number) { mNumber = number; } public int getNumber() { return mNumber; } public boolean isSomething() { return false; } </code>. Default is false."},{"name":"tokens","description":"definitions to check"}]},
- {"title":"Javadoc Package","key":"checkstyle:com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck","category":"Maintainability","plugin":"checkstyle","description":"<p>Checks that each Java package has a Javadoc file used for commenting. By default it only allows a package-info.java file, but can be configured to allow a package.html file. An error will be reported if both files exist as this is not allowed by the Javadoc tool.</p>","priority":"MINOR","status":"ACTIVE","params":[{"name":"allowLegacy","description":"If set then allow the use of a package.html file."}]},
- {"title":"Javadoc Style","key":"checkstyle:com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck","category":"Usability","plugin":"checkstyle","description":"Validates Javadoc comments to help ensure they are well formed. The following checks are performed:\n <ul>\n <li>Ensures the first sentence ends with proper punctuation (That is a period, question mark, or exclamation mark, by default). \n Javadoc automatically places the first sentence in the method summary table and index. With out proper punctuation the Javadoc may be malformed. \n All items eligible for the {@inheritDoc} tag are exempt from this requirement.</li>\n <li>Check text for Javadoc statements that do not have any description. \n This includes both completely empty Javadoc, and Javadoc with only tags such as @param and @return.</li>\n <li>Check text for incomplete HTML tags. Verifies that HTML tags have corresponding end tags and issues an \"Unclosed HTML tag found:\" error if not. \n An \"Extra HTML tag found:\" error is issued if an end tag is found without a previous open tag.</li>\n <li>Check that a package Javadoc comment is well-formed (as described above) and NOT missing from any package-info.java files.</li>\n <li>Check for allowed HTML tags. The list of allowed HTML tags is \"a\", \"abbr\", \"acronym\", \"address\", \"area\", \"b\", \n \"bdo\", \"big\", \"blockquote\", \"br\", \"caption\", \"cite\", \"code\", \"colgroup\", \"del\", \"div\", \"dfn\", \"dl\", \"em\", \"fieldset\", \n \"h1\" to \"h6\", \"hr\", \"i\", \"img\", \"ins\", \"kbd\", \"li\", \"ol\", \"p\", \"pre\", \"q\", \"samp\", \"small\", \"span\", \"strong\", \n \"sub\", \"sup\", \"table\", \"tbody\", \"td\", \"tfoot\", \"th\", \"thread\", \"tr\", \"tt\", \"ul\"</li>\n </ul>","priority":"MAJOR","status":"ACTIVE","params":[{"name":"scope","description":"visibility scope where Javadoc comments are checked"},{"name":"excludeScope","description":"visibility scope where Javadoc comments are not checked"},{"name":"checkFirstSentence","description":"Whether to check the first sentence for proper end of sentence. Default is true."},{"name":"checkEmptyJavadoc","description":"Whether to check if the Javadoc is missing a describing text. Default is false."},{"name":"checkHtml","description":"Whether to check for incomplete html tags. Default is true."},{"name":"tokens","description":"definitions to check"}]},
- {"title":"Javadoc Type","key":"checkstyle:com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck","category":"Usability","plugin":"checkstyle","description":"Checks Javadoc comments for class and interface definitions. By default, does not check for author or version tags. \n The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE. To verify another scope, set property scope to one of the Scope constants. \n To define the format for an author tag or a version tag, set property authorFormat or versionFormat respectively to a regular expression.\n <br><br>Error messages about type parameters for which no param tags are present can be suppressed by defining property allowMissingParamTags.","priority":"MAJOR","status":"ACTIVE","params":[{"name":"scope","description":"visibility scope where Javadoc comments are checked"},{"name":"excludeScope","description":"visibility scope where Javadoc comments are not checked"},{"name":"authorFormat","description":"pattern for @author tag"},{"name":"versionFormat","description":"pattern for @version tag"},{"name":"allowMissingParamTags","description":"whether to ignore errors when a class has type parameters but does not have matching param tags in the javadoc. Default is false."},{"name":"tokens","description":"definitions to check"}]},
- {"title":"Javadoc Variable","key":"checkstyle:com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocVariableCheck","category":"Usability","plugin":"checkstyle","description":"Checks that a variable has Javadoc comment.","priority":"MAJOR","status":"ACTIVE","params":[{"name":"scope","description":"visibility scope where Javadoc comments are checked"},{"name":"excludeScope","description":"visibility scope where Javadoc comments are not checked"}]}
-]