aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-11-30 15:14:04 +0100
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-12-06 14:40:17 +0100
commit6840bca918854ebfc8b16cbd07071aa1b6672313 (patch)
tree3ebba1d712e4e0e223bf02769cc809dbdda6ce1f /tests
parentc84c9ce7619fc312374583ccd8510024a5b1c75c (diff)
downloadsonarqube-6840bca918854ebfc8b16cbd07071aa1b6672313.tar.gz
sonarqube-6840bca918854ebfc8b16cbd07071aa1b6672313.zip
Remove legacy sonar-ws code for organizations
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java3
-rw-r--r--tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java11
-rw-r--r--tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java5
-rw-r--r--tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java63
-rw-r--r--tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java4
-rw-r--r--tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java3
-rw-r--r--tests/src/test/java/org/sonarqube/tests/user/OrganizationIdentityProviderTest.java3
7 files changed, 46 insertions, 46 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java
index 571b44399bb..7b655eecb99 100644
--- a/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueTagsTest.java
@@ -34,6 +34,7 @@ import org.sonarqube.ws.Organizations.Organization;
import org.sonarqube.ws.Projects.CreateWsResponse;
import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.issue.SearchRequest;
+import org.sonarqube.ws.client.organizations.AddMemberRequest;
import org.sonarqube.ws.client.permission.AddUserRequest;
import org.sonarqube.ws.client.project.CreateRequest;
import util.ItUtils;
@@ -127,7 +128,7 @@ public class IssueTagsTest {
}
private void addMemberToOrganization(User member) {
- tester.organizations().service().addMember(organization.getKey(), member.getLogin());
+ tester.organizations().service().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(member.getLogin()));
}
private void grantUserPermission(String projectKey, User member) {
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
index 78498fa03a5..0304a639f53 100644
--- a/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/organization/BillingTest.java
@@ -34,7 +34,7 @@ import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsResponse;
import org.sonarqube.ws.client.ce.TaskRequest;
-import org.sonarqube.ws.client.organization.UpdateProjectVisibilityRequest;
+import org.sonarqube.ws.client.organizations.UpdateProjectVisibilityRequest;
import org.sonarqube.ws.client.project.CreateRequest;
import org.sonarqube.ws.client.project.UpdateVisibilityRequest;
import util.ItUtils;
@@ -127,10 +127,9 @@ public class BillingTest {
public void does_not_fail_to_update_default_projects_visibility_to_private() {
tester.settings().setGlobalSettings("sonar.billing.preventUpdatingProjectsVisibilityToPrivate", "false");
- tester.wsClient().organizationsOld().updateProjectVisibility(UpdateProjectVisibilityRequest.builder()
+ tester.wsClient().organizations().updateProjectVisibility(new UpdateProjectVisibilityRequest()
.setOrganization(organization.getKey())
- .setProjectVisibility("private")
- .build());
+ .setProjectVisibility("private"));
assertWsResponseAsAdmin(new GetRequest("api/navigation/organization").setParam("organization", organization.getKey()),
"\"projectVisibility\":\"private\"");
@@ -142,8 +141,8 @@ public class BillingTest {
expectHttpError(400,
format("Organization %s cannot use private project", organization.getKey()),
- () -> tester.wsClient().organizationsOld()
- .updateProjectVisibility(UpdateProjectVisibilityRequest.builder().setOrganization(organization.getKey()).setProjectVisibility("private").build()));
+ () -> tester.wsClient().organizations()
+ .updateProjectVisibility(new UpdateProjectVisibilityRequest().setOrganization(organization.getKey()).setProjectVisibility("private")));
}
@Test
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java
index 2fcb812f7bf..18c4d6c3372 100644
--- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipTest.java
@@ -31,6 +31,7 @@ import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Organizations.Organization;
import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.HttpException;
+import org.sonarqube.ws.client.organizations.RemoveMemberRequest;
import org.sonarqube.ws.client.permission.AddUserRequest;
public class OrganizationMembershipTest {
@@ -94,7 +95,7 @@ public class OrganizationMembershipTest {
tester.wsClient().permissionsOld().addUser(new AddUserRequest().setLogin(user.getLogin()).setPermission("admin").setOrganization(organization.getKey()));
tester.organizations().assertThatMemberOf(organization, user);
// Admin is the creator of the organization so he was granted with admin permission
- tester.wsClient().organizationsOld().removeMember(organization.getKey(), "admin");
+ tester.wsClient().organizations().removeMember(new RemoveMemberRequest().setOrganization(organization.getKey()).setLogin("admin"));
expectedException.expect(HttpException.class);
expectedException.expectMessage("The last administrator member cannot be removed");
@@ -125,6 +126,6 @@ public class OrganizationMembershipTest {
}
private void removeMembership(Organization organization, User user) {
- tester.wsClient().organizationsOld().removeMember(organization.getKey(), user.getLogin());
+ tester.wsClient().organizations().removeMember(new RemoveMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin()));
}
}
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 462e4b2f1ee..5b72379ff63 100644
--- a/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java
@@ -37,10 +37,12 @@ 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.organization.CreateRequest;
-import org.sonarqube.ws.client.organization.OrganizationService;
-import org.sonarqube.ws.client.organization.SearchRequest;
-import org.sonarqube.ws.client.organization.UpdateRequest;
+import org.sonarqube.ws.client.organizations.AddMemberRequest;
+import org.sonarqube.ws.client.organizations.CreateRequest;
+import org.sonarqube.ws.client.organizations.DeleteRequest;
+import org.sonarqube.ws.client.organizations.OrganizationsService;
+import org.sonarqube.ws.client.organizations.SearchRequest;
+import org.sonarqube.ws.client.organizations.UpdateRequest;
import org.sonarqube.ws.client.permission.AddUserRequest;
import org.sonarqube.ws.client.permission.PermissionsService;
import org.sonarqube.ws.client.roots.SetRootRequest;
@@ -77,7 +79,7 @@ public class OrganizationTest {
@Test
public void default_organization_should_exist() {
- Organization defaultOrg = tester.organizations().service().search(SearchRequest.builder().build())
+ Organization defaultOrg = tester.organizations().service().search(new SearchRequest())
.getOrganizationsList()
.stream()
.filter(Organization::getGuarded)
@@ -89,19 +91,18 @@ public class OrganizationTest {
@Test
public void default_organization_can_not_be_deleted() {
- expectBadRequestError(() -> tester.organizations().service().delete(DEFAULT_ORGANIZATION_KEY));
+ expectBadRequestError(() -> tester.organizations().service().delete(new DeleteRequest().setOrganization(DEFAULT_ORGANIZATION_KEY)));
}
@Test
public void create_update_and_delete_organizations() {
- OrganizationService service = tester.organizations().service();
+ OrganizationsService service = tester.organizations().service();
Organization org = tester.organizations().generate(o -> o
.setName(NAME)
.setDescription(DESCRIPTION)
.setUrl(URL)
- .setAvatar(AVATAR_URL)
- .build());
+ .setAvatar(AVATAR_URL));
assertThat(org.getName()).isEqualTo(NAME);
assertThat(org.getDescription()).isEqualTo(DESCRIPTION);
assertThat(org.getUrl()).isEqualTo(URL);
@@ -111,35 +112,32 @@ public class OrganizationTest {
assertThatBuiltInQualityProfilesExist(org);
// update by key
- service.update(new UpdateRequest.Builder()
+ service.update(new UpdateRequest()
.setKey(org.getKey())
.setName("new name")
.setDescription("new description")
.setUrl("new url")
- .setAvatar("new avatar url")
- .build());
+ .setAvatar("new avatar url"));
verifyOrganization(org, "new name", "new description", "new url", "new avatar url");
// remove optional fields
- service.update(new UpdateRequest.Builder()
+ service.update(new UpdateRequest()
.setKey(org.getKey())
.setName("new name 2")
.setDescription("")
.setUrl("")
- .setAvatar("")
- .build());
+ .setAvatar(""));
verifyOrganization(org, "new name 2", null, null, null);
// delete organization
- service.delete(org.getKey());
+ service.delete(new DeleteRequest().setOrganization(org.getKey()));
assertThatOrganizationDoesNotExit(org);
assertThatQualityProfilesDoNotExist(org);
// create again
- service.create(new CreateRequest.Builder()
+ service.create(new CreateRequest()
.setName(NAME)
- .setKey(org.getKey())
- .build())
+ .setKey(org.getKey()))
.getOrganization();
verifyOrganization(org, NAME, null, null, null);
}
@@ -149,9 +147,8 @@ public class OrganizationTest {
// create organization without key
String name = "Foo Company to keyize";
String expectedKey = "foo-company-to-keyize";
- Organization createdOrganization = tester.organizations().service().create(new CreateRequest.Builder()
- .setName(name)
- .build())
+ Organization createdOrganization = tester.organizations().service().create(new CreateRequest()
+ .setName(name))
.getOrganization();
assertThat(createdOrganization.getKey()).isEqualTo(expectedKey);
verifyOrganization(createdOrganization, name, null, null, null);
@@ -163,8 +160,8 @@ public class OrganizationTest {
OrganizationTester anonymousTester = tester.asAnonymous().organizations();
expectForbiddenError(() -> anonymousTester.generate());
- expectUnauthorizedError(() -> anonymousTester.service().update(new UpdateRequest.Builder().setKey(org.getKey()).setName("new name").build()));
- expectUnauthorizedError(() -> anonymousTester.service().delete(org.getKey()));
+ expectUnauthorizedError(() -> anonymousTester.service().update(new UpdateRequest().setKey(org.getKey()).setName("new name")));
+ expectUnauthorizedError(() -> anonymousTester.service().delete(new DeleteRequest().setOrganization(org.getKey())));
}
@Test
@@ -174,8 +171,8 @@ public class OrganizationTest {
OrganizationTester userTester = tester.as(user.getLogin()).organizations();
expectForbiddenError(() -> userTester.generate());
- expectForbiddenError(() -> userTester.service().update(new UpdateRequest.Builder().setKey(org.getKey()).setName("new name").build()));
- expectForbiddenError(() -> userTester.service().delete(org.getKey()));
+ expectForbiddenError(() -> userTester.service().update(new UpdateRequest().setKey(org.getKey()).setName("new name")));
+ expectForbiddenError(() -> userTester.service().delete(new DeleteRequest().setOrganization(org.getKey())));
}
@Test
@@ -187,7 +184,7 @@ public class OrganizationTest {
Organization org = asUser.generate();
// delete org, attempt recreate when no root anymore and ensure it can't anymore
- asUser.service().delete(org.getKey());
+ asUser.service().delete(new DeleteRequest().setOrganization(org.getKey()));
tester.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user.getLogin()));
expectForbiddenError(() -> asUser.generate());
@@ -199,7 +196,7 @@ public class OrganizationTest {
User user = tester.users().generate();
Group group = tester.groups().generate(organization);
// users.removeGroups("sonar-users");
- tester.organizations().service().addMember(organization.getKey(), user.getLogin());
+ tester.organizations().service().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin()));
addPermissionsToUser(organization.getKey(), user.getLogin(), "provisioning", "scan");
runProjectAnalysis(orchestrator, "shared/xoo-sample",
@@ -255,7 +252,7 @@ public class OrganizationTest {
ComponentsService componentsService = tester.wsClient().componentsOld();
assertThat(searchSampleProject(organization.getKey(), componentsService).getComponentsList()).hasSize(1);
- tester.organizations().service().delete(organization.getKey());
+ tester.organizations().service().delete(new DeleteRequest().setOrganization(organization.getKey()));
expectNotFoundError(() -> searchSampleProject(organization.getKey(), componentsService));
assertThatOrganizationDoesNotExit(organization);
@@ -265,7 +262,7 @@ public class OrganizationTest {
public void return_groups_belonging_to_a_user_on_an_organization() throws Exception {
Organization organization = tester.organizations().generate();
User user = tester.users().generate();
- tester.organizations().service().addMember(organization.getKey(), user.getLogin());
+ tester.organizations().service().addMember(new AddMemberRequest().setOrganization(organization.getKey()).setLogin(user.getLogin()));
Group group = tester.groups().generate(organization);
tester.groups().addMemberToGroups(organization, user.getLogin(), group.getName());
@@ -294,7 +291,7 @@ public class OrganizationTest {
assertThat(organization.getKey()).isNotEmpty();
assertThat(organization.getGuarded()).isFalse();
- List<Organization> reloadedOrgs = tester.organizations().service().search(SearchRequest.builder().build()).getOrganizationsList();
+ List<Organization> reloadedOrgs = tester.organizations().service().search(new SearchRequest()).getOrganizationsList();
assertThat(reloadedOrgs)
.filteredOn(o -> o.getKey().equals(organization.getKey()))
.hasSize(1);
@@ -309,13 +306,13 @@ public class OrganizationTest {
}
private void assertThatOrganizationDoesNotExit(Organization org) {
- SearchRequest request = new SearchRequest.Builder().setOrganizations(org.getKey()).build();
+ SearchRequest request = new SearchRequest().setOrganizations(singletonList(org.getKey()));
assertThat(tester.organizations().service().search(request).getOrganizationsList()).isEmpty();
}
private void verifyOrganization(Organization createdOrganization, String name, String description, String url,
String avatarUrl) {
- SearchRequest request = new SearchRequest.Builder().setOrganizations(createdOrganization.getKey()).build();
+ SearchRequest request = new SearchRequest().setOrganizations(singletonList(createdOrganization.getKey()));
List<Organization> result = tester.organizations().service().search(request).getOrganizationsList();
assertThat(result).hasSize(1);
Organization searchedOrganization = result.get(0);
diff --git a/tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java b/tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java
index aeaf297a844..c6802d79c12 100644
--- a/tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/organization/PersonalOrganizationTest.java
@@ -29,7 +29,7 @@ import org.junit.Test;
import org.sonarqube.qa.util.Tester;
import org.sonarqube.ws.Organizations;
import org.sonarqube.ws.Users;
-import org.sonarqube.ws.client.organization.SearchRequest;
+import org.sonarqube.ws.client.organizations.SearchRequest;
import static org.assertj.core.api.Assertions.assertThat;
@@ -52,7 +52,7 @@ public class PersonalOrganizationTest {
public void personal_organizations_are_created_for_new_users() {
Users.CreateWsResponse.User user = tester.users().generate();
- List<Organizations.Organization> existing = tester.wsClient().organizationsOld().search(SearchRequest.builder().build()).getOrganizationsList();
+ List<Organizations.Organization> existing = tester.wsClient().organizations().search(new SearchRequest()).getOrganizationsList();
assertThat(existing)
.filteredOn(Organizations.Organization::getGuarded)
.filteredOn(o -> o.getKey().equals(user.getLogin()))
diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java
index ef5199d1b64..c3866bb6c0f 100644
--- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/CustomQualityProfilesTest.java
@@ -37,6 +37,7 @@ import org.sonarqube.ws.Qualityprofiles.CreateWsResponse.QualityProfile;
import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.organizations.DeleteRequest;
import org.sonarqube.ws.client.qualityprofile.AddProjectRequest;
import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest;
import org.sonarqube.ws.client.qualityprofile.CopyRequest;
@@ -152,7 +153,7 @@ public class CustomQualityProfilesTest {
adminSession.service().changeParent(
ChangeParentRequest.builder().setParentKey(builtInProfile.getKey()).setProfileKey(inheritedProfile2.getKey()).build());
- tester.organizations().service().delete(org.getKey());
+ tester.organizations().service().delete(new DeleteRequest().setOrganization(org.getKey()));
expectMissingError(() -> tester.qProfiles().service().search(new SearchRequest()
.setOrganizationKey(org.getKey())));
diff --git a/tests/src/test/java/org/sonarqube/tests/user/OrganizationIdentityProviderTest.java b/tests/src/test/java/org/sonarqube/tests/user/OrganizationIdentityProviderTest.java
index 0fdfabbdaed..8c3b52cbeb2 100644
--- a/tests/src/test/java/org/sonarqube/tests/user/OrganizationIdentityProviderTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/user/OrganizationIdentityProviderTest.java
@@ -31,6 +31,7 @@ import org.sonarqube.tests.Category6Suite;
import org.sonarqube.ws.UserGroups.Group;
import org.sonarqube.ws.Users.CreateWsResponse.User;
import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.organizations.AddMemberRequest;
public class OrganizationIdentityProviderTest {
@@ -83,7 +84,7 @@ public class OrganizationIdentityProviderTest {
Group group = tester.groups().generate(null);
User user = tester.users().generate();
// Add user as member of default organization
- tester.wsClient().organizationsOld().addMember("default-organization", user.getLogin());
+ tester.wsClient().organizations().addMember(new AddMemberRequest().setOrganization("default-organization").setLogin(user.getLogin()));
tester.groups().assertThatUserIsMemberOf(null, user.getLogin(), "Members");
enableUserCreationByAuthPlugin(user.getLogin());
// No group is returned by the plugin