]> source.dussan.org Git - sonarqube.git/commitdiff
Generate client for api/rules
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 23 Nov 2017 21:42:27 +0000 (22:42 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 29 Nov 2017 19:24:11 +0000 (20:24 +0100)
22 files changed:
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QProfileTester.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleQueryFactory.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/RuleQueryFactoryTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java
sonar-ws/src/main/java/org/sonarqube/ws/client/rule/CreateWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/rule/RulesService.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/rule/RulesWsParameters.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/rule/SearchWsRequest.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/rule/package-info.java [deleted file]
sonar-ws/src/test/java/org/sonarqube/ws/client/rule/RulesServiceTest.java [deleted file]
tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java
tests/src/test/java/org/sonarqube/tests/rule/RuleTagsTest.java
tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java

index 25ac4c79602ba89338fbb8c4fb5c798fe8496b05..102581d155dce407feba4d3d87e6f77708851c95 100644 (file)
@@ -33,7 +33,7 @@ import org.sonarqube.ws.client.qualityprofile.ActivateRuleWsRequest;
 import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
 import org.sonarqube.ws.client.qualityprofile.CreateRequest;
 import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
-import org.sonarqube.ws.client.rule.SearchWsRequest;
+import org.sonarqube.ws.client.rules.SearchRequest;
 
 import static java.util.Arrays.asList;
 import static java.util.Arrays.stream;
@@ -97,11 +97,11 @@ public class QProfileTester {
   public QProfileTester assertThatNumberOfActiveRulesEqualsTo(String profileKey, int expectedActiveRules) {
     try {
       List<String> facetIds = asList("active_severities", "repositories", "languages", "severities", "statuses", "types");
-      SearchWsRequest request = new SearchWsRequest()
-        .setQProfile(profileKey)
-        .setActivation(true)
+      SearchRequest request = new SearchRequest()
+        .setQprofile(profileKey)
+        .setActivation("true")
         .setFacets(facetIds)
-        .setFields(singletonList("actives"));
+        .setF(singletonList("actives"));
       Rules.SearchResponse response = session.wsClient().rules().search(request);
 
       // assume that expectedActiveRules fits in first page of results
index 1bfa30ed7212467af7912dfcc8e169d1b07cdbce..56823ae9f2ffa5e0052067da13d330a98eaf82ee 100644 (file)
@@ -41,30 +41,30 @@ import org.sonarqube.ws.Rules;
 
 import static java.lang.String.format;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_CREATED_AT;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_DEBT_OVERLOADED;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_DEBT_REM_FUNCTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_DEFAULT_DEBT_REM_FUNCTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_DEFAULT_REM_FUNCTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_EFFORT_TO_FIX_DESCRIPTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_GAP_DESCRIPTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_HTML_DESCRIPTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_INTERNAL_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_IS_TEMPLATE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_LANGUAGE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_LANGUAGE_NAME;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_MARKDOWN_DESCRIPTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_NAME;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_NOTE_LOGIN;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_PARAMS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_REM_FUNCTION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_REM_FUNCTION_OVERLOADED;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_REPO;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_SEVERITY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_STATUS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_SYSTEM_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.FIELD_TEMPLATE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_CREATED_AT;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEBT_OVERLOADED;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEBT_REM_FUNCTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEFAULT_DEBT_REM_FUNCTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEFAULT_REM_FUNCTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_EFFORT_TO_FIX_DESCRIPTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_GAP_DESCRIPTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_HTML_DESCRIPTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_INTERNAL_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_IS_TEMPLATE;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_LANGUAGE;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_LANGUAGE_NAME;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_MARKDOWN_DESCRIPTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_NAME;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_NOTE_LOGIN;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_PARAMS;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_REM_FUNCTION;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_REM_FUNCTION_OVERLOADED;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_REPO;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_SEVERITY;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_STATUS;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_SYSTEM_TAGS;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_TAGS;
+import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_TEMPLATE_KEY;
 
 /**
  * Conversion of {@link org.sonar.db.rule.RuleDto} to {@link org.sonarqube.ws.Rules.Rule}
index 0046aa9190433d4f97954ea03f1613eee47828e2..69aed9b2d4cff909bfe6fc5d063be9f94b7a37a0 100644 (file)
@@ -37,22 +37,22 @@ import static java.lang.String.format;
 import static org.sonar.server.util.EnumUtils.toEnums;
 import static org.sonar.server.ws.WsUtils.checkFound;
 import static org.sonar.server.ws.WsUtils.checkFoundWithOptional;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_AVAILABLE_SINCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_INHERITANCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_IS_TEMPLATE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_REPOSITORIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_RULE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_STATUSES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TEMPLATE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TYPES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_AVAILABLE_SINCE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_INHERITANCE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_IS_TEMPLATE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_LANGUAGES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ORGANIZATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_REPOSITORIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_RULE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_SEVERITIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_STATUSES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TAGS;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TEMPLATE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TYPES;
 
 @ServerSide
 public class RuleQueryFactory {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java
new file mode 100644 (file)
index 0000000..b70e05e
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.rule.ws;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.Set;
+
+public class RulesWsParameters {
+  public static final String PARAM_REPOSITORIES = "repositories";
+  public static final String PARAM_RULE_KEY = "rule_key";
+  public static final String PARAM_ACTIVATION = "activation";
+  public static final String PARAM_QPROFILE = "qprofile";
+  public static final String PARAM_SEVERITIES = "severities";
+  public static final String PARAM_AVAILABLE_SINCE = "available_since";
+  public static final String PARAM_STATUSES = "statuses";
+  public static final String PARAM_LANGUAGES = "languages";
+  public static final String PARAM_TAGS = "tags";
+  public static final String PARAM_TYPES = "types";
+  public static final String PARAM_INHERITANCE = "inheritance";
+  public static final String PARAM_ACTIVE_SEVERITIES = "active_severities";
+  public static final String PARAM_IS_TEMPLATE = "is_template";
+  public static final String PARAM_TEMPLATE_KEY = "template_key";
+  public static final String PARAM_ORGANIZATION = "organization";
+  public static final String PARAM_COMPARE_TO_PROFILE = "compareToProfile";
+
+  public static final String FIELD_REPO = "repo";
+  public static final String FIELD_NAME = "name";
+  public static final String FIELD_CREATED_AT = "createdAt";
+  public static final String FIELD_SEVERITY = "severity";
+  public static final String FIELD_STATUS = "status";
+  public static final String FIELD_INTERNAL_KEY = "internalKey";
+  public static final String FIELD_IS_TEMPLATE = "isTemplate";
+  public static final String FIELD_TEMPLATE_KEY = "templateKey";
+  public static final String FIELD_TAGS = "tags";
+  public static final String FIELD_SYSTEM_TAGS = "sysTags";
+  public static final String FIELD_LANGUAGE = "lang";
+  public static final String FIELD_LANGUAGE_NAME = "langName";
+  public static final String FIELD_HTML_DESCRIPTION = "htmlDesc";
+  public static final String FIELD_MARKDOWN_DESCRIPTION = "mdDesc";
+  public static final String FIELD_NOTE_LOGIN = "noteLogin";
+  public static final String FIELD_MARKDOWN_NOTE = "mdNote";
+  public static final String FIELD_HTML_NOTE = "htmlNote";
+
+  /**
+   * @deprecated since 5.5, replaced by {@link #FIELD_DEFAULT_REM_FUNCTION}
+   */
+  @Deprecated
+  public static final String FIELD_DEFAULT_DEBT_REM_FUNCTION = "defaultDebtRemFn";
+  public static final String FIELD_DEFAULT_REM_FUNCTION = "defaultRemFn";
+
+  /**
+   * @deprecated since 5.5, replaced by {@link #FIELD_REM_FUNCTION}
+   */
+  @Deprecated
+  public static final String FIELD_DEBT_REM_FUNCTION = "debtRemFn";
+  public static final String FIELD_REM_FUNCTION = "remFn";
+
+  /**
+   * @deprecated since 5.5, replaced by {@link #FIELD_GAP_DESCRIPTION}
+   */
+  @Deprecated
+  public static final String FIELD_EFFORT_TO_FIX_DESCRIPTION = "effortToFixDescription";
+  public static final String FIELD_GAP_DESCRIPTION = "gapDescription";
+
+  /**
+   * @deprecated since 5.5, replaced by {@link #FIELD_REM_FUNCTION_OVERLOADED}
+   */
+  @Deprecated
+  public static final String FIELD_DEBT_OVERLOADED = "debtOverloaded";
+  public static final String FIELD_REM_FUNCTION_OVERLOADED = "remFnOverloaded";
+
+  public static final String FIELD_PARAMS = "params";
+  public static final String FIELD_ACTIVES = "actives";
+
+  public static final Set<String> OPTIONAL_FIELDS = ImmutableSet.of(FIELD_REPO, FIELD_NAME, FIELD_CREATED_AT, FIELD_SEVERITY, FIELD_STATUS, FIELD_INTERNAL_KEY, FIELD_IS_TEMPLATE,
+    FIELD_TEMPLATE_KEY, FIELD_TAGS, FIELD_SYSTEM_TAGS, FIELD_LANGUAGE, FIELD_LANGUAGE_NAME, FIELD_HTML_DESCRIPTION, FIELD_MARKDOWN_DESCRIPTION, FIELD_NOTE_LOGIN,
+    FIELD_MARKDOWN_NOTE, FIELD_HTML_NOTE,
+    FIELD_DEFAULT_DEBT_REM_FUNCTION, FIELD_EFFORT_TO_FIX_DESCRIPTION, FIELD_DEBT_OVERLOADED, FIELD_DEBT_REM_FUNCTION,
+    FIELD_DEFAULT_REM_FUNCTION, FIELD_GAP_DESCRIPTION, FIELD_REM_FUNCTION_OVERLOADED, FIELD_REM_FUNCTION,
+    FIELD_PARAMS, FIELD_ACTIVES);
+
+  private RulesWsParameters() {
+    // prevent instantiation
+  }
+}
index 89dc76bf4c41ec3f963a986c9d2cf8eca11c6721..348f30b5652b353a148db9ec079bd007cfa47444 100644 (file)
@@ -58,7 +58,7 @@ import org.sonar.server.rule.index.RuleIndexDefinition;
 import org.sonar.server.rule.index.RuleQuery;
 import org.sonarqube.ws.Common;
 import org.sonarqube.ws.Rules.SearchResponse;
-import org.sonarqube.ws.client.rule.SearchWsRequest;
+import org.sonarqube.ws.client.rules.SearchRequest;
 
 import static java.lang.String.format;
 import static org.sonar.api.server.ws.WebService.Param.ASCENDING;
@@ -80,24 +80,24 @@ import static org.sonar.server.rule.index.RuleIndex.FACET_SEVERITIES;
 import static org.sonar.server.rule.index.RuleIndex.FACET_STATUSES;
 import static org.sonar.server.rule.index.RuleIndex.FACET_TAGS;
 import static org.sonar.server.rule.index.RuleIndex.FACET_TYPES;
+import static org.sonar.server.rule.ws.RulesWsParameters.OPTIONAL_FIELDS;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_AVAILABLE_SINCE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_INHERITANCE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_IS_TEMPLATE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_LANGUAGES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ORGANIZATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_REPOSITORIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_RULE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_SEVERITIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_STATUSES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TAGS;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TEMPLATE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TYPES;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.OPTIONAL_FIELDS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_AVAILABLE_SINCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_INHERITANCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_IS_TEMPLATE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_REPOSITORIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_RULE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_STATUSES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TEMPLATE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TYPES;
 
 public class SearchAction implements RulesWsAction {
   public static final String ACTION = "search";
@@ -156,7 +156,7 @@ public class SearchAction implements RulesWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      SearchWsRequest searchWsRequest = toSearchWsRequest(request);
+      SearchRequest searchWsRequest = toSearchWsRequest(request);
       SearchOptions context = buildSearchOptions(searchWsRequest);
       RuleQuery query = ruleQueryFactory.createRuleQuery(dbSession, request);
       SearchResult searchResult = doSearch(dbSession, query, context);
@@ -165,7 +165,7 @@ public class SearchAction implements RulesWsAction {
     }
   }
 
-  private SearchResponse buildResponse(DbSession dbSession, SearchWsRequest request, SearchOptions context, SearchResult result, RuleQuery query) {
+  private SearchResponse buildResponse(DbSession dbSession, SearchRequest request, SearchOptions context, SearchResult result, RuleQuery query) {
     SearchResponse.Builder responseBuilder = SearchResponse.newBuilder();
     writeStatistics(responseBuilder, result, context);
     doContextResponse(dbSession, request, result, responseBuilder, query);
@@ -321,7 +321,7 @@ public class SearchAction implements RulesWsAction {
     }
   }
 
-  private static SearchOptions buildSearchOptions(SearchWsRequest request) {
+  private static SearchOptions buildSearchOptions(SearchRequest request) {
     SearchOptions context = loadCommonContext(request);
     SearchOptions searchOptions = new SearchOptions()
       .setLimit(context.getLimit())
@@ -334,16 +334,16 @@ public class SearchAction implements RulesWsAction {
     return searchOptions;
   }
 
-  private static SearchOptions loadCommonContext(SearchWsRequest request) {
-    int pageSize = request.getPageSize();
-    SearchOptions context = new SearchOptions().addFields(request.getFields());
+  private static SearchOptions loadCommonContext(SearchRequest request) {
+    int pageSize = Integer.parseInt(request.getPs());
+    SearchOptions context = new SearchOptions().addFields(request.getF());
     if (request.getFacets() != null) {
       context.addFacets(request.getFacets());
     }
     if (pageSize < 1) {
-      context.setPage(request.getPage(), 0).setLimit(MAX_LIMIT);
+      context.setPage(Integer.parseInt(request.getP()), 0).setLimit(MAX_LIMIT);
     } else {
-      context.setPage(request.getPage(), pageSize);
+      context.setPage(Integer.parseInt(request.getP()), pageSize);
     }
     return context;
   }
@@ -376,7 +376,7 @@ public class SearchAction implements RulesWsAction {
       .setTotal(result.getTotal());
   }
 
-  private void doContextResponse(DbSession dbSession, SearchWsRequest request, SearchResult result, SearchResponse.Builder response, RuleQuery query) {
+  private void doContextResponse(DbSession dbSession, SearchRequest request, SearchResult result, SearchResponse.Builder response, RuleQuery query) {
     SearchOptions contextForResponse = loadCommonContext(request);
     writeRules(response, result, contextForResponse);
     if (contextForResponse.getFields().contains("actives")) {
@@ -384,7 +384,7 @@ public class SearchAction implements RulesWsAction {
     }
   }
 
-  private static void writeFacets(SearchResponse.Builder response, SearchWsRequest request, SearchOptions context, SearchResult results) {
+  private static void writeFacets(SearchResponse.Builder response, SearchRequest request, SearchOptions context, SearchResult results) {
     addMandatoryFacetValues(results, FACET_LANGUAGES, request.getLanguages());
     addMandatoryFacetValues(results, FACET_REPOSITORIES, request.getRepositories());
     addMandatoryFacetValues(results, FACET_STATUSES, ALL_STATUSES_EXCEPT_REMOVED);
@@ -447,24 +447,24 @@ public class SearchAction implements RulesWsAction {
     }
   }
 
-  private static SearchWsRequest toSearchWsRequest(Request request) {
-    return new SearchWsRequest()
-      .setActivation(request.paramAsBoolean(PARAM_ACTIVATION))
+  private static SearchRequest toSearchWsRequest(Request request) {
+    return new SearchRequest()
+      .setActivation("" + request.paramAsBoolean(PARAM_ACTIVATION))
       .setActiveSeverities(request.paramAsStrings(PARAM_ACTIVE_SEVERITIES))
-      .setAsc(request.mandatoryParamAsBoolean(ASCENDING))
+      .setAsc("" + request.mandatoryParamAsBoolean(ASCENDING))
       .setAvailableSince(request.param(PARAM_AVAILABLE_SINCE))
-      .setFields(request.paramAsStrings(FIELDS))
+      .setF(request.paramAsStrings(FIELDS))
       .setFacets(request.paramAsStrings(FACETS))
       .setInheritance(request.paramAsStrings(PARAM_INHERITANCE))
-      .setIsTemplate(request.paramAsBoolean(PARAM_IS_TEMPLATE))
+      .setIsTemplate("" + request.paramAsBoolean(PARAM_IS_TEMPLATE))
       .setLanguages(request.paramAsStrings(PARAM_LANGUAGES))
-      .setPage(request.mandatoryParamAsInt(PAGE))
-      .setPageSize(request.mandatoryParamAsInt(PAGE_SIZE))
-      .setQuery(request.param(TEXT_QUERY))
-      .setQProfile(request.param(PARAM_QPROFILE))
+      .setP("" + request.mandatoryParamAsInt(PAGE))
+      .setPs("" + request.mandatoryParamAsInt(PAGE_SIZE))
+      .setQ(request.param(TEXT_QUERY))
+      .setQprofile(request.param(PARAM_QPROFILE))
       .setRepositories(request.paramAsStrings(PARAM_REPOSITORIES))
       .setRuleKey(request.param(PARAM_RULE_KEY))
-      .setSort(request.param(SORT))
+      .setS(request.param(SORT))
       .setSeverities(request.paramAsStrings(PARAM_SEVERITIES))
       .setStatuses(request.paramAsStrings(PARAM_STATUSES))
       .setTags(request.paramAsStrings(PARAM_TAGS))
index 16616f424d0c9e4340561fe5ed342e487716c150..b7bfb5473e1697ffcd020a8aa98c5e97894dec16 100644 (file)
@@ -69,8 +69,8 @@ import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY;
 import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_SEVERITY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_LANGUAGES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE;
 
 public class QProfilesWsMediumTest {
 
index c81b8a7611ddbc33309ab908490932c32e542c1c..ea969491913accdc4125f43e45c30b7b699f19aa 100644 (file)
@@ -52,22 +52,22 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
 import static org.sonar.db.qualityprofile.ActiveRuleDto.INHERITED;
 import static org.sonar.db.qualityprofile.ActiveRuleDto.OVERRIDES;
 import static org.sonar.server.rule.ws.SearchAction.defineRuleSearchParameters;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_AVAILABLE_SINCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_INHERITANCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_IS_TEMPLATE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_REPOSITORIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_RULE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_STATUSES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TEMPLATE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TYPES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_AVAILABLE_SINCE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_INHERITANCE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_IS_TEMPLATE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_LANGUAGES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ORGANIZATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_REPOSITORIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_RULE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_SEVERITIES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_STATUSES;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TAGS;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TEMPLATE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_TYPES;
 
 public class RuleQueryFactoryTest {
 
index a2c0897b8c7c0b39349e0153e43007a7eef3fec6..47ef1825d2515ae2fd91aa00aafd50210309fd2e 100644 (file)
@@ -84,11 +84,11 @@ import static org.mockito.Mockito.mock;
 import static org.sonar.api.rule.Severity.BLOCKER;
 import static org.sonar.db.rule.RuleTesting.setSystemTags;
 import static org.sonar.db.rule.RuleTesting.setTags;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_RULE_KEY;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ACTIVATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_ORGANIZATION;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_QPROFILE;
+import static org.sonar.server.rule.ws.RulesWsParameters.PARAM_RULE_KEY;
 
 public class SearchActionTest {
 
index cc1e5fba1818a860ce916bf405dfafbc6ddda9fb..12341753e19902e7090a384c6434d691f39f64d4 100644 (file)
@@ -28,7 +28,6 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Encryption;
-import org.sonar.api.config.Settings;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.server.exceptions.BadRequestException;
@@ -39,8 +38,8 @@ import org.sonar.server.ws.WsActionTester;
 import org.sonarqube.ws.Settings.EncryptWsResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.server.setting.ws.SettingsWsParameters.PARAM_VALUE;
 import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.client.settings.SettingsWsParameters.PARAM_VALUE;
 
 public class EncryptActionTest {
   @Rule
index e57f10037cc598be13b0c3d9eba3a4b4cd84a1d9..7c1445edcb29472d1c9f0dfa4aa128bd86ec71f6 100644 (file)
@@ -34,7 +34,7 @@ import org.sonarqube.ws.client.projectlinks.ProjectLinksService;
 import org.sonarqube.ws.client.qualitygates.QualitygatesService;
 import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
 import org.sonarqube.ws.client.roots.RootsService;
-import org.sonarqube.ws.client.rule.RulesService;
+import org.sonarqube.ws.client.rules.RulesService;
 import org.sonarqube.ws.client.settings.SettingsService;
 import org.sonarqube.ws.client.system.SystemService;
 import org.sonarqube.ws.client.user.UsersService;
index e05f08dfecf5abd5c396f9a41cd1dbc370e79a2b..2854977c5dfb834a2b8e6404fc6f83a54733ad5b 100644 (file)
@@ -34,7 +34,7 @@ import org.sonarqube.ws.client.projectlinks.ProjectLinksService;
 import org.sonarqube.ws.client.qualitygates.QualitygatesService;
 import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
 import org.sonarqube.ws.client.roots.RootsService;
-import org.sonarqube.ws.client.rule.RulesService;
+import org.sonarqube.ws.client.rules.RulesService;
 import org.sonarqube.ws.client.settings.SettingsService;
 import org.sonarqube.ws.client.system.SystemService;
 import org.sonarqube.ws.client.user.UsersService;
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/CreateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/CreateWsRequest.java
deleted file mode 100644 (file)
index 9f6c295..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.sonarqube.ws.client.rule;
-
-public class CreateWsRequest {
-
-  private String customKey;
-  private String markdownDescription;
-  private String name;
-  private String params;
-  private Boolean preventReactivation;
-  private String severity;
-  private String status;
-  private String templateKey;
-
-  private CreateWsRequest(Builder builder) {
-    this.customKey = builder.customKey;
-    this.markdownDescription = builder.markdownDescription;
-    this.name = builder.name;
-    this.params = builder.params;
-    this.preventReactivation = builder.preventReactivation;
-    this.severity = builder.severity;
-    this.status = builder.status;
-    this.templateKey = builder.templateKey;
-  }
-
-  public String getCustomKey() {
-    return customKey;
-  }
-
-  public String getMarkdownDescription() {
-    return markdownDescription;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public String getParams() {
-    return params;
-  }
-
-  public Boolean getPreventReactivation() {
-    return preventReactivation;
-  }
-
-  public String getSeverity() {
-    return severity;
-  }
-
-  public String getStatus() {
-    return status;
-  }
-
-  public String getTemplateKey() {
-    return templateKey;
-  }
-
-  public static class Builder {
-    private String customKey;
-    private String markdownDescription;
-    private String name;
-    private String params;
-    private Boolean preventReactivation;
-    private String severity;
-    private String status;
-    private String templateKey;
-
-    public Builder setCustomKey(String customKey) {
-      this.customKey = customKey;
-      return this;
-    }
-
-    public Builder setMarkdownDescription(String markdownDescription) {
-      this.markdownDescription = markdownDescription;
-      return this;
-    }
-
-    public Builder setName(String name) {
-      this.name = name;
-      return this;
-    }
-
-    public Builder setParams(String params) {
-      this.params = params;
-      return this;
-    }
-
-    public Builder setPreventReactivation(Boolean preventReactivation) {
-      this.preventReactivation = preventReactivation;
-      return this;
-    }
-
-    public Builder setSeverity(String severity) {
-      this.severity = severity;
-      return this;
-    }
-
-    public Builder setStatus(String status) {
-      this.status = status;
-      return this;
-    }
-
-    public Builder setTemplateKey(String templateKey) {
-      this.templateKey = templateKey;
-      return this;
-    }
-
-    public CreateWsRequest build() {
-      return new CreateWsRequest(this);
-    }
-  }
-
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/RulesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/RulesService.java
deleted file mode 100644 (file)
index e744ff8..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.sonarqube.ws.client.rule;
-
-import javax.annotation.Nullable;
-import org.sonarqube.ws.Rules;
-import org.sonarqube.ws.Rules.SearchResponse;
-import org.sonarqube.ws.client.BaseService;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsConnector;
-
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_AVAILABLE_SINCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_INHERITANCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_IS_TEMPLATE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_REPOSITORIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_RULE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_STATUSES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TEMPLATE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TYPES;
-
-public class RulesService extends BaseService {
-
-  public RulesService(WsConnector wsConnector) {
-    super(wsConnector, "api/rules");
-  }
-
-  public SearchResponse search(SearchWsRequest request) {
-    return call(
-      new GetRequest(path("search"))
-        .setParam(PARAM_ACTIVATION, request.getActivation())
-        .setParam(PARAM_ACTIVE_SEVERITIES, inlineMultipleParamValue(request.getActiveSeverities()))
-        .setParam("asc", request.getAsc())
-        .setParam(PARAM_AVAILABLE_SINCE, request.getAvailableSince())
-        .setParam("f", inlineMultipleParamValue(request.getFields()))
-        .setParam("facets", inlineMultipleParamValue(request.getFacets()))
-        .setParam(PARAM_INHERITANCE, inlineMultipleParamValue(request.getInheritance()))
-        .setParam(PARAM_IS_TEMPLATE, request.getIsTemplate())
-        .setParam(PARAM_LANGUAGES, inlineMultipleParamValue(request.getLanguages()))
-        .setParam("p", request.getPage())
-        .setParam("ps", request.getPageSize())
-        .setParam("q", request.getQuery())
-        .setParam(PARAM_QPROFILE, request.getQProfile())
-        .setParam(PARAM_COMPARE_TO_PROFILE, request.getCompareToProfile())
-        .setParam(PARAM_REPOSITORIES, inlineMultipleParamValue(request.getRepositories()))
-        .setParam(PARAM_RULE_KEY, request.getRuleKey())
-        .setParam("s", request.getSort())
-        .setParam(PARAM_SEVERITIES, inlineMultipleParamValue(request.getSeverities()))
-        .setParam(PARAM_STATUSES, inlineMultipleParamValue(request.getStatuses()))
-        .setParam(PARAM_TAGS, inlineMultipleParamValue(request.getTags()))
-        .setParam(PARAM_TEMPLATE_KEY, request.getTemplateKey())
-        .setParam(PARAM_TYPES, inlineMultipleParamValue(request.getTypes())),
-      SearchResponse.parser());
-  }
-
-  public Rules.ShowResponse show(@Nullable String organization, String key) {
-    GetRequest request = new GetRequest(path("show"))
-      .setParam("organization", organization)
-      .setParam("key", key);
-    return call(request, Rules.ShowResponse.parser());
-  }
-
-  public void create(CreateWsRequest request) {
-    PostRequest httpRequest = new PostRequest(path("create"));
-    httpRequest.setParam("custom_key", request.getCustomKey());
-    httpRequest.setParam("markdown_description", request.getMarkdownDescription());
-    httpRequest.setParam("name", request.getName());
-    httpRequest.setParam("params", request.getParams());
-    httpRequest.setParam("prevent_reactivation", request.getPreventReactivation());
-    httpRequest.setParam("severity", request.getSeverity());
-    httpRequest.setParam("status", request.getStatus());
-    httpRequest.setParam("template_key", request.getTemplateKey());
-    call(httpRequest);
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/RulesWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/RulesWsParameters.java
deleted file mode 100644 (file)
index c820d82..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.sonarqube.ws.client.rule;
-
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-
-public class RulesWsParameters {
-  public static final String PARAM_REPOSITORIES = "repositories";
-  public static final String PARAM_RULE_KEY = "rule_key";
-  public static final String PARAM_ACTIVATION = "activation";
-  public static final String PARAM_QPROFILE = "qprofile";
-  public static final String PARAM_SEVERITIES = "severities";
-  public static final String PARAM_AVAILABLE_SINCE = "available_since";
-  public static final String PARAM_STATUSES = "statuses";
-  public static final String PARAM_LANGUAGES = "languages";
-  public static final String PARAM_TAGS = "tags";
-  public static final String PARAM_TYPES = "types";
-  public static final String PARAM_INHERITANCE = "inheritance";
-  public static final String PARAM_ACTIVE_SEVERITIES = "active_severities";
-  public static final String PARAM_IS_TEMPLATE = "is_template";
-  public static final String PARAM_TEMPLATE_KEY = "template_key";
-  public static final String PARAM_ORGANIZATION = "organization";
-  public static final String PARAM_COMPARE_TO_PROFILE = "compareToProfile";
-
-  public static final String FIELD_REPO = "repo";
-  public static final String FIELD_NAME = "name";
-  public static final String FIELD_CREATED_AT = "createdAt";
-  public static final String FIELD_SEVERITY = "severity";
-  public static final String FIELD_STATUS = "status";
-  public static final String FIELD_INTERNAL_KEY = "internalKey";
-  public static final String FIELD_IS_TEMPLATE = "isTemplate";
-  public static final String FIELD_TEMPLATE_KEY = "templateKey";
-  public static final String FIELD_TAGS = "tags";
-  public static final String FIELD_SYSTEM_TAGS = "sysTags";
-  public static final String FIELD_LANGUAGE = "lang";
-  public static final String FIELD_LANGUAGE_NAME = "langName";
-  public static final String FIELD_HTML_DESCRIPTION = "htmlDesc";
-  public static final String FIELD_MARKDOWN_DESCRIPTION = "mdDesc";
-  public static final String FIELD_NOTE_LOGIN = "noteLogin";
-  public static final String FIELD_MARKDOWN_NOTE = "mdNote";
-  public static final String FIELD_HTML_NOTE = "htmlNote";
-
-  /**
-   * @deprecated since 5.5, replaced by {@link #FIELD_DEFAULT_REM_FUNCTION}
-   */
-  @Deprecated
-  public static final String FIELD_DEFAULT_DEBT_REM_FUNCTION = "defaultDebtRemFn";
-  public static final String FIELD_DEFAULT_REM_FUNCTION = "defaultRemFn";
-
-  /**
-   * @deprecated since 5.5, replaced by {@link #FIELD_REM_FUNCTION}
-   */
-  @Deprecated
-  public static final String FIELD_DEBT_REM_FUNCTION = "debtRemFn";
-  public static final String FIELD_REM_FUNCTION = "remFn";
-
-  /**
-   * @deprecated since 5.5, replaced by {@link #FIELD_GAP_DESCRIPTION}
-   */
-  @Deprecated
-  public static final String FIELD_EFFORT_TO_FIX_DESCRIPTION = "effortToFixDescription";
-  public static final String FIELD_GAP_DESCRIPTION = "gapDescription";
-
-  /**
-   * @deprecated since 5.5, replaced by {@link #FIELD_REM_FUNCTION_OVERLOADED}
-   */
-  @Deprecated
-  public static final String FIELD_DEBT_OVERLOADED = "debtOverloaded";
-  public static final String FIELD_REM_FUNCTION_OVERLOADED = "remFnOverloaded";
-
-  public static final String FIELD_PARAMS = "params";
-  public static final String FIELD_ACTIVES = "actives";
-
-  public static final Set<String> OPTIONAL_FIELDS = ImmutableSet.of(FIELD_REPO, FIELD_NAME, FIELD_CREATED_AT, FIELD_SEVERITY, FIELD_STATUS, FIELD_INTERNAL_KEY, FIELD_IS_TEMPLATE,
-    FIELD_TEMPLATE_KEY, FIELD_TAGS, FIELD_SYSTEM_TAGS, FIELD_LANGUAGE, FIELD_LANGUAGE_NAME, FIELD_HTML_DESCRIPTION, FIELD_MARKDOWN_DESCRIPTION, FIELD_NOTE_LOGIN,
-    FIELD_MARKDOWN_NOTE, FIELD_HTML_NOTE,
-    FIELD_DEFAULT_DEBT_REM_FUNCTION, FIELD_EFFORT_TO_FIX_DESCRIPTION, FIELD_DEBT_OVERLOADED, FIELD_DEBT_REM_FUNCTION,
-    FIELD_DEFAULT_REM_FUNCTION, FIELD_GAP_DESCRIPTION, FIELD_REM_FUNCTION_OVERLOADED, FIELD_REM_FUNCTION,
-    FIELD_PARAMS, FIELD_ACTIVES);
-
-  private RulesWsParameters() {
-    // prevent instantiation
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/SearchWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/SearchWsRequest.java
deleted file mode 100644 (file)
index 5e0255e..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.sonarqube.ws.client.rule;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-public class SearchWsRequest {
-  private Boolean activation;
-  private List<String> activeSeverities;
-  private Boolean asc;
-  private String availableSince;
-  private List<String> fields;
-  private List<String> facets;
-  private List<String> inheritance;
-  private Boolean isTemplate;
-  private List<String> languages;
-  private Integer page;
-  private Integer pageSize;
-  private String query;
-  private String qProfile;
-  private String compareToProfile;
-  private List<String> repositories;
-  private String ruleKey;
-  private String sort;
-  private List<String> severities;
-  private List<String> statuses;
-  private List<String> tags;
-  private String templateKey;
-  private List<String> types;
-
-  @CheckForNull
-  public Boolean getActivation() {
-    return activation;
-  }
-
-  public SearchWsRequest setActivation(@Nullable Boolean activation) {
-    this.activation = activation;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getActiveSeverities() {
-    return activeSeverities;
-  }
-
-  public SearchWsRequest setActiveSeverities(@Nullable List<String> activeSeverities) {
-    this.activeSeverities = activeSeverities;
-    return this;
-  }
-
-  @CheckForNull
-  public Boolean getAsc() {
-    return asc;
-  }
-
-  public SearchWsRequest setAsc(Boolean asc) {
-    this.asc = asc;
-    return this;
-  }
-
-  @CheckForNull
-  public String getAvailableSince() {
-    return availableSince;
-  }
-
-  public SearchWsRequest setAvailableSince(@Nullable String availableSince) {
-    this.availableSince = availableSince;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getFields() {
-    return fields;
-  }
-
-  public SearchWsRequest setFields(@Nullable List<String> fields) {
-    this.fields = fields;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getFacets() {
-    return facets;
-  }
-
-  public SearchWsRequest setFacets(@Nullable List<String> facets) {
-    this.facets = facets;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getInheritance() {
-    return inheritance;
-  }
-
-  public SearchWsRequest setInheritance(@Nullable List<String> inheritance) {
-    this.inheritance = inheritance;
-    return this;
-  }
-
-  @CheckForNull
-  public Boolean getIsTemplate() {
-    return isTemplate;
-  }
-
-  public SearchWsRequest setIsTemplate(@Nullable Boolean isTemplate) {
-    this.isTemplate = isTemplate;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getLanguages() {
-    return languages;
-  }
-
-  public SearchWsRequest setLanguages(@Nullable List<String> languages) {
-    this.languages = languages;
-    return this;
-  }
-
-  @CheckForNull
-  public Integer getPage() {
-    return page;
-  }
-
-  public SearchWsRequest setPage(@Nullable Integer page) {
-    this.page = page;
-    return this;
-  }
-
-  @CheckForNull
-  public Integer getPageSize() {
-    return pageSize;
-  }
-
-  public SearchWsRequest setPageSize(@Nullable Integer pageSize) {
-    this.pageSize = pageSize;
-    return this;
-  }
-
-  @CheckForNull
-  public String getQuery() {
-    return query;
-  }
-
-  public SearchWsRequest setQuery(@Nullable String query) {
-    this.query = query;
-    return this;
-  }
-
-  @CheckForNull
-  public String getQProfile() {
-    return qProfile;
-  }
-
-  public SearchWsRequest setQProfile(@Nullable String qProfile) {
-    this.qProfile = qProfile;
-    return this;
-  }
-
-  @CheckForNull
-  public String getCompareToProfile() {
-    return compareToProfile;
-  }
-
-  public SearchWsRequest setCompareToProfile(@Nullable String compareToProfile) {
-    this.compareToProfile = compareToProfile;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getRepositories() {
-    return repositories;
-  }
-
-  public SearchWsRequest setRepositories(@Nullable List<String> repositories) {
-    this.repositories = repositories;
-    return this;
-  }
-
-  @CheckForNull
-  public String getRuleKey() {
-    return ruleKey;
-  }
-
-  public SearchWsRequest setRuleKey(@Nullable String ruleKey) {
-    this.ruleKey = ruleKey;
-    return this;
-  }
-
-  @CheckForNull
-  public String getSort() {
-    return sort;
-  }
-
-  public SearchWsRequest setSort(@Nullable String sort) {
-    this.sort = sort;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getSeverities() {
-    return severities;
-  }
-
-  public SearchWsRequest setSeverities(@Nullable List<String> severities) {
-    this.severities = severities;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getStatuses() {
-    return statuses;
-  }
-
-  public SearchWsRequest setStatuses(@Nullable List<String> statuses) {
-    this.statuses = statuses;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getTags() {
-    return tags;
-  }
-
-  public SearchWsRequest setTags(@Nullable List<String> tags) {
-    this.tags = tags;
-    return this;
-  }
-
-  @CheckForNull
-  public String getTemplateKey() {
-    return templateKey;
-  }
-
-  public SearchWsRequest setTemplateKey(@Nullable String templateKey) {
-    this.templateKey = templateKey;
-    return this;
-  }
-
-  @CheckForNull
-  public List<String> getTypes() {
-    return types;
-  }
-
-  public SearchWsRequest setTypes(@Nullable List<String> types) {
-    this.types = types;
-    return this;
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/rule/package-info.java
deleted file mode 100644 (file)
index f781f2f..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonarqube.ws.client.rule;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/rule/RulesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/rule/RulesServiceTest.java
deleted file mode 100644 (file)
index 45248fa..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.sonarqube.ws.client.rule;
-
-import com.google.common.collect.Lists;
-import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.ws.Rules;
-import org.sonarqube.ws.Rules.SearchResponse;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.ServiceTester;
-import org.sonarqube.ws.client.WsConnector;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVATION;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_ACTIVE_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_AVAILABLE_SINCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_COMPARE_TO_PROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_INHERITANCE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_IS_TEMPLATE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_REPOSITORIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_RULE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_SEVERITIES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_STATUSES;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TAGS;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TEMPLATE_KEY;
-import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_TYPES;
-
-public class RulesServiceTest {
-  static final boolean ACTIVATION_VALUE = true;
-  static final List<String> ACTIVE_SEVERITIES_VALUE = Lists.newArrayList("CRITICAL", "BLOCKER");
-  static final String ACTIVE_SEVERITIES_VALUE_INLINED = "CRITICAL,BLOCKER";
-  static final boolean ASC_VALUE = false;
-  static final String AVAILABLE_SINCE_VALUE = "2015-06-22";
-  static final List<String> FIELDS_VALUE = newArrayList("repo", "name");
-  static final String FIELDS_VALUE_INLINED = "repo,name";
-  static final List<String> FACETS_VALUE = newArrayList("languages", "repositories");
-  static final String FACETS_VALUE_INLINED = "languages,repositories";
-  static final List<String> INHERITANCE_VALUE = newArrayList("INHERITED", "OVERRIDES");
-  static final String INHERITANCE_VALUE_INLINED = "INHERITED,OVERRIDES";
-  static final boolean IS_TEMPLATE_VALUE = true;
-  static final List<String> LANGUAGES_VALUE = newArrayList("java", "js");
-  static final String LANGUAGES_VALUE_INLINED = "java,js";
-  static final int PAGE_VALUE = 12;
-  static final int PAGE_SIZE_VALUE = 42;
-  static final String QUERY_VALUE = "query-value";
-  static final String QPROFILE_VALUE = "qprofile-key";
-  static final List<String> REPOSITORIES_VALUE = newArrayList("findbugs", "checkstyle");
-  static final String REPOSITORIES_VALUE_INLINED = "findbugs,checkstyle";
-  static final String RULE_KEY_VALUE = "rule-key-value";
-  static final String SORT_VALUE = "name";
-  static final List<String> SEVERITIES_VALUE = newArrayList("INFO", "MINOR");
-  static final String SEVERITIES_VALUE_INLINED = "INFO,MINOR";
-  static final List<String> STATUSES_VALUE = newArrayList("BETA", "DEPRECATED");
-  static final String STATUSES_VALUE_INLINED = "BETA,DEPRECATED";
-  static final List<String> TAGS_VALUE = newArrayList("clumsy", "java8");
-  static final String TAGS_VALUE_INLINED = "clumsy,java8";
-  static final String TEMPLATE_KEY_VALUE = "template-key-value";
-  static final List<String> TYPES_VALUE = newArrayList("CODE_SMELL", "BUG");
-  static final String TYPES_VALUE_INLINED = "CODE_SMELL,BUG";
-
-  @Rule
-  public ServiceTester<RulesService> serviceTester = new ServiceTester<>(new RulesService(mock(WsConnector.class)));
-
-  private RulesService underTest = serviceTester.getInstanceUnderTest();
-
-  @Test
-  public void test_search() {
-    underTest.search(new SearchWsRequest()
-      .setActivation(ACTIVATION_VALUE)
-      .setActiveSeverities(ACTIVE_SEVERITIES_VALUE)
-      .setAsc(ASC_VALUE)
-      .setAvailableSince(AVAILABLE_SINCE_VALUE)
-      .setFields(FIELDS_VALUE)
-      .setFacets(FACETS_VALUE)
-      .setInheritance(INHERITANCE_VALUE)
-      .setIsTemplate(IS_TEMPLATE_VALUE)
-      .setLanguages(LANGUAGES_VALUE)
-      .setPage(PAGE_VALUE)
-      .setPageSize(PAGE_SIZE_VALUE)
-      .setQuery(QUERY_VALUE)
-      .setQProfile(QPROFILE_VALUE)
-      .setCompareToProfile("CompareTo")
-      .setRepositories(REPOSITORIES_VALUE)
-      .setRuleKey(RULE_KEY_VALUE)
-      .setSort(SORT_VALUE)
-      .setSeverities(SEVERITIES_VALUE)
-      .setStatuses(STATUSES_VALUE)
-      .setTags(TAGS_VALUE)
-      .setTemplateKey(TEMPLATE_KEY_VALUE)
-      .setTypes(TYPES_VALUE));
-
-    assertThat(serviceTester.getGetParser()).isSameAs(SearchResponse.parser());
-    GetRequest getRequest = serviceTester.getGetRequest();
-    serviceTester.assertThat(getRequest)
-      .hasPath("search")
-      .hasParam(PARAM_ACTIVATION, ACTIVATION_VALUE)
-      .hasParam(PARAM_ACTIVE_SEVERITIES, ACTIVE_SEVERITIES_VALUE_INLINED)
-      .hasParam("asc", ASC_VALUE)
-      .hasParam(PARAM_AVAILABLE_SINCE, AVAILABLE_SINCE_VALUE)
-      .hasParam("f", FIELDS_VALUE_INLINED)
-      .hasParam("facets", FACETS_VALUE_INLINED)
-      .hasParam(PARAM_INHERITANCE, INHERITANCE_VALUE_INLINED)
-      .hasParam(PARAM_IS_TEMPLATE, IS_TEMPLATE_VALUE)
-      .hasParam("p", PAGE_VALUE)
-      .hasParam("ps", PAGE_SIZE_VALUE)
-      .hasParam("q", QUERY_VALUE)
-      .hasParam(PARAM_QPROFILE, QPROFILE_VALUE)
-      .hasParam(PARAM_COMPARE_TO_PROFILE, "CompareTo")
-      .hasParam(PARAM_REPOSITORIES, REPOSITORIES_VALUE_INLINED)
-      .hasParam(PARAM_RULE_KEY, RULE_KEY_VALUE)
-      .hasParam(PARAM_LANGUAGES, LANGUAGES_VALUE_INLINED)
-      .hasParam("s", SORT_VALUE)
-      .hasParam(PARAM_SEVERITIES, SEVERITIES_VALUE_INLINED)
-      .hasParam(PARAM_STATUSES, STATUSES_VALUE_INLINED)
-      .hasParam(PARAM_TAGS, TAGS_VALUE_INLINED)
-      .hasParam(PARAM_TEMPLATE_KEY, TEMPLATE_KEY_VALUE)
-      .hasParam(PARAM_TYPES, TYPES_VALUE_INLINED)
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void test_show() {
-    underTest.show("the-org", "the-rule/key");
-
-    assertThat(serviceTester.getGetParser()).isSameAs(Rules.ShowResponse.parser());
-    GetRequest getRequest = serviceTester.getGetRequest();
-    serviceTester.assertThat(getRequest)
-      .hasPath("show")
-      .hasParam("organization", "the-org")
-      .hasParam("key", "the-rule/key")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void test_create() {
-    underTest.create(new CreateWsRequest.Builder()
-      .setTemplateKey("the-template-key")
-      .setCustomKey("the-custom-key")
-      .setSeverity("BLOCKER")
-      .setParams("the-params")
-      .setPreventReactivation(true)
-      .setMarkdownDescription("the-desc")
-      .setStatus("BETA")
-      .setName("the-name")
-      .build());
-
-    PostRequest postRequest = serviceTester.getPostRequest();
-    serviceTester.assertThat(postRequest)
-      .hasPath("create")
-      .hasParam("template_key", "the-template-key")
-      .hasParam("custom_key", "the-custom-key")
-      .hasParam("severity", "BLOCKER")
-      .hasParam("params", "the-params")
-      .hasParam("prevent_reactivation", "true")
-      .hasParam("markdown_description", "the-desc")
-      .hasParam("status", "BETA")
-      .hasParam("name", "the-name")
-      .andNoOtherParam();
-  }
-}
index bbde52e720e1c3c0986fe09fb3bb341af746be96..a0067d75aa1d740f102efdeba2a6f6531261c457 100644 (file)
@@ -314,7 +314,7 @@ public class OrganizationTest {
   }
 
   private void verifyOrganization(Organization createdOrganization, String name, String description, String url,
-                                  String avatarUrl) {
+    String avatarUrl) {
     SearchWsRequest request = new SearchWsRequest.Builder().setOrganizations(createdOrganization.getKey()).build();
     List<Organization> result = tester.organizations().service().search(request).getOrganizationsList();
     assertThat(result).hasSize(1);
@@ -353,7 +353,8 @@ public class OrganizationTest {
       } else {
         assertThat(p.getActiveRuleCount()).isGreaterThan(0);
         // that allows to check the Elasticsearch index of active rules
-        Rules.SearchResponse activeRulesResponse = tester.wsClient().rules().search(new org.sonarqube.ws.client.rule.SearchWsRequest().setActivation(true).setQProfile(p.getKey()));
+        Rules.SearchResponse activeRulesResponse = tester.wsClient().rules()
+          .search(new org.sonarqube.ws.client.rules.SearchRequest().setActivation("true").setQprofile(p.getKey()));
         assertThat(activeRulesResponse.getTotal()).as("profile " + p.getName()).isEqualTo(p.getActiveRuleCount());
         assertThat(activeRulesResponse.getRulesCount()).isEqualTo((int) p.getActiveRuleCount());
       }
index efd0562727b2a048af9d45380d22541be02fef6e..a44242f05e492ce842c126b93d085ca37ba3dd39 100644 (file)
@@ -33,7 +33,7 @@ import org.sonarqube.tests.Byteman;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations;
 import org.sonarqube.ws.Qualityprofiles;
-import org.sonarqube.ws.client.rule.SearchWsRequest;
+import org.sonarqube.ws.client.rules.SearchRequest;
 import util.ItUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -100,7 +100,7 @@ public class ActiveRuleEsResilienceTest {
   }
 
   private long searchActiveRules(Qualityprofiles.CreateWsResponse.QualityProfile profile) {
-    SearchWsRequest request = new SearchWsRequest().setActivation(true).setQProfile(profile.getKey());
+    SearchRequest request = new SearchRequest().setActivation("true").setQprofile(profile.getKey());
     return tester.wsClient().rules().search(request).getRulesCount();
   }
 }
index 770298e8180130322125c41174380aac93c58bf1..220b922a700a0a04d392286cae92211b892e7641 100644 (file)
@@ -29,10 +29,10 @@ import org.junit.Test;
 import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonarqube.tests.Byteman;
 import org.sonarqube.qa.util.Tester;
-import org.sonarqube.ws.client.rule.CreateWsRequest;
-import org.sonarqube.ws.client.rule.SearchWsRequest;
+import org.sonarqube.tests.Byteman;
+import org.sonarqube.ws.client.rules.CreateRequest;
+import org.sonarqube.ws.client.rules.SearchRequest;
 import util.ItUtils;
 
 import static java.util.Collections.singletonList;
@@ -78,13 +78,12 @@ public class RuleEsResilienceTest {
 
   @Test
   public void creation_of_custom_rule_is_resilient_to_elasticsearch_errors() throws Exception {
-    CreateWsRequest request = new CreateWsRequest.Builder()
+    CreateRequest request = new CreateRequest()
       .setCustomKey("my_custom_rule")
       .setName("My custom rule")
       .setTemplateKey("xoo:xoo-template")
       .setMarkdownDescription("The *initial* rule")
-      .setSeverity("MAJOR")
-      .build();
+      .setSeverity("MAJOR");
     tester.wsClient().rules().create(request);
 
     // rule exists in db but is not indexed. Search returns no results.
@@ -100,8 +99,8 @@ public class RuleEsResilienceTest {
   }
 
   private boolean nameFoundInSearch(String query) {
-    SearchWsRequest request = new SearchWsRequest()
-      .setQuery(query)
+    SearchRequest request = new SearchRequest()
+      .setQ(query)
       .setRepositories(singletonList("xoo"));
     return tester.wsClient().rules().search(request).getRulesCount() > 0;
   }
index 16fd9ca3fb07d901abc5b6b90c465ccb7b2038ed..6612ea7c0df6f0b247adf78cf29dde840e4efc31 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonarqube.tests.rule;
 
 import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category6Suite;
 import java.util.List;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -28,10 +27,14 @@ import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
 import org.sonarqube.qa.util.Tester;
+import org.sonarqube.tests.Category6Suite;
 import org.sonarqube.ws.Organizations;
-import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.rules.ShowRequest;
+import org.sonarqube.ws.client.rules.TagsRequest;
+import org.sonarqube.ws.client.rules.UpdateRequest;
 import util.ItUtils;
 
+import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class RuleTagsTest {
@@ -88,23 +91,22 @@ public class RuleTagsTest {
   }
 
   private List<String> listTags(Organizations.Organization organization) {
-    String json = orchestrator.getServer().newHttpCall("/api/rules/tags")
-      .setParam("organization", organization.getKey())
-      .execute()
-      .getBodyAsString();
+    String json = tester
+      .wsClient()
+      .rules()
+      .tags(new TagsRequest().setOrganization(organization.getKey()));
     return (List<String>) ItUtils.jsonToMap(json).get("tags");
   }
 
   private List<String> showRuleTags(Organizations.Organization organization) {
-    return tester.wsClient().rules().show(organization.getKey(), "xoo:OneIssuePerFile")
+    return tester.wsClient().rules().show(new ShowRequest().setOrganization(organization.getKey()).setKey("xoo:OneIssuePerFile"))
       .getRule().getTags().getTagsList();
   }
 
   private void updateTag(String tag, Organizations.Organization organization) {
-    tester.wsClient().wsConnector().call(new PostRequest("/api/rules/update")
-      .setParam("organization", organization.getKey())
-      .setParam("key", "xoo:OneIssuePerFile")
-      .setParam("tags", tag))
-      .failIfNotSuccessful();
+    tester.wsClient().rules().update(new UpdateRequest()
+      .setOrganization(organization.getKey())
+      .setKey("xoo:OneIssuePerFile")
+      .setTags(asList(tag)));
   }
 }
index 33469fb65770346a79749246336d1da9741b0856..f2249a9b6a8791f8f514ced7a60d4cf2e6862a51 100644 (file)
@@ -31,7 +31,7 @@ import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.Qualityprofiles.CreateWsResponse;
 import org.sonarqube.ws.Qualityprofiles.SearchWsResponse;
 import org.sonarqube.ws.Rules;
-import org.sonarqube.ws.client.rule.SearchWsRequest;
+import org.sonarqube.ws.client.rules.SearchRequest;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -55,7 +55,7 @@ public class RulesWsTest {
     Organization org = tester.organizations().generate();
     SearchWsResponse.QualityProfile sonarWay = getProfile(org, p -> PROFILE_SONAR_WAY.equals(p.getName()) && LANGUAGE_XOO.equals(p.getLanguage()) && p.getIsBuiltIn());
 
-    List<Rules.Rule> result = tester.wsClient().rules().search(new SearchWsRequest().setQProfile(sonarWay.getKey()).setActivation(true))
+    List<Rules.Rule> result = tester.wsClient().rules().search(new SearchRequest().setQprofile(sonarWay.getKey()).setActivation("true"))
       .getRulesList();
 
     assertThat(result)
@@ -71,9 +71,9 @@ public class RulesWsTest {
     tester.qProfiles().activateRule(xooProfile, RULE_ONE_ISSUE_PER_LINE);
     SearchWsResponse.QualityProfile sonarWay = getProfile(org, p -> PROFILE_SONAR_WAY.equals(p.getName()) && LANGUAGE_XOO.equals(p.getLanguage()) && p.getIsBuiltIn());
 
-    List<Rules.Rule> result = tester.wsClient().rules().search(new SearchWsRequest()
-      .setQProfile(xooProfile.getKey())
-      .setActivation(false)
+    List<Rules.Rule> result = tester.wsClient().rules().search(new SearchRequest()
+      .setQprofile(xooProfile.getKey())
+      .setActivation("false")
       .setCompareToProfile(sonarWay.getKey()))
       .getRulesList();