Search in sources :

Example 1 with SearchRequest

use of org.sonarqube.ws.client.favorite.SearchRequest in project sonarqube by SonarSource.

the class FavoriteTest method project_as_favorite_when_authenticated_and_first_analysis_and_a_project_creator_permission.

@Test
public void project_as_favorite_when_authenticated_and_first_analysis_and_a_project_creator_permission() {
    SonarScanner sampleProject = createScannerWithUserCredentials();
    addProjectCreatorPermission();
    orchestrator.executeBuild(sampleProject);
    Favorites.SearchResponse response = adminWsClient.favorites().search(new SearchRequest());
    assertThat(response.getFavoritesList()).extracting(Favorite::getKey).contains(PROJECT_KEY);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Favorites(org.sonarqube.ws.Favorites) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 2 with SearchRequest

use of org.sonarqube.ws.client.favorite.SearchRequest in project sonarqube by SonarSource.

the class FavoriteTest method no_project_as_favorite_when_no_project_creator_permission.

@Test
public void no_project_as_favorite_when_no_project_creator_permission() {
    SonarScanner sampleProject = createScannerWithUserCredentials();
    orchestrator.executeBuild(sampleProject);
    Favorites.SearchResponse response = adminWsClient.favorites().search(new SearchRequest());
    assertThat(response.getFavoritesList()).extracting(Favorite::getKey).doesNotContain(PROJECT_KEY);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Favorites(org.sonarqube.ws.Favorites) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 3 with SearchRequest

use of org.sonarqube.ws.client.favorite.SearchRequest in project sonarqube by SonarSource.

the class FavoriteTest method no_project_as_favorite_when_second_analysis.

@Test
public void no_project_as_favorite_when_second_analysis() {
    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
    orchestrator.executeBuild(sampleProject);
    sampleProject = createScannerWithUserCredentials();
    addProjectCreatorPermission();
    orchestrator.executeBuild(sampleProject);
    Favorites.SearchResponse response = adminWsClient.favorites().search(new SearchRequest());
    assertThat(response.getFavoritesList()).extracting(Favorite::getKey).doesNotContain(PROJECT_KEY);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Favorites(org.sonarqube.ws.Favorites) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 4 with SearchRequest

use of org.sonarqube.ws.client.favorite.SearchRequest in project sonarqube by SonarSource.

the class FavoritesWsTest method favorites_web_service.

@Test
public void favorites_web_service() {
    // GET (nothing)
    List<Favorite> favorites = adminClient.favorites().search(new SearchRequest()).getFavoritesList();
    assertThat(favorites).isEmpty();
    // POST (create favorites)
    adminClient.favorites().add("sample");
    adminClient.favorites().add("sample:src/main/xoo/sample/Sample.xoo");
    // GET (created favorites)
    favorites = adminClient.favorites().search(new SearchRequest()).getFavoritesList();
    assertThat(favorites.stream().map(Favorite::getKey)).containsOnly("sample", "sample:src/main/xoo/sample/Sample.xoo");
    // DELETE (a favorite)
    adminClient.favorites().remove("sample");
    favorites = adminClient.favorites().search(new SearchRequest()).getFavoritesList();
    assertThat(favorites.stream().map(Favorite::getKey)).containsOnly("sample:src/main/xoo/sample/Sample.xoo");
}
Also used : Favorite(org.sonarqube.ws.Favorites.Favorite) SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Test(org.junit.Test)

Example 5 with SearchRequest

use of org.sonarqube.ws.client.favorite.SearchRequest in project sonarqube by SonarSource.

the class SearchAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    SearchRequest searchRequest = toWsRequest(request);
    SearchResults searchResults = toSearchResults(searchRequest);
    SearchResponse wsResponse = toSearchResponse(searchResults);
    writeProtobuf(wsResponse, request, response);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) SearchResponse(org.sonarqube.ws.Favorites.SearchResponse)

Aggregations

SearchRequest (org.sonarqube.ws.client.favorite.SearchRequest)5 Test (org.junit.Test)4 SonarScanner (com.sonar.orchestrator.build.SonarScanner)3 Favorites (org.sonarqube.ws.Favorites)3 Favorite (org.sonarqube.ws.Favorites.Favorite)1 SearchResponse (org.sonarqube.ws.Favorites.SearchResponse)1