From: Sébastien Lesaint Date: Tue, 31 Jan 2017 08:41:49 +0000 (+0100) Subject: fix OrganizationIt X-Git-Tag: 6.3-RC1~322 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3c9ec8364571e24b3031a756d19993c03fb9a846;p=sonarqube.git fix OrganizationIt --- diff --git a/it/it-tests/src/test/java/it/organization/OrganizationIt.java b/it/it-tests/src/test/java/it/organization/OrganizationIt.java index e950f73cbca..327c9f2499e 100644 --- a/it/it-tests/src/test/java/it/organization/OrganizationIt.java +++ b/it/it-tests/src/test/java/it/organization/OrganizationIt.java @@ -265,23 +265,26 @@ public class OrganizationIt { .contains("grp1", "grp2"); ItUtils.runProjectAnalysis(orchestrator, "shared/xoo-sample", - "sonar.organization", orgKeyAndName); + "sonar.organization", orgKeyAndName); ComponentsService componentsService = ItUtils.newAdminWsClient(orchestrator).components(); - assertThat(searchSampleProject(componentsService).getComponentsList()).hasSize(1); + assertThat(searchSampleProject(orgKeyAndName, componentsService).getComponentsList()).hasSize(1); adminOrganizationService.delete(orgKeyAndName); - assertThat(searchSampleProject(componentsService).getComponentsList()).hasSize(0); + expect404HttpError(() -> searchSampleProject(orgKeyAndName, componentsService)); assertThat(groupManagement.getUserGroups("bob").getGroups()) - .extracting(Groups.Group::getName) - .doesNotContain("grp1", "grp2"); + .extracting(Groups.Group::getName) + .doesNotContain("grp1", "grp2"); verifyNoExtraOrganization(); } - private WsComponents.SearchWsResponse searchSampleProject(ComponentsService componentsService) { + private WsComponents.SearchWsResponse searchSampleProject(String organizationKey, ComponentsService componentsService) { return componentsService - .search(new org.sonarqube.ws.client.component.SearchWsRequest().setQualifiers(singletonList("TRK")).setQuery("sample")); + .search(new org.sonarqube.ws.client.component.SearchWsRequest() + .setOrganization(organizationKey) + .setQualifiers(singletonList("TRK")) + .setQuery("sample")); } private void expect403HttpError(Runnable runnable) { @@ -293,6 +296,15 @@ public class OrganizationIt { } } + private void expect404HttpError(Runnable runnable) { + try { + runnable.run(); + fail("Ws call should have failed"); + } catch (HttpException e) { + assertThat(e.code()).isEqualTo(404); + } + } + private void verifyNoExtraOrganization() { Organizations.SearchWsResponse searchWsResponse = anonymousOrganizationService.search(new SearchWsRequest.Builder().build()); List organizationsList = searchWsResponse.getOrganizationsList(); @@ -302,7 +314,8 @@ public class OrganizationIt { private void verifySingleSearchResult(Organizations.Organization createdOrganization, String name, String description, String url, String avatarUrl) { - List organizations = anonymousOrganizationService.search(new SearchWsRequest.Builder().build()).getOrganizationsList(); + List organizations = anonymousOrganizationService.search(new SearchWsRequest.Builder() + .build()).getOrganizationsList(); assertThat(organizations).hasSize(2); Organizations.Organization searchedOrganization = organizations.stream() .filter(organization -> !DEFAULT_ORGANIZATION_KEY.equals(organization.getKey())) diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java index bd555b39a44..64bf9753360 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/component/ComponentsService.java @@ -58,6 +58,7 @@ public class ComponentsService extends BaseService { public SearchWsResponse search(SearchWsRequest request) { GetRequest get = new GetRequest(path(ACTION_SEARCH)) + .setParam(PARAM_ORGANIZATION, request.getOrganization()) .setParam(PARAM_QUALIFIERS, Joiner.on(",").join(request.getQualifiers())) .setParam(Param.PAGE, request.getPage()) .setParam(Param.PAGE_SIZE, request.getPageSize())