diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-23 22:42:27 +0100 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-11-29 20:24:11 +0100 |
commit | 683a197994747c831641d2514acb5943db6f6aa6 (patch) | |
tree | d0f17ed96cc426286e93f0838fafee5ba1fb78ce /tests/src | |
parent | b4ea0e2987239a4940a008926268e4428a237544 (diff) | |
download | sonarqube-683a197994747c831641d2514acb5943db6f6aa6.tar.gz sonarqube-683a197994747c831641d2514acb5943db6f6aa6.zip |
Generate client for api/rules
Diffstat (limited to 'tests/src')
5 files changed, 31 insertions, 29 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java index bbde52e720e..a0067d75aa1 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java @@ -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()); } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java index efd0562727b..a44242f05e4 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/ActiveRuleEsResilienceTest.java @@ -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(); } } diff --git a/tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java index 770298e8180..220b922a700 100644 --- a/tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java +++ b/tests/src/test/java/org/sonarqube/tests/rule/RuleEsResilienceTest.java @@ -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; } diff --git a/tests/src/test/java/org/sonarqube/tests/rule/RuleTagsTest.java b/tests/src/test/java/org/sonarqube/tests/rule/RuleTagsTest.java index 16fd9ca3fb0..6612ea7c0df 100644 --- a/tests/src/test/java/org/sonarqube/tests/rule/RuleTagsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/rule/RuleTagsTest.java @@ -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))); } } diff --git a/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java b/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java index 33469fb6577..f2249a9b6a8 100644 --- a/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/rule/RulesWsTest.java @@ -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(); |