Search in sources :

Example 1 with Favorite

use of org.sonarqube.ws.Favorites.Favorite 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)

Aggregations

Test (org.junit.Test)1 Favorite (org.sonarqube.ws.Favorites.Favorite)1 SearchRequest (org.sonarqube.ws.client.favorite.SearchRequest)1