diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-22 21:51:52 +0100 |
---|---|---|
committer | Daniel Schwarz <bartfastiel@users.noreply.github.com> | 2017-11-29 20:24:11 +0100 |
commit | 554fb67ddb958cdfafb6fcd40b7d50a298e8d147 (patch) | |
tree | ab49c311fdedb6789b616247e48f30a7c3e1fbae /tests | |
parent | d1157c4101390a94167aebad27d054c93e0d66f4 (diff) | |
download | sonarqube-554fb67ddb958cdfafb6fcd40b7d50a298e8d147.tar.gz sonarqube-554fb67ddb958cdfafb6fcd40b7d50a298e8d147.zip |
Initial generation of sonar-ws client
Diffstat (limited to 'tests')
9 files changed, 38 insertions, 32 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/FavoriteTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/FavoriteTest.java index 1bb37ef7303..14b60781d47 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/FavoriteTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/FavoriteTest.java @@ -31,7 +31,7 @@ import org.sonarqube.ws.Favorites; import org.sonarqube.ws.Favorites.Favorite; import org.sonarqube.ws.Permissions; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.favorite.SearchRequest; +import org.sonarqube.ws.client.favorites.SearchRequest; import org.sonarqube.ws.client.permission.AddProjectCreatorToTemplateWsRequest; import org.sonarqube.ws.client.permission.RemoveProjectCreatorFromTemplateWsRequest; import org.sonarqube.ws.client.permission.SearchTemplatesWsRequest; diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/LinksTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/LinksTest.java index 574dc29c367..2f2e20bc59a 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/LinksTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/LinksTest.java @@ -23,15 +23,15 @@ import com.google.common.collect.ImmutableMap; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.MavenBuild; import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category3Suite; import java.util.List; import java.util.Optional; import org.junit.After; import org.junit.ClassRule; import org.junit.Test; +import org.sonarqube.tests.Category3Suite; import org.sonarqube.ws.ProjectLinks; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.projectlinks.SearchWsRequest; +import org.sonarqube.ws.client.projectlinks.SearchRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -75,7 +75,7 @@ public class LinksTest { private void verifyLinks() { WsClient wsClient = ItUtils.newWsClient(orchestrator); - List<ProjectLinks.Link> links = wsClient.projectLinks().search(new SearchWsRequest().setProjectKey(PROJECT_KEY)).getLinksList(); + List<ProjectLinks.Link> links = wsClient.projectLinks().search(new SearchRequest().setProjectKey(PROJECT_KEY)).getLinksList(); verifyLink(links, "homepage", "http://www.simplesample.org_OVERRIDDEN"); verifyLink(links, "ci", "http://bamboo.ci.codehaus.org/browse/SIMPLESAMPLE"); verifyLink(links, "issue", "http://jira.codehaus.org/browse/SIMPLESAMPLE"); diff --git a/tests/src/test/java/org/sonarqube/tests/analysis/PermissionTest.java b/tests/src/test/java/org/sonarqube/tests/analysis/PermissionTest.java index d0f4eefd4a4..b7d8921246d 100644 --- a/tests/src/test/java/org/sonarqube/tests/analysis/PermissionTest.java +++ b/tests/src/test/java/org/sonarqube/tests/analysis/PermissionTest.java @@ -32,9 +32,9 @@ import org.junit.Test; import org.sonarqube.ws.UserTokens; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.permission.AddUserWsRequest; -import org.sonarqube.ws.client.usertoken.GenerateWsRequest; -import org.sonarqube.ws.client.usertoken.RevokeWsRequest; -import org.sonarqube.ws.client.usertoken.UserTokensService; +import org.sonarqube.ws.client.usertokens.GenerateRequest; +import org.sonarqube.ws.client.usertokens.RevokeRequest; +import org.sonarqube.ws.client.usertokens.UserTokensService; import util.user.UserRule; import static org.assertj.core.api.Assertions.assertThat; @@ -79,7 +79,7 @@ public class PermissionTest { createUserWithProvisioningAndScanPermissions(); String tokenName = "For test"; - UserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateWsRequest() + UserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateRequest() .setLogin(A_LOGIN) .setName(tokenName)); SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample")); @@ -90,7 +90,7 @@ public class PermissionTest { BuildResult buildResult = orchestrator.executeBuild(sampleProject); assertThat(buildResult.isSuccess()).isTrue(); - userTokensWsClient.revoke(new RevokeWsRequest().setLogin(A_LOGIN).setName(tokenName)); + userTokensWsClient.revoke(new RevokeRequest().setLogin(A_LOGIN).setName(tokenName)); } @Test diff --git a/tests/src/test/java/org/sonarqube/tests/component/BranchTest.java b/tests/src/test/java/org/sonarqube/tests/component/BranchTest.java index 3d0b3c8ab02..a4a0ad170a8 100644 --- a/tests/src/test/java/org/sonarqube/tests/component/BranchTest.java +++ b/tests/src/test/java/org/sonarqube/tests/component/BranchTest.java @@ -30,6 +30,7 @@ import org.sonarqube.ws.Common; import org.sonarqube.ws.ProjectBranches; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsResponse; +import org.sonarqube.ws.client.projectbranches.ListRequest; import util.ItUtils; import static org.assertj.core.api.Java6Assertions.assertThat; @@ -47,7 +48,7 @@ public class BranchTest { public void list_branches_contains_main_branch() { runProjectAnalysis(orchestrator, "shared/xoo-sample"); - ProjectBranches.ListWsResponse result = tester.wsClient().projectBranches().list("sample"); + ProjectBranches.ListWsResponse result = tester.wsClient().projectBranches().list(new ListRequest().setProject("sample")); assertThat(result.getBranchesList()) .extracting(ProjectBranches.Branch::getName, ProjectBranches.Branch::getType, ProjectBranches.Branch::getIsMain) diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectLinksTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectLinksTest.java index b980b287381..17e15dadd13 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectLinksTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectLinksTest.java @@ -33,8 +33,8 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.qa.util.pageobjects.ProjectLinkItem; import org.sonarqube.qa.util.pageobjects.ProjectLinksPage; import org.sonarqube.ws.ProjectLinks.CreateWsResponse; -import org.sonarqube.ws.client.projectlinks.CreateWsRequest; -import org.sonarqube.ws.client.projectlinks.DeleteWsRequest; +import org.sonarqube.ws.client.projectlinks.CreateRequest; +import org.sonarqube.ws.client.projectlinks.DeleteRequest; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Selenide.$; @@ -131,7 +131,7 @@ public class ProjectLinksTest { } private CreateWsResponse createCustomLink() { - return tester.wsClient().projectLinks().create(new CreateWsRequest() + return tester.wsClient().projectLinks().create(new CreateRequest() .setProjectKey("sample") .setName("Custom") .setUrl("http://example.org/custom")); @@ -139,7 +139,7 @@ public class ProjectLinksTest { private void deleteLink(long id) { try { - tester.wsClient().projectLinks().delete(new DeleteWsRequest().setId(id)); + tester.wsClient().projectLinks().delete(new DeleteRequest().setId("" + id)); } catch (Exception e) { // fail silently } diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectsPageTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectsPageTest.java index a18787080f5..0bf926b80b3 100644 --- a/tests/src/test/java/org/sonarqube/tests/project/ProjectsPageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/project/ProjectsPageTest.java @@ -32,6 +32,8 @@ import org.sonarqube.qa.util.pageobjects.projects.ProjectsPage; import org.sonarqube.ws.Users; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; +import org.sonarqube.ws.client.favorites.AddRequest; +import org.sonarqube.ws.client.favorites.RemoveRequest; import static com.codeborne.selenide.Selenide.clearBrowserLocalStorage; import static com.codeborne.selenide.WebDriverRunner.url; @@ -110,12 +112,12 @@ public class ProjectsPageTest { // favorite one project WsClient administratorWsClient = tester.as(administrator.getLogin()).wsClient(); - administratorWsClient.favorites().add(PROJECT_KEY); + administratorWsClient.favorites().add(new AddRequest().setComponent(PROJECT_KEY)); page = nav.openProjects(); page.shouldHaveTotal(1).shouldDisplayFavoriteProjects(); // un-favorite this project - administratorWsClient.favorites().remove(PROJECT_KEY); + administratorWsClient.favorites().remove(new RemoveRequest().setComponent(PROJECT_KEY)); page = nav.openProjects(); page.shouldHaveTotal(2).shouldDisplayAllProjects(); diff --git a/tests/src/test/java/org/sonarqube/tests/user/FavoritesWsTest.java b/tests/src/test/java/org/sonarqube/tests/user/FavoritesWsTest.java index fbcd3181ad3..8baa938ef66 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/FavoritesWsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/FavoritesWsTest.java @@ -21,14 +21,16 @@ package org.sonarqube.tests.user; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; -import org.sonarqube.tests.Category4Suite; import java.util.List; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; +import org.sonarqube.tests.Category4Suite; import org.sonarqube.ws.Favorites.Favorite; import org.sonarqube.ws.client.WsClient; -import org.sonarqube.ws.client.favorite.SearchRequest; +import org.sonarqube.ws.client.favorites.AddRequest; +import org.sonarqube.ws.client.favorites.RemoveRequest; +import org.sonarqube.ws.client.favorites.SearchRequest; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.newAdminWsClient; @@ -56,15 +58,15 @@ public class FavoritesWsTest { assertThat(favorites).isEmpty(); // POST (create favorites) - adminClient.favorites().add("sample"); - adminClient.favorites().add("sample:src/main/xoo/sample/Sample.xoo"); + adminClient.favorites().add(new AddRequest().setComponent("sample")); + adminClient.favorites().add(new AddRequest().setComponent("sample:src/main/xoo/sample/Sample.xoo")); // GET (created favorites) favorites = adminClient.favorites().search(new SearchRequest()).getFavoritesList(); assertThat(favorites.stream().map(Favorite::getKey)).containsOnly("sample", "sample:src/main/xoo/sample/Sample.xoo"); // DELETE (a favorite) - adminClient.favorites().remove("sample"); + adminClient.favorites().remove(new RemoveRequest().setComponent("sample")); favorites = adminClient.favorites().search(new SearchRequest()).getFavoritesList(); assertThat(favorites.stream().map(Favorite::getKey)).containsOnly("sample:src/main/xoo/sample/Sample.xoo"); } diff --git a/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java b/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java index 14b8237feab..1955c1c2f62 100644 --- a/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java +++ b/tests/src/test/java/org/sonarqube/tests/user/LocalAuthenticationTest.java @@ -40,10 +40,10 @@ import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.user.CreateRequest; -import org.sonarqube.ws.client.usertoken.GenerateWsRequest; -import org.sonarqube.ws.client.usertoken.RevokeWsRequest; -import org.sonarqube.ws.client.usertoken.SearchWsRequest; -import org.sonarqube.ws.client.usertoken.UserTokensService; +import org.sonarqube.ws.client.usertokens.GenerateRequest; +import org.sonarqube.ws.client.usertokens.RevokeRequest; +import org.sonarqube.ws.client.usertokens.SearchRequest; +import org.sonarqube.ws.client.usertokens.UserTokensService; import util.selenium.Selenese; import static java.lang.String.format; @@ -106,7 +106,7 @@ public class LocalAuthenticationTest { User user = tester.users().generate(); String tokenName = "Validate token based authentication"; UserTokensService tokensService = tester.wsClient().userTokens(); - UserTokens.GenerateWsResponse generateWsResponse = tokensService.generate(new GenerateWsRequest() + UserTokens.GenerateWsResponse generateWsResponse = tokensService.generate(new GenerateRequest() .setLogin(user.getLogin()) .setName(tokenName)); WsClient wsClient = WsClientFactories.getDefault().newClient(HttpConnector.newBuilder() @@ -117,10 +117,10 @@ public class LocalAuthenticationTest { assertThat(response.content()).isEqualTo("{\"valid\":true}"); - UserTokens.SearchWsResponse searchResponse = tokensService.search(new SearchWsRequest().setLogin(user.getLogin())); + UserTokens.SearchWsResponse searchResponse = tokensService.search(new SearchRequest().setLogin(user.getLogin())); assertThat(searchResponse.getUserTokensCount()).isEqualTo(1); - tokensService.revoke(new RevokeWsRequest().setLogin(user.getLogin()).setName(tokenName)); - searchResponse = tokensService.search(new SearchWsRequest().setLogin(user.getLogin())); + tokensService.revoke(new RevokeRequest().setLogin(user.getLogin()).setName(tokenName)); + searchResponse = tokensService.search(new SearchRequest().setLogin(user.getLogin())); assertThat(searchResponse.getUserTokensCount()).isEqualTo(0); } diff --git a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java index 003c3eba941..5aba7eeb6c4 100644 --- a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java +++ b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java @@ -37,7 +37,8 @@ import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.project.DeleteRequest; import org.sonarqube.ws.client.setting.ResetRequest; import org.sonarqube.ws.client.setting.SetRequest; -import org.sonarqube.ws.client.webhook.DeliveriesRequest; +import org.sonarqube.ws.client.webhooks.DeliveriesRequest; +import org.sonarqube.ws.client.webhooks.DeliveryRequest; import util.ItUtils; import static java.util.Objects.requireNonNull; @@ -220,7 +221,7 @@ public class WebhooksTest { } private List<Webhooks.Delivery> getPersistedDeliveries() { - DeliveriesRequest deliveriesReq = DeliveriesRequest.builder().setComponentKey(PROJECT_KEY).build(); + DeliveriesRequest deliveriesReq = new DeliveriesRequest().setComponentKey(PROJECT_KEY); return adminWs.webhooks().deliveries(deliveriesReq).getDeliveriesList(); } @@ -230,7 +231,7 @@ public class WebhooksTest { } private Webhooks.Delivery getDetailOfPersistedDelivery(Webhooks.Delivery delivery) { - Webhooks.Delivery detail = adminWs.webhooks().delivery(delivery.getId()).getDelivery(); + Webhooks.Delivery detail = adminWs.webhooks().delivery(new DeliveryRequest().setDeliveryId(delivery.getId())).getDelivery(); return requireNonNull(detail); } |