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);
}
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);
}
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);
}
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");
}
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);
}
Aggregations