summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-12-08 10:01:12 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-12-08 10:01:12 +0100
commitb70cc269756f6fba6e0fff3f1ab25745efd7e0ec (patch)
tree96efe2972495c2bb22ce23fe95774c930f5411f7 /server
parent72ed026449d0ce330746e0993993bb3bf1ed434a (diff)
downloadsonarqube-b70cc269756f6fba6e0fff3f1ab25745efd7e0ec.tar.gz
sonarqube-b70cc269756f6fba6e0fff3f1ab25745efd7e0ec.zip
Revert "SONAR-6820 WS api/rules/search has a page size limit of 500"
This reverts commit bf7964f6f2776dab0934b7d2768990de4ae6a5c2.
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java183
2 files changed, 87 insertions, 105 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java
index 7fed268d5ad..00439eb0f9b 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java
@@ -56,7 +56,6 @@ import org.sonar.server.user.UserSession;
import org.sonarqube.ws.Common;
import org.sonarqube.ws.Rules.SearchResponse;
-import static org.sonar.server.ws.WsUtils.checkRequest;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
/**
@@ -82,8 +81,6 @@ public class SearchAction implements RulesWsAction {
public static final String PARAM_TEMPLATE_KEY = "template_key";
private static final Collection<String> DEFAULT_FACETS = ImmutableSet.of(PARAM_LANGUAGES, PARAM_REPOSITORIES, "tags");
- private static final int MAX_PAGE_SIZE = 500;
- private static final String MSG_MAX_PAGE_SIZE_ERROR = "Page size must be less than " + MAX_PAGE_SIZE;
private final RuleService ruleService;
private final ActiveRuleCompleter activeRuleCompleter;
@@ -100,7 +97,7 @@ public class SearchAction implements RulesWsAction {
@Override
public void define(WebService.NewController controller) {
WebService.NewAction action = controller.createAction(ACTION)
- .addPagingParams(100, MAX_PAGE_SIZE)
+ .addPagingParams(100)
.setHandler(this);
Collection<String> possibleFacets = possibleFacets();
@@ -170,7 +167,8 @@ public class SearchAction implements RulesWsAction {
RuleIndex.FACET_SEVERITIES,
RuleIndex.FACET_ACTIVE_SEVERITIES,
RuleIndex.FACET_STATUSES,
- RuleIndex.FACET_OLD_DEFAULT);
+ RuleIndex.FACET_OLD_DEFAULT
+ );
}
/**
@@ -332,7 +330,6 @@ public class SearchAction implements RulesWsAction {
private QueryContext loadCommonContext(Request request) {
int pageSize = request.mandatoryParamAsInt(Param.PAGE_SIZE);
- checkRequest(pageSize <= MAX_PAGE_SIZE, MSG_MAX_PAGE_SIZE_ERROR);
QueryContext context = new QueryContext(userSession).addFieldsToReturn(request.paramAsStrings(Param.FIELDS));
List<String> facets = request.paramAsStrings(Param.FACETS);
if (facets != null) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
index 2323e7b6b8e..46124819e38 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
@@ -20,15 +20,11 @@
package org.sonar.server.rule.ws;
import com.google.common.collect.ImmutableSet;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
@@ -46,7 +42,6 @@ import org.sonar.db.rule.RuleParamDto;
import org.sonar.db.rule.RuleTesting;
import org.sonar.server.db.DbClient;
import org.sonar.server.debt.DebtTesting;
-import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.qualityprofile.QProfileTesting;
import org.sonar.server.qualityprofile.db.ActiveRuleDao;
import org.sonar.server.rule.db.RuleDao;
@@ -55,6 +50,10 @@ import org.sonar.server.tester.ServerTester;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsTester;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+
import static org.assertj.core.api.Assertions.assertThat;
public class SearchActionMediumTest {
@@ -63,8 +62,6 @@ public class SearchActionMediumTest {
public static ServerTester tester = new ServerTester().addXoo();
@Rule
public UserSessionRule userSessionRule = UserSessionRule.forServerTester(tester);
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
private static final String API_ENDPOINT = "api/rules";
private static final String API_SEARCH_METHOD = "search";
@@ -188,16 +185,16 @@ public class SearchActionMediumTest {
insertDebtCharacteristics(dbSession);
ruleDao.insert(dbSession, RuleTesting.newXooX1()
- .setDefaultSubCharacteristicId(hardReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("1h")
- .setDefaultRemediationOffset("15min")
-
- .setSubCharacteristicId(null)
- .setRemediationFunction(null)
- .setRemediationCoefficient(null)
- .setRemediationOffset(null)
- );
+ .setDefaultSubCharacteristicId(hardReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("1h")
+ .setDefaultRemediationOffset("15min")
+
+ .setSubCharacteristicId(null)
+ .setRemediationFunction(null)
+ .setRemediationCoefficient(null)
+ .setRemediationOffset(null)
+ );
dbSession.commit();
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
@@ -212,16 +209,16 @@ public class SearchActionMediumTest {
insertDebtCharacteristics(dbSession);
ruleDao.insert(dbSession, RuleTesting.newXooX1()
- .setDefaultSubCharacteristicId(hardReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("1h")
- .setDefaultRemediationOffset("15min")
-
- .setSubCharacteristicId(softReliabilityId)
- .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setRemediationCoefficient("2h")
- .setRemediationOffset("25min")
- );
+ .setDefaultSubCharacteristicId(hardReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("1h")
+ .setDefaultRemediationOffset("15min")
+
+ .setSubCharacteristicId(softReliabilityId)
+ .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setRemediationCoefficient("2h")
+ .setRemediationOffset("25min")
+ );
dbSession.commit();
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
@@ -235,16 +232,16 @@ public class SearchActionMediumTest {
insertDebtCharacteristics(dbSession);
ruleDao.insert(dbSession, RuleTesting.newXooX1()
- .setDefaultSubCharacteristicId(hardReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("1h")
- .setDefaultRemediationOffset("15min")
-
- .setSubCharacteristicId(softReliabilityId)
- .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.name())
- .setRemediationCoefficient(null)
- .setRemediationOffset("5min")
- );
+ .setDefaultSubCharacteristicId(hardReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("1h")
+ .setDefaultRemediationOffset("15min")
+
+ .setSubCharacteristicId(softReliabilityId)
+ .setRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE.name())
+ .setRemediationCoefficient(null)
+ .setRemediationOffset("5min")
+ );
dbSession.commit();
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
@@ -258,16 +255,16 @@ public class SearchActionMediumTest {
insertDebtCharacteristics(dbSession);
ruleDao.insert(dbSession, RuleTesting.newXooX1()
- .setDefaultSubCharacteristicId(hardReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("1h")
- .setDefaultRemediationOffset("15min")
-
- .setSubCharacteristicId(softReliabilityId)
- .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.name())
- .setRemediationCoefficient("1h")
- .setRemediationOffset(null)
- );
+ .setDefaultSubCharacteristicId(hardReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("1h")
+ .setDefaultRemediationOffset("15min")
+
+ .setSubCharacteristicId(softReliabilityId)
+ .setRemediationFunction(DebtRemediationFunction.Type.LINEAR.name())
+ .setRemediationCoefficient("1h")
+ .setRemediationOffset(null)
+ );
dbSession.commit();
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
@@ -281,49 +278,49 @@ public class SearchActionMediumTest {
insertDebtCharacteristics(dbSession);
ruleDao.insert(dbSession, RuleTesting.newXooX1()
- .setDefaultSubCharacteristicId(hardReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("1h")
- .setDefaultRemediationOffset("15min")
-
- .setSubCharacteristicId(null)
- .setRemediationFunction(null)
- .setRemediationCoefficient(null)
- .setRemediationOffset(null)
- );
+ .setDefaultSubCharacteristicId(hardReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("1h")
+ .setDefaultRemediationOffset("15min")
+
+ .setSubCharacteristicId(null)
+ .setRemediationFunction(null)
+ .setRemediationCoefficient(null)
+ .setRemediationOffset(null)
+ );
ruleDao.insert(dbSession, RuleTesting.newXooX2()
- .setDefaultSubCharacteristicId(hardReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("1h")
- .setDefaultRemediationOffset("15min")
-
- .setSubCharacteristicId(softReliabilityId)
- .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setRemediationCoefficient("30min")
- .setRemediationOffset("5min")
- );
+ .setDefaultSubCharacteristicId(hardReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("1h")
+ .setDefaultRemediationOffset("15min")
+
+ .setSubCharacteristicId(softReliabilityId)
+ .setRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setRemediationCoefficient("30min")
+ .setRemediationOffset("5min")
+ );
ruleDao.insert(dbSession, RuleTesting.newXooX3()
- .setDefaultSubCharacteristicId(null)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("2min")
- .setDefaultRemediationOffset("1min")
-
- .setSubCharacteristicId(null)
- .setRemediationFunction(null)
- .setRemediationCoefficient(null)
- .setRemediationOffset(null)
- );
+ .setDefaultSubCharacteristicId(null)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("2min")
+ .setDefaultRemediationOffset("1min")
+
+ .setSubCharacteristicId(null)
+ .setRemediationFunction(null)
+ .setRemediationCoefficient(null)
+ .setRemediationOffset(null)
+ );
ruleDao.insert(dbSession, RuleTesting.newDto(RuleKey.of("xoo", "x4")).setLanguage("xoo")
- .setDefaultSubCharacteristicId(softReliabilityId)
- .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
- .setDefaultRemediationCoefficient("2min")
- .setDefaultRemediationOffset("1min")
-
- .setSubCharacteristicId(-1)
- .setRemediationFunction(null)
- .setRemediationCoefficient(null)
- .setRemediationOffset(null)
- );
+ .setDefaultSubCharacteristicId(softReliabilityId)
+ .setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name())
+ .setDefaultRemediationCoefficient("2min")
+ .setDefaultRemediationOffset("1min")
+
+ .setSubCharacteristicId(-1)
+ .setRemediationFunction(null)
+ .setRemediationCoefficient(null)
+ .setRemediationOffset(null)
+ );
dbSession.commit();
WsTester.Result result = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD)
@@ -640,18 +637,6 @@ public class SearchActionMediumTest {
result.assertJson("{\"total\":0,\"p\":1,\"ps\":100,\"rules\":[]}");
}
- @Test
- public void fail_when_page_size_greater_than_500() throws Exception {
- expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Page size must be less than 500");
-
- WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD)
- .setParam(WebService.Param.PAGE_SIZE, String.valueOf(501));
- request.setParam(WebService.Param.FIELDS, "actives");
-
- request.execute();
- }
-
private ActiveRuleDto newActiveRule(QualityProfileDto profile, RuleDto rule) {
return ActiveRuleDto.createFor(profile, rule)
.setInheritance(null)