diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-11-25 10:54:56 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-11-30 19:01:45 +0100 |
commit | bba16edb777a69137b3122dfbc5b898049f274c5 (patch) | |
tree | 17be034a5b93b109d2dd1148398225f77875e56b /it | |
parent | 08dbeeee650d4792b6aaabb109ccd9504d282804 (diff) | |
download | sonarqube-bba16edb777a69137b3122dfbc5b898049f274c5.tar.gz sonarqube-bba16edb777a69137b3122dfbc5b898049f274c5.zip |
SONAR-7054 use ws-client in batch
Diffstat (limited to 'it')
7 files changed, 53 insertions, 52 deletions
diff --git a/it/it-tests/src/test/java/it/actionPlan/ActionPlanTest.java b/it/it-tests/src/test/java/it/actionPlan/ActionPlanTest.java index 914ed9eb526..fe73d0dc13c 100644 --- a/it/it-tests/src/test/java/it/actionPlan/ActionPlanTest.java +++ b/it/it-tests/src/test/java/it/actionPlan/ActionPlanTest.java @@ -137,7 +137,7 @@ public class ActionPlanTest { try { // Create a user having admin permission on the project adminClient.userClient().create(UserParameters.create().login(projectAdminUser).name(projectAdminUser).password("password").passwordConfirmation("password")); - adminWsClient.permissionsClient().addUser( + adminWsClient.permissions().addUser( new AddUserWsRequest() .setLogin(projectAdminUser) .setProjectKey(PROJECT_KEY) @@ -145,7 +145,7 @@ public class ActionPlanTest { // Create a user having browse permission on the project adminClient.userClient().create(UserParameters.create().login(projectUser).name(projectUser).password("password").passwordConfirmation("password")); - adminWsClient.permissionsClient().addUser( + adminWsClient.permissions().addUser( new AddUserWsRequest() .setLogin(projectUser) .setProjectKey(PROJECT_KEY) diff --git a/it/it-tests/src/test/java/it/authorisation/AuthenticationTest.java b/it/it-tests/src/test/java/it/authorisation/AuthenticationTest.java index 30d0bdd5043..7288287edbe 100644 --- a/it/it-tests/src/test/java/it/authorisation/AuthenticationTest.java +++ b/it/it-tests/src/test/java/it/authorisation/AuthenticationTest.java @@ -32,18 +32,20 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; import org.sonarqube.ws.WsUserTokens; +import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.HttpConnector; +import org.sonarqube.ws.client.HttpWsClient; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; +import org.sonarqube.ws.client.WsResponse; import org.sonarqube.ws.client.permission.AddGroupWsRequest; import org.sonarqube.ws.client.permission.AddUserWsRequest; import org.sonarqube.ws.client.permission.RemoveGroupWsRequest; import org.sonarqube.ws.client.usertoken.GenerateWsRequest; -import org.sonarqube.ws.client.usertoken.UserTokensWsClient; +import org.sonarqube.ws.client.usertoken.UserTokensService; import static java.lang.String.format; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.HttpConnector.newHttpConnector; -import static org.sonarqube.ws.client.WsRequest.newGetRequest; -import static org.sonarqube.ws.client.WsRequest.newPostRequest; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; @@ -51,7 +53,7 @@ public class AuthenticationTest { @ClassRule public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR; private static WsClient adminWsClient; - private static UserTokensWsClient userTokensWsClient; + private static UserTokensService userTokensWsClient; private static final String PROJECT_KEY = "sample"; private static final String LOGIN = "george.orwell"; @@ -64,7 +66,7 @@ public class AuthenticationTest { ORCHESTRATOR.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line"); adminWsClient = newAdminWsClient(ORCHESTRATOR); - userTokensWsClient = adminWsClient.userTokensWsClient(); + userTokensWsClient = adminWsClient.userTokens(); removeGroupPermission("anyone", "dryRunScan"); removeGroupPermission("anyone", "scan"); @@ -89,9 +91,9 @@ public class AuthenticationTest { createUser(login, name, password); // authenticate - WsClient wsClient = new WsClient(newHttpConnector().url(ORCHESTRATOR.getServer().getUrl()).login(login).password(password).build()); - String response = wsClient.execute(newGetRequest("api/authentication/validate")); - assertThat(response).isEqualTo("{\"valid\":true}"); + WsClient wsClient = new HttpWsClient(new HttpConnector.Builder().url(ORCHESTRATOR.getServer().getUrl()).credentials(login, password).build()); + WsResponse response = wsClient.wsConnector().call(new GetRequest("api/authentication/validate")); + assertThat(response.getContent()).isEqualTo("{\"valid\":true}"); } @Test @@ -99,14 +101,13 @@ public class AuthenticationTest { WsUserTokens.GenerateWsResponse generateWsResponse = userTokensWsClient.generate(new GenerateWsRequest() .setLogin(LOGIN) .setName("Validate token based authentication")); - WsClient wsClient = new WsClient(newHttpConnector() + WsClient wsClient = new HttpWsClient(new HttpConnector.Builder() .url(ORCHESTRATOR.getServer().getUrl()) - .login(generateWsResponse.getToken()) - .password("").build()); + .token(generateWsResponse.getToken()).build()); - String response = wsClient.execute(newGetRequest("api/authentication/validate")); + WsResponse response = wsClient.wsConnector().call(new GetRequest("api/authentication/validate")); - assertThat(response).isEqualTo("{\"valid\":true}"); + assertThat(response.getContent()).isEqualTo("{\"valid\":true}"); } /** @@ -123,9 +124,9 @@ public class AuthenticationTest { createUser(login, format("name-%s", userId), password); // authenticate - WsClient wsClient = new WsClient(newHttpConnector().url(ORCHESTRATOR.getServer().getUrl()).login(login).password(password).build()); - String response = wsClient.execute(newGetRequest("api/authentication/validate")); - assertThat(response).isEqualTo("{\"valid\":false}"); + WsClient wsClient = new HttpWsClient(new HttpConnector.Builder().url(ORCHESTRATOR.getServer().getUrl()).credentials(login, password).build()); + WsResponse response = wsClient.wsConnector().call(new GetRequest("api/authentication/validate")); + assertThat(response.getContent()).isEqualTo("{\"valid\":false}"); } @Test @@ -162,41 +163,41 @@ public class AuthenticationTest { } private static void createUser(String login, String password) { - adminWsClient.execute( - newPostRequest("api/users/create") + adminWsClient.wsConnector().call( + new PostRequest("api/users/create") .setParam("login", login) .setParam("name", login) .setParam("password", password)); } private static void createUser(String login, String name, String password) { - adminWsClient.execute( - newPostRequest("api/users/create") + adminWsClient.wsConnector().call( + new PostRequest("api/users/create") .setParam("login", login) .setParam("name", name) .setParam("password", password)); } private static void addUserPermission(String login, String permission) { - adminWsClient.permissionsClient().addUser(new AddUserWsRequest() + adminWsClient.permissions().addUser(new AddUserWsRequest() .setLogin(login) .setPermission(permission)); } private static void deactivateUser(String login) { - adminWsClient.execute( - newPostRequest("api/users/deactivate") + adminWsClient.wsConnector().call( + new PostRequest("api/users/deactivate") .setParam("login", login)); } private static void removeGroupPermission(String groupName, String permission) { - adminWsClient.permissionsClient().removeGroup(new RemoveGroupWsRequest() + adminWsClient.permissions().removeGroup(new RemoveGroupWsRequest() .setGroupName(groupName) .setPermission(permission)); } private static void addGroupPermission(String groupName, String permission) { - adminWsClient.permissionsClient().addGroup(new AddGroupWsRequest() + adminWsClient.permissions().addGroup(new AddGroupWsRequest() .setGroupName(groupName) .setPermission(permission)); } diff --git a/it/it-tests/src/test/java/it/authorisation/IssuePermissionTest.java b/it/it-tests/src/test/java/it/authorisation/IssuePermissionTest.java index 5a45198f444..3eb384be9d1 100644 --- a/it/it-tests/src/test/java/it/authorisation/IssuePermissionTest.java +++ b/it/it-tests/src/test/java/it/authorisation/IssuePermissionTest.java @@ -229,7 +229,7 @@ public class IssuePermissionTest { } private void addUserPermission(String login, String projectKey, String permission) { - adminWsClient.permissionsClient().addUser( + adminWsClient.permissions().addUser( new AddUserWsRequest() .setLogin(login) .setProjectKey(projectKey) @@ -237,7 +237,7 @@ public class IssuePermissionTest { } private void removeGroupPermission(String groupName, String projectKey, String permission) { - adminWsClient.permissionsClient().removeGroup(new RemoveGroupWsRequest() + adminWsClient.permissions().removeGroup(new RemoveGroupWsRequest() .setGroupName(groupName) .setProjectKey(projectKey) .setPermission(permission)); diff --git a/it/it-tests/src/test/java/it/authorisation/PermissionTest.java b/it/it-tests/src/test/java/it/authorisation/PermissionTest.java index e3dfe05fdb0..8c273061637 100644 --- a/it/it-tests/src/test/java/it/authorisation/PermissionTest.java +++ b/it/it-tests/src/test/java/it/authorisation/PermissionTest.java @@ -30,6 +30,7 @@ import org.junit.ClassRule; import org.junit.Test; import org.sonarqube.ws.WsPermissions; import org.sonarqube.ws.WsPermissions.SearchTemplatesWsResponse; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.permission.AddGroupToTemplateWsRequest; import org.sonarqube.ws.client.permission.AddGroupWsRequest; @@ -37,14 +38,13 @@ import org.sonarqube.ws.client.permission.AddUserToTemplateWsRequest; import org.sonarqube.ws.client.permission.AddUserWsRequest; import org.sonarqube.ws.client.permission.CreateTemplateWsRequest; import org.sonarqube.ws.client.permission.GroupsWsRequest; -import org.sonarqube.ws.client.permission.PermissionsWsClient; +import org.sonarqube.ws.client.permission.PermissionsService; import org.sonarqube.ws.client.permission.RemoveGroupFromTemplateWsRequest; import org.sonarqube.ws.client.permission.RemoveUserFromTemplateWsRequest; import org.sonarqube.ws.client.permission.SearchTemplatesWsRequest; import org.sonarqube.ws.client.permission.UsersWsRequest; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.WsRequest.newPostRequest; import static util.ItUtils.newAdminWsClient; import static util.ItUtils.projectDir; @@ -52,7 +52,7 @@ public class PermissionTest { @ClassRule public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; private static WsClient adminWsClient; - private static PermissionsWsClient permissionsWsClient; + private static PermissionsService permissionsWsClient; private static final String PROJECT_KEY = "sample"; private static final String LOGIN = "george.orwell"; @@ -70,7 +70,7 @@ public class PermissionTest { orchestrator.executeBuild(sampleProject); adminWsClient = newAdminWsClient(orchestrator); - permissionsWsClient = adminWsClient.permissionsClient(); + permissionsWsClient = adminWsClient.permissions(); createUser(LOGIN, "George Orwell"); createGroup(GROUP_NAME); @@ -157,28 +157,28 @@ public class PermissionTest { } private static void createUser(String login, String name) { - adminWsClient.execute( - newPostRequest("api/users/create") + adminWsClient.wsConnector().call( + new PostRequest("api/users/create") .setParam("login", login) .setParam("name", name) .setParam("password", "123456")); } private static void deactivateUser(String login) { - adminWsClient.execute( - newPostRequest("api/users/deactivate") + adminWsClient.wsConnector().call( + new PostRequest("api/users/deactivate") .setParam("login", login)); } private static void createGroup(String groupName) { - adminWsClient.execute( - newPostRequest("api/user_groups/create") + adminWsClient.wsConnector().call( + new PostRequest("api/user_groups/create") .setParam("name", groupName)); } private static void deleteGroup(String groupName) { - adminWsClient.execute( - newPostRequest("api/user_groups/delete") + adminWsClient.wsConnector().call( + new PostRequest("api/user_groups/delete") .setParam("name", groupName)); } } diff --git a/it/it-tests/src/test/java/it/issue/CommonRulesTest.java b/it/it-tests/src/test/java/it/issue/CommonRulesTest.java index fcd14f5061f..6324365637f 100644 --- a/it/it-tests/src/test/java/it/issue/CommonRulesTest.java +++ b/it/it-tests/src/test/java/it/issue/CommonRulesTest.java @@ -86,7 +86,7 @@ public class CommonRulesTest extends AbstractIssueTest { } private List<Issue> findIssues(String componentKey, String ruleKey) { - return adminWsClient.issuesWsClient().search( + return adminWsClient.issues().search( new SearchWsRequest() .setComponents(singletonList(componentKey)) .setRules(singletonList(ruleKey))) diff --git a/it/it-tests/src/test/java/it/measureFilter/MeasureFiltersTest.java b/it/it-tests/src/test/java/it/measureFilter/MeasureFiltersTest.java index 17f4fb9de52..4d0a3fdadff 100644 --- a/it/it-tests/src/test/java/it/measureFilter/MeasureFiltersTest.java +++ b/it/it-tests/src/test/java/it/measureFilter/MeasureFiltersTest.java @@ -147,7 +147,7 @@ public class MeasureFiltersTest { client.userClient().create(userCreationParameters); if (permission != null) { - adminWsClient.permissionsClient().addUser(new AddUserWsRequest() + adminWsClient.permissions().addUser(new AddUserWsRequest() .setLogin(login) .setPermission(permission)); } diff --git a/it/it-tests/src/test/java/util/ItUtils.java b/it/it-tests/src/test/java/util/ItUtils.java index 0f293e3b4ce..6270b999363 100644 --- a/it/it-tests/src/test/java/util/ItUtils.java +++ b/it/it-tests/src/test/java/util/ItUtils.java @@ -1,8 +1,8 @@ package util;/* - * Copyright (C) 2009-2014 SonarSource SA - * All rights reserved - * mailto:contact AT sonarsource DOT com - */ + * Copyright (C) 2009-2014 SonarSource SA + * All rights reserved + * mailto:contact AT sonarsource DOT com + */ import com.google.common.base.Supplier; import com.google.common.base.Suppliers; @@ -32,13 +32,14 @@ import org.sonar.wsclient.issue.IssueClient; import org.sonar.wsclient.issue.IssueQuery; import org.sonar.wsclient.services.PropertyDeleteQuery; import org.sonar.wsclient.services.PropertyUpdateQuery; +import org.sonarqube.ws.client.HttpConnector; +import org.sonarqube.ws.client.HttpWsClient; import org.sonarqube.ws.client.WsClient; import static com.google.common.collect.FluentIterable.from; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.sonarqube.ws.client.HttpConnector.newHttpConnector; public class ItUtils { @@ -77,10 +78,9 @@ public class ItUtils { public static WsClient newAdminWsClient(Orchestrator orchestrator) { Server server = orchestrator.getServer(); - return new WsClient(newHttpConnector() + return new HttpWsClient(new HttpConnector.Builder() .url(server.getUrl()) - .login(server.ADMIN_LOGIN) - .password(server.ADMIN_PASSWORD) + .credentials(server.ADMIN_LOGIN, server.ADMIN_PASSWORD) .build()); } |