Search in sources :

Example 1 with SearchWsRequest

use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.

the class ScannerTest method should_scan_branch_with_forward_slash.

/**
   * SONAR-3718
   */
@Test
public void should_scan_branch_with_forward_slash() {
    scan("shared/xoo-multi-modules-sample");
    scan("shared/xoo-multi-modules-sample", "sonar.branch", "branch/0.x");
    assertThat(newAdminWsClient(orchestrator).components().search(new SearchWsRequest().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");
}
Also used : SearchWsRequest(org.sonarqube.ws.client.component.SearchWsRequest) Test(org.junit.Test)

Example 2 with SearchWsRequest

use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.

the class SearchActionTest method search_with_language.

@Test
public void search_with_language() throws IOException {
    OrganizationDto organizationDto = db.organizations().insert();
    insertProjectsAuthorizedForUser(newProjectDto(organizationDto).setKey("java-project").setLanguage("java"), newProjectDto(organizationDto).setKey("cpp-project").setLanguage("cpp"));
    SearchWsResponse response = call(new SearchWsRequest().setOrganization(organizationDto.getKey()).setLanguage("java").setQualifiers(singletonList(PROJECT)));
    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("java-project");
}
Also used : SearchWsRequest(org.sonarqube.ws.client.component.SearchWsRequest) SearchWsResponse(org.sonarqube.ws.WsComponents.SearchWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 3 with SearchWsRequest

use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.

the class SearchActionTest method search_for_files.

@Test
public void search_for_files() throws IOException {
    ComponentDto project = newProjectDto(db.getDefaultOrganization());
    ComponentDto file1 = newFileDto(project).setKey("file1");
    ComponentDto file2 = newFileDto(project).setKey("file2");
    db.components().insertComponents(project, file1, file2);
    setBrowsePermissionOnUser(project);
    SearchWsResponse response = call(new SearchWsRequest().setQuery(file1.key()).setQualifiers(singletonList(FILE)));
    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey());
}
Also used : SearchWsRequest(org.sonarqube.ws.client.component.SearchWsRequest) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.WsComponents.SearchWsResponse) Test(org.junit.Test)

Example 4 with SearchWsRequest

use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.

the class SearchActionTest method fail_when_no_qualifier_provided.

@Test
public void fail_when_no_qualifier_provided() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("The 'qualifiers' parameter is missing");
    call(new SearchWsRequest());
}
Also used : SearchWsRequest(org.sonarqube.ws.client.component.SearchWsRequest) Test(org.junit.Test)

Example 5 with SearchWsRequest

use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.

the class SearchActionTest method do_not_verify_permissions_if_user_is_root.

@Test
public void do_not_verify_permissions_if_user_is_root() throws IOException {
    OrganizationDto org = db.organizations().insert();
    ComponentDto project1 = newProjectDto(org);
    ComponentDto file1 = newFileDto(project1);
    ComponentDto project2 = newProjectDto(org);
    ComponentDto file2 = newFileDto(project2);
    db.components().insertComponents(project1, file1, project2, file2);
    SearchWsRequest request = new SearchWsRequest().setQualifiers(singletonList(FILE)).setOrganization(org.getKey());
    userSession.logIn().setNonRoot();
    assertThat(call(request).getComponentsCount()).isZero();
    userSession.logIn().setRoot();
    assertThat(call(request).getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey(), file2.getKey());
}
Also used : SearchWsRequest(org.sonarqube.ws.client.component.SearchWsRequest) ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 SearchWsRequest (org.sonarqube.ws.client.component.SearchWsRequest)8 SearchWsResponse (org.sonarqube.ws.WsComponents.SearchWsResponse)5 ComponentDto (org.sonar.db.component.ComponentDto)4 OrganizationDto (org.sonar.db.organization.OrganizationDto)3 ArrayList (java.util.ArrayList)1