diff options
author | Daniel Schwarz <daniel.schwarz@sonarsource.com> | 2017-11-30 18:39:25 +0100 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-12-06 14:40:17 +0100 |
commit | 2d211ab5fd27358de3d07990f3dc1b487d29c994 (patch) | |
tree | 62bf1cda6dd18ade21a5df17d80520e40146eb50 /tests | |
parent | 6840bca918854ebfc8b16cbd07071aa1b6672313 (diff) | |
download | sonarqube-2d211ab5fd27358de3d07990f3dc1b487d29c994.tar.gz sonarqube-2d211ab5fd27358de3d07990f3dc1b487d29c994.zip |
Remove legacy sonar-ws code for components
Diffstat (limited to 'tests')
14 files changed, 83 insertions, 102 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java index 46b49e6eb67..e207bc33ba6 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/AnalysisEsResilienceTest.java @@ -27,9 +27,7 @@ import java.net.InetAddress; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.annotation.Nullable; import org.junit.After; import org.junit.ClassRule; @@ -39,13 +37,15 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.tests.Byteman; import org.sonarqube.ws.Ce; import org.sonarqube.ws.Common; +import org.sonarqube.ws.Components; +import org.sonarqube.ws.Components.SuggestionsWsResponse.Suggestion; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Organizations.Organization; -import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; import org.sonarqube.ws.Projects; +import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile; import org.sonarqube.ws.Users.CreateWsResponse.User; import org.sonarqube.ws.client.ce.TaskRequest; -import org.sonarqube.ws.client.component.SuggestionsRequest; +import org.sonarqube.ws.client.components.SuggestionsRequest; import org.sonarqube.ws.client.issue.SearchRequest; import util.ItUtils; @@ -98,9 +98,9 @@ public class AnalysisEsResilienceTest { .assignQProfileToProject(profile, project); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-sample-v1", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); - assertThat(searchFile(file2Key, organization)).isEmpty(); - assertThat(searchFile(file3Key, organization)).isEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); + assertThat(searchFile(file2Key)).isEmpty(); + assertThat(searchFile(file3Key)).isEmpty(); Issues.SearchWsResponse issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent) @@ -108,9 +108,9 @@ public class AnalysisEsResilienceTest { byteman.activateScript("resilience/making_ce_indexation_failing.btm"); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-sample-v2", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); - assertThat(searchFile(file2Key, organization)).isEmpty();// inconsistency: in DB there is also file2Key - assertThat(searchFile(file3Key, organization)).isEmpty();// inconsistency: in DB there is also file3Key + assertThat(searchFile(fileKey)).isNotEmpty(); + assertThat(searchFile(file2Key)).isEmpty();// inconsistency: in DB there is also file2Key + assertThat(searchFile(file3Key)).isEmpty();// inconsistency: in DB there is also file3Key issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent) @@ -118,9 +118,9 @@ public class AnalysisEsResilienceTest { byteman.deactivateAllRules(); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-sample-v3", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); - assertThat(searchFile(file2Key, organization)).isEmpty(); - assertThat(searchFile(file3Key, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); + assertThat(searchFile(file2Key)).isEmpty(); + assertThat(searchFile(file3Key)).isNotEmpty(); issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent, Issues.Issue::getStatus) @@ -144,7 +144,7 @@ public class AnalysisEsResilienceTest { .assignQProfileToProject(profile, project); executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-purge", "2000-01-01"); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); Issues.SearchWsResponse issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent) @@ -166,7 +166,7 @@ public class AnalysisEsResilienceTest { .contains("Caused by: java.lang.IllegalStateException: Unrecoverable indexation failures"); // The issue must be present with status CLOSED in database - assertThat(searchFile(fileKey, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .extracting(Issues.Issue::getComponent, Issues.Issue::getStatus) @@ -189,7 +189,7 @@ public class AnalysisEsResilienceTest { // Second analysis must fix the issue, // The purge will delete the "old" issue executeAnalysis(projectKey, organization, orgAdministrator, "analysis/resilience/resilience-purge", null); - assertThat(searchFile(fileKey, organization)).isNotEmpty(); + assertThat(searchFile(fileKey)).isNotEmpty(); issues = searchIssues(projectKey); assertThat(issues.getIssuesList()) .isEmpty(); @@ -232,18 +232,16 @@ public class AnalysisEsResilienceTest { return tester.wsClient().issuesOld().search(request); } - private List<String> searchFile(String key, Organization organization) { - SuggestionsRequest query = SuggestionsRequest.builder() - .setS(key) - .build(); - Map<String, Object> response = ItUtils.jsonToMap( - tester.wsClient().componentsOld().suggestions(query).content() - ); - List results = (List) response.get("results"); - Map trkResult = (Map) results.stream().filter(result -> "FIL".equals(((Map) result).get("q"))).findAny().get(); - List items = (List) trkResult.get("items"); - Stream<String> x = items.stream().map(item -> (String) ((Map) item).get("key")); - return x.collect(Collectors.toList()); + private List<String> searchFile(String key) { + SuggestionsRequest query = new SuggestionsRequest().setS(key); + + Components.SuggestionsWsResponse response = tester.wsClient().components().suggestions(query); + + return response + .getResultsList().stream().filter(result -> "FIL".equals(result.getQ())).findAny().get() + .getItemsList().stream() + .map(Suggestion::getKey) + .collect(Collectors.toList()); } private String executeAnalysis(String projectKey, Organization organization, User orgAdministrator, String projectPath, @Nullable String date) { diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java index 75cffdb3e11..a1716492c52 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/FileExclusionsTest.java @@ -28,7 +28,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.Components.Component; -import org.sonarqube.ws.client.component.TreeRequest; +import org.sonarqube.ws.client.components.TreeRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -134,6 +134,6 @@ public class FileExclusionsTest { } public static List<Component> getComponents(String qualifier) { - return newWsClient(orchestrator).componentsOld().tree(new TreeRequest().setBaseComponentKey(PROJECT).setQualifiers(singletonList(qualifier))).getComponentsList(); + return newWsClient(orchestrator).components().tree(new TreeRequest().setComponent(PROJECT).setQualifiers(singletonList(qualifier))).getComponentsList(); } } diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java index fa7261ced8b..15b20555741 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/ScannerTest.java @@ -33,7 +33,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonarqube.qa.util.Tester; import org.sonarqube.tests.Category3Suite; -import org.sonarqube.ws.client.component.SearchRequest; +import org.sonarqube.ws.client.components.SearchRequest; import util.ItUtils; import static java.util.Collections.singletonList; @@ -68,7 +68,7 @@ public class ScannerTest { scan("shared/xoo-multi-modules-sample"); scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x"); - assertThat(tester.wsClient().componentsOld().search(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList()).hasSize(2); + assertThat(tester.wsClient().components().search(new SearchRequest().setQualifiers(singletonList("TRK"))).getComponentsList()).hasSize(2); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:multi-modules-sample").getName()).isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample"); assertThat(getComponent(orchestrator, "com.sonarsource.it.samples:multi-modules-sample:branch/0.x").getName()) .isEqualTo("Sonar :: Integration Tests :: Multi-modules Sample branch/0.x"); diff --git a/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java b/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java index ad7898a3ab7..6379e36a30a 100644 --- a/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java +++ b/tests/src/test/java/org/sonarqube/tests/authorization/PermissionTemplateTest.java @@ -29,15 +29,15 @@ import org.junit.Test; import org.junit.rules.DisableOnDebug; import org.junit.rules.TestRule; import org.junit.rules.Timeout; -import org.sonarqube.tests.Category6Suite; import org.sonarqube.qa.util.Tester; +import org.sonarqube.tests.Category6Suite; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Permissions; import org.sonarqube.ws.Permissions.CreateTemplateWsResponse; import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.Users.CreateWsResponse; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.permission.AddUserToTemplateRequest; import org.sonarqube.ws.client.permission.ApplyTemplateRequest; import org.sonarqube.ws.client.permission.BulkApplyTemplateRequest; @@ -191,9 +191,9 @@ public class PermissionTemplateTest { } private boolean userHasAccessToIndexedProject(CreateWsResponse.User user, Organization organization, Project project) { - SearchProjectsRequest request = SearchProjectsRequest.builder().setOrganization(organization.getKey()).build(); + SearchProjectsRequest request = new SearchProjectsRequest().setOrganization(organization.getKey()); WsClient userSession = tester.as(user.getLogin()).wsClient(); - return userSession.componentsOld().searchProjects(request) + return userSession.components().searchProjects(request) .getComponentsList().stream() .anyMatch(c -> c.getKey().equals(project.getKey())); } diff --git a/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java b/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java index dbd32671196..d978ad8c32f 100644 --- a/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/component/ComponentsWsTest.java @@ -27,10 +27,8 @@ import org.junit.Test; import org.junit.rules.RuleChain; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Components; -import org.sonarqube.ws.client.component.SearchRequest; -import org.sonarqube.ws.client.component.ShowRequest; +import org.sonarqube.ws.client.components.ShowRequest; -import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; @@ -53,19 +51,10 @@ public class ComponentsWsTest { @Test public void show() { - Components.ShowWsResponse response = tester.wsClient().componentsOld().show(new ShowRequest().setKey(FILE_KEY)); + Components.ShowWsResponse response = tester.wsClient().components().show(new ShowRequest().setComponent(FILE_KEY)); assertThat(response).isNotNull(); assertThat(response.getComponent().getKey()).isEqualTo(FILE_KEY); assertThat(response.getAncestorsList()).isNotEmpty(); } - - @Test - public void search() { - Components.SearchWsResponse response = tester.wsClient().componentsOld().search(new SearchRequest() - .setQualifiers(singletonList("FIL"))); - - assertThat(response).isNotNull(); - assertThat(response.getComponents(0).getKey()).isEqualTo(FILE_KEY); - } } diff --git a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java index 30ace8285e1..1404a396b78 100644 --- a/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java +++ b/tests/src/test/java/org/sonarqube/tests/lite/LiteTest.java @@ -28,7 +28,7 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Issues; import org.sonarqube.ws.Components; import org.sonarqube.ws.Measures; -import org.sonarqube.ws.client.component.TreeRequest; +import org.sonarqube.ws.client.components.TreeRequest; import org.sonarqube.ws.client.issue.IssuesService; import org.sonarqube.ws.client.issue.SearchRequest; import org.sonarqube.ws.client.measure.ComponentTreeRequest; @@ -75,8 +75,8 @@ public class LiteTest { @Test public void call_components_ws() { // files in project - Components.TreeWsResponse tree = tester.wsClient().componentsOld().tree(new TreeRequest() - .setBaseComponentKey(PROJECT_KEY) + Components.TreeWsResponse tree = tester.wsClient().components().tree(new TreeRequest() + .setComponent(PROJECT_KEY) .setQualifiers(singletonList("FIL"))); assertThat(tree.getComponentsCount()).isEqualTo(4); tree.getComponentsList().forEach(c -> { 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 5b72379ff63..dd40c775f24 100644 --- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java @@ -36,7 +36,6 @@ import org.sonarqube.ws.Rules; import org.sonarqube.ws.UserGroups.Group; import org.sonarqube.ws.Users; import org.sonarqube.ws.Users.CreateWsResponse.User; -import org.sonarqube.ws.client.component.ComponentsService; import org.sonarqube.ws.client.organizations.AddMemberRequest; import org.sonarqube.ws.client.organizations.CreateRequest; import org.sonarqube.ws.client.organizations.DeleteRequest; @@ -203,8 +202,7 @@ public class OrganizationTest { "sonar.organization", organization.getKey(), "sonar.login", user.getLogin(), "sonar.password", user.getLogin()); - ComponentsService componentsService = tester.as(user.getLogin()).wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(organization.getKey()).getComponentsList()).hasSize(1); } @Test @@ -219,8 +217,7 @@ public class OrganizationTest { assertThat(e.getResult().getLogs()).contains("Insufficient privileges"); } - ComponentsService componentsService = tester.wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsCount()).isEqualTo(0); + assertThat(searchSampleProject(organization.getKey()).getComponentsCount()).isEqualTo(0); } @Test @@ -229,8 +226,7 @@ public class OrganizationTest { runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.organization", organization.getKey(), "sonar.login", "admin", "sonar.password", "admin"); - ComponentsService componentsService = tester.asAnonymous().wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(organization.getKey()).getComponentsList()).hasSize(1); } private void addPermissionsToUser(String orgKeyAndName, String login, String permission, String... otherPermissions) { @@ -249,12 +245,11 @@ public class OrganizationTest { "sonar.organization", organization.getKey(), "sonar.login", "admin", "sonar.password", "admin"); - ComponentsService componentsService = tester.wsClient().componentsOld(); - assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(organization.getKey()).getComponentsList()).hasSize(1); tester.organizations().service().delete(new DeleteRequest().setOrganization(organization.getKey())); - expectNotFoundError(() -> searchSampleProject(organization.getKey(), componentsService)); + expectNotFoundError(() -> searchSampleProject(organization.getKey())); assertThatOrganizationDoesNotExit(organization); } @@ -297,12 +292,12 @@ public class OrganizationTest { .hasSize(1); } - private Components.SearchWsResponse searchSampleProject(String organizationKey, ComponentsService componentsService) { - return componentsService - .search(new org.sonarqube.ws.client.component.SearchRequest() + private Components.SearchWsResponse searchSampleProject(String organizationKey) { + return tester.wsClient().components() + .search(new org.sonarqube.ws.client.components.SearchRequest() .setOrganization(organizationKey) .setQualifiers(singletonList("TRK")) - .setQuery("sample")); + .setQ("sample")); } private void assertThatOrganizationDoesNotExit(Organization org) { diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java index 6b5a48383a4..8fecbb8eb6f 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectBulkDeletionPageTest.java @@ -26,7 +26,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.Projects.CreateWsResponse.Project; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Condition.visible; @@ -68,7 +68,7 @@ public class ProjectBulkDeletionPageTest { $(".modal button").click(); $("#projects-management-page").shouldNotHave(text(project1.getName())).shouldNotHave(text(project3.getName())); - assertThat(tester.wsClient().componentsOld().searchProjects(SearchProjectsRequest.builder().build()) + assertThat(tester.wsClient().components().searchProjects(new SearchProjectsRequest()) .getComponentsCount()).isEqualTo(1); } } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java index 8216d8897da..9f679c9b20a 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectDeletionTest.java @@ -40,7 +40,7 @@ import org.sonarqube.ws.Users; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.project.DeleteRequest; import org.sonarqube.ws.client.project.SearchRequest; @@ -202,8 +202,8 @@ public class ProjectDeletionTest { * Projects page - api/components/search_projects - uses ES + DB */ private boolean isInComponentSearchProjects(String name) { - Components.SearchProjectsWsResponse response = tester.wsClient().componentsOld().searchProjects( - SearchProjectsRequest.builder().setFilter("query=\"" + name + "\"").build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest().setFilter("query=\"" + name + "\"")); return response.getComponentsCount() > 0; } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java index 3972f771c78..02af1ddf6a0 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectFilterTest.java @@ -34,7 +34,7 @@ import org.sonarqube.ws.Common; import org.sonarqube.ws.Organizations.Organization; import org.sonarqube.ws.Components.Component; import org.sonarqube.ws.Components.SearchProjectsWsResponse; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.project.CreateRequest; import static java.util.Arrays.asList; @@ -90,7 +90,7 @@ public class ProjectFilterTest { String projectKey = newProjectKey(); tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey).setName(projectKey).setOrganization(organization.getKey()).build()); - SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).build()); + SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey())); assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(projectKey); } @@ -110,7 +110,7 @@ public class ProjectFilterTest { tester.wsClient().projects().create(CreateRequest.builder().setKey(projectKey3).setName(projectKey3).setOrganization(organization.getKey()).build()); SearchProjectsWsResponse response = searchProjects( - SearchProjectsRequest.builder().setAdditionalFields(singletonList("leakPeriodDate")).setOrganization(organization.getKey()).build()); + new SearchProjectsRequest().setF(singletonList("leakPeriodDate")).setOrganization(organization.getKey())); assertThat(response.getComponentsList()).extracting(Component::getKey, Component::hasLeakPeriodDate) .containsOnly( @@ -137,18 +137,18 @@ public class ProjectFilterTest { assertThat(searchProjects("query = \"unknown\"").getComponentsList()).isEmpty(); // Search by metric criteria and text query - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"pAch\" AND ncloc > 50").build()).getComponentsList()) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"pAch\" AND ncloc > 50")).getComponentsList()) .extracting(Component::getKey).containsExactly("project3"); - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"nd\" AND ncloc > 50").build()).getComponentsList()) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"nd\" AND ncloc > 50")).getComponentsList()) .extracting(Component::getKey).containsExactly("project3", "project4"); - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"unknown\" AND ncloc > 50").build()).getComponentsList()).isEmpty(); + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"unknown\" AND ncloc > 50")).getComponentsList()).isEmpty(); ; // Check facets - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"apache\"").setFacets(singletonList("ncloc")).build()).getFacets().getFacets(0).getValuesList()) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"apache\"").setFacets(singletonList("ncloc"))).getFacets().getFacets(0).getValuesList()) .extracting(Common.FacetValue::getVal, Common.FacetValue::getCount) .containsOnly(tuple("*-1000.0", 3L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 0L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 0L)); - assertThat(searchProjects(SearchProjectsRequest.builder().setFilter("query = \"unknown\"").setFacets(singletonList("ncloc")).build()).getFacets().getFacets(0) + assertThat(searchProjects(new SearchProjectsRequest().setFilter("query = \"unknown\"").setFacets(singletonList("ncloc"))).getFacets().getFacets(0) .getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount) .containsOnly(tuple("*-1000.0", 0L), tuple("1000.0-10000.0", 0L), tuple("10000.0-100000.0", 0L), tuple("100000.0-500000.0", 0L), tuple("500000.0-*", 0L)); } @@ -158,7 +158,7 @@ public class ProjectFilterTest { analyzeProject(newProjectKey(), "shared/xoo-sample"); analyzeProject(newProjectKey(), "shared/xoo-multi-modules-sample"); - SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).setFacets(asList( + SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()).setFacets(asList( "alert_status", "coverage", "duplicated_lines_density", @@ -167,7 +167,7 @@ public class ProjectFilterTest { "reliability_rating", "security_rating", "sqale_rating", - "tags")).build()); + "tags"))); checkFacet(response, "alert_status", tuple("OK", 2L), @@ -228,8 +228,8 @@ public class ProjectFilterTest { analyzeProject(projectKey2, "projectSearch/xoo-history-v1", "sonar.projectDate", "2016-12-31"); analyzeProject(projectKey2, "projectSearch/xoo-history-v2"); - SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).setFacets(asList( - "new_reliability_rating", "new_security_rating", "new_maintainability_rating", "new_coverage", "new_duplicated_lines_density", "new_lines")).build()); + SearchProjectsWsResponse response = searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()).setFacets(asList( + "new_reliability_rating", "new_security_rating", "new_maintainability_rating", "new_coverage", "new_duplicated_lines_density", "new_lines"))); checkFacet(response, "new_reliability_rating", tuple("1", 2L), @@ -287,11 +287,11 @@ public class ProjectFilterTest { } private SearchProjectsWsResponse searchProjects(String filter) throws IOException { - return searchProjects(SearchProjectsRequest.builder().setOrganization(organization.getKey()).setFilter(filter).build()); + return searchProjects(new SearchProjectsRequest().setOrganization(organization.getKey()).setFilter(filter)); } private SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) throws IOException { - return tester.wsClient().componentsOld().searchProjects(request); + return tester.wsClient().components().searchProjects(request); } private void verifyFilterMatches(String projectKey, String filter) throws IOException { diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java index 2ab5e74158d..d42e850af28 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdateTest.java @@ -39,8 +39,8 @@ import org.sonarqube.ws.Organizations; import org.sonarqube.ws.Projects; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.component.SearchProjectsRequest; -import org.sonarqube.ws.client.component.ShowRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; +import org.sonarqube.ws.client.components.ShowRequest; import org.sonarqube.ws.client.project.BulkUpdateKeyRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.project.UpdateKeyRequest; @@ -71,7 +71,7 @@ public class ProjectKeyUpdateTest { public void update_key() { analyzeXooSample(); String newProjectKey = "another_project_key"; - Components.Component project = tester.wsClient().componentsOld().show(new ShowRequest().setKey(PROJECT_KEY)).getComponent(); + Components.Component project = tester.wsClient().components().show(new ShowRequest().setComponent(PROJECT_KEY)).getComponent(); assertThat(project.getKey()).isEqualTo(PROJECT_KEY); tester.wsClient().projects().updateKey(UpdateKeyRequest.builder() @@ -79,14 +79,14 @@ public class ProjectKeyUpdateTest { .setNewKey(newProjectKey) .build()); - assertThat(tester.wsClient().componentsOld().show(new ShowRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); + assertThat(tester.wsClient().components().show(new ShowRequest().setComponentId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); } @Test public void bulk_update_key() { analyzeXooSample(); String newProjectKey = "another_project_key"; - Components.Component project = tester.wsClient().componentsOld().show(new ShowRequest().setKey(PROJECT_KEY)).getComponent(); + Components.Component project = tester.wsClient().components().show(new ShowRequest().setComponent(PROJECT_KEY)).getComponent(); assertThat(project.getKey()).isEqualTo(PROJECT_KEY); Projects.BulkUpdateKeyWsResponse result = tester.wsClient().projects().bulkUpdateKey(BulkUpdateKeyRequest.builder() @@ -95,7 +95,7 @@ public class ProjectKeyUpdateTest { .setTo(newProjectKey) .build()); - assertThat(tester.wsClient().componentsOld().show(new ShowRequest().setId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); + assertThat(tester.wsClient().components().show(new ShowRequest().setComponentId(project.getId())).getComponent().getKey()).isEqualTo(newProjectKey); assertThat(result.getKeysCount()).isEqualTo(1); assertThat(result.getKeys(0)) .extracting(Projects.BulkUpdateKeyWsResponse.Key::getKey, Projects.BulkUpdateKeyWsResponse.Key::getNewKey, Projects.BulkUpdateKeyWsResponse.Key::getDuplicate) @@ -254,8 +254,8 @@ public class ProjectKeyUpdateTest { */ @CheckForNull private String keyInComponentSearchProjects(String name) { - Components.SearchProjectsWsResponse response = tester.wsClient().componentsOld().searchProjects( - SearchProjectsRequest.builder().setFilter("query=\"" + name + "\"").build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest().setFilter("query=\"" + name + "\"")); if (response.getComponentsCount() > 0) { return response.getComponents(0).getKey(); } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java index 1faa8d031e3..ddb5803da22 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectProvisioningTest.java @@ -35,7 +35,7 @@ import org.sonarqube.ws.Projects; import org.sonarqube.ws.Projects.CreateWsResponse.Project; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.project.CreateRequest; import org.sonarqube.ws.client.project.SearchRequest; import util.ItUtils; @@ -109,8 +109,8 @@ public class ProjectProvisioningTest { * Projects page - api/components/search_projects - uses ES + DB */ private boolean isInComponentSearchProjects(String name) { - Components.SearchProjectsWsResponse response = tester.wsClient().componentsOld().searchProjects( - SearchProjectsRequest.builder().setFilter("query=\"" + name + "\"").build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest().setFilter("query=\"" + name + "\"")); return response.getComponentsCount() > 0; } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java index 0f9c90fb04e..926212d90fc 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectVisibilityPageTest.java @@ -28,12 +28,11 @@ import org.junit.Test; import org.sonarqube.qa.util.Tester; import org.sonarqube.qa.util.pageobjects.ProjectsManagementPage; import org.sonarqube.ws.Components; -import org.sonarqube.ws.client.component.SearchProjectsRequest; +import org.sonarqube.ws.client.components.SearchProjectsRequest; import org.sonarqube.ws.client.permission.RemoveGroupRequest; import org.sonarqube.ws.client.project.UpdateVisibilityRequest; import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; public class ProjectVisibilityPageTest { @@ -84,8 +83,8 @@ public class ProjectVisibilityPageTest { .createProject("foo", "foo", visibility) .shouldHaveProjectsCount(1); - Components.SearchProjectsWsResponse response = newAdminWsClient(orchestrator).componentsOld().searchProjects( - SearchProjectsRequest.builder().build()); + Components.SearchProjectsWsResponse response = tester.wsClient().components().searchProjects( + new SearchProjectsRequest()); assertThat(response.getComponentsCount()).isEqualTo(1); assertThat(response.getComponents(0).getKey()).isEqualTo("foo"); assertThat(response.getComponents(0).getName()).isEqualTo("foo"); diff --git a/tests/src/test/java/util/ItUtils.java b/tests/src/test/java/util/ItUtils.java index 6ac8775f635..c1dfd54f86e 100644 --- a/tests/src/test/java/util/ItUtils.java +++ b/tests/src/test/java/util/ItUtils.java @@ -70,7 +70,7 @@ import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.HttpConnector; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; -import org.sonarqube.ws.client.component.ShowRequest; +import org.sonarqube.ws.client.components.ShowRequest; import org.sonarqube.ws.client.measure.ComponentRequest; import org.sonarqube.ws.client.qualityprofile.RestoreRequest; import org.sonarqube.ws.client.settings.ResetRequest; @@ -373,7 +373,7 @@ public class ItUtils { @CheckForNull public static Component getComponent(Orchestrator orchestrator, String componentKey) { try { - return newWsClient(orchestrator).componentsOld().show(new ShowRequest().setKey((componentKey))).getComponent(); + return newWsClient(orchestrator).components().show(new ShowRequest().setComponent((componentKey))).getComponent(); } catch (org.sonarqube.ws.client.HttpException e) { if (e.code() == 404) { return null; |