use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.
the class SearchActionTest method search_by_key_query.
@Test
public void search_by_key_query() throws IOException {
insertProjectsAuthorizedForUser(newProjectDto(db.getDefaultOrganization()).setKey("project-_%-key"), newProjectDto(db.getDefaultOrganization()).setKey("project-key-without-escaped-characters"));
SearchWsResponse response = call(new SearchWsRequest().setQuery("project-_%-key").setQualifiers(singletonList(PROJECT)));
assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("project-_%-key");
}
use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.
the class SearchActionTest method search_with_pagination.
@Test
public void search_with_pagination() throws IOException {
OrganizationDto organizationDto = db.organizations().insert();
List<ComponentDto> componentDtoList = new ArrayList<>();
for (int i = 1; i <= 9; i++) {
componentDtoList.add(newProjectDto(organizationDto, "project-uuid-" + i).setKey("project-key-" + i).setName("Project Name " + i));
}
insertProjectsAuthorizedForUser(componentDtoList.toArray(new ComponentDto[] {}));
SearchWsResponse response = call(new SearchWsRequest().setOrganization(organizationDto.getKey()).setPage(2).setPageSize(3).setQualifiers(singletonList(PROJECT)));
assertThat(response.getComponentsList()).extracting(Component::getKey).containsExactly("project-key-4", "project-key-5", "project-key-6");
}
use of org.sonarqube.ws.client.component.SearchWsRequest in project sonarqube by SonarSource.
the class SearchActionTest method return_only_components_from_projects_on_which_user_has_browse_permission.
@Test
public void return_only_components_from_projects_on_which_user_has_browse_permission() throws IOException {
ComponentDto project1 = newProjectDto(db.getDefaultOrganization());
ComponentDto file1 = newFileDto(project1).setKey("file1");
ComponentDto file2 = newFileDto(project1).setKey("file2");
ComponentDto project2 = newProjectDto(db.getDefaultOrganization());
ComponentDto file3 = newFileDto(project2).setKey("file3");
db.components().insertComponents(project1, file1, file2, project2, file3);
setBrowsePermissionOnUser(project1);
SearchWsResponse response = call(new SearchWsRequest().setQualifiers(singletonList(FILE)));
assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(file1.getKey(), file2.getKey());
}
Aggregations