aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-12-19 13:26:01 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-12-19 18:20:15 +0100
commit785a3106418f3f32402e3fa0e89f2ef3ebe6b254 (patch)
tree5a267ec797ba5a58f35dc2ee5d2a8c5ade83c138 /it
parentc688ff54703b1dc3bdbc4a05f919c71b28a23aad (diff)
downloadsonarqube-785a3106418f3f32402e3fa0e89f2ef3ebe6b254.tar.gz
sonarqube-785a3106418f3f32402e3fa0e89f2ef3ebe6b254.zip
SONAR-7286 Create WS api/favorites/search
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/analysis/FavoriteTest.java16
-rw-r--r--it/it-tests/src/test/java/it/user/FavoritesWsTest.java18
2 files changed, 15 insertions, 19 deletions
diff --git a/it/it-tests/src/test/java/it/analysis/FavoriteTest.java b/it/it-tests/src/test/java/it/analysis/FavoriteTest.java
index f066888a61a..c8602a377a6 100644
--- a/it/it-tests/src/test/java/it/analysis/FavoriteTest.java
+++ b/it/it-tests/src/test/java/it/analysis/FavoriteTest.java
@@ -28,9 +28,9 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
-import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.Favorites;
+import org.sonarqube.ws.Favorites.Favorite;
import org.sonarqube.ws.WsPermissions;
-import org.sonarqube.ws.client.GetRequest;
import org.sonarqube.ws.client.WsClient;
import org.sonarqube.ws.client.permission.AddProjectCreatorToTemplateWsRequest;
import org.sonarqube.ws.client.permission.RemoveProjectCreatorFromTemplateWsRequest;
@@ -71,8 +71,8 @@ public class FavoriteTest {
orchestrator.executeBuild(sampleProject);
- String response = adminWsClient.wsConnector().call(new GetRequest("api/favourites").setMediaType(MediaTypes.JSON)).content();
- assertThat(response).contains(PROJECT_KEY);
+ Favorites.SearchResponse response = adminWsClient.favorites().search(null, null);
+ assertThat(response.getFavoritesList()).extracting(Favorite::getKey).contains(PROJECT_KEY);
}
@Test
@@ -81,8 +81,8 @@ public class FavoriteTest {
orchestrator.executeBuild(sampleProject);
- String response = adminWsClient.wsConnector().call(new GetRequest("api/favourites").setMediaType(MediaTypes.JSON)).content();
- assertThat(response).doesNotContain(PROJECT_KEY);
+ Favorites.SearchResponse response = adminWsClient.favorites().search(null, null);
+ assertThat(response.getFavoritesList()).extracting(Favorite::getKey).doesNotContain(PROJECT_KEY);
}
@Test
@@ -94,8 +94,8 @@ public class FavoriteTest {
orchestrator.executeBuild(sampleProject);
- String response = adminWsClient.wsConnector().call(new GetRequest("api/favourites").setMediaType(MediaTypes.JSON)).content();
- assertThat(response).doesNotContain(PROJECT_KEY);
+ Favorites.SearchResponse response = adminWsClient.favorites().search(null, null);
+ assertThat(response.getFavoritesList()).extracting(Favorite::getKey).doesNotContain(PROJECT_KEY);
}
private static SonarScanner createScannerWithUserCredentials() {
diff --git a/it/it-tests/src/test/java/it/user/FavoritesWsTest.java b/it/it-tests/src/test/java/it/user/FavoritesWsTest.java
index 62ec54251e8..357d1fa3bf2 100644
--- a/it/it-tests/src/test/java/it/user/FavoritesWsTest.java
+++ b/it/it-tests/src/test/java/it/user/FavoritesWsTest.java
@@ -26,9 +26,7 @@ import java.util.List;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
-import org.sonar.wsclient.Sonar;
-import org.sonar.wsclient.services.Favourite;
-import org.sonar.wsclient.services.FavouriteQuery;
+import org.sonarqube.ws.Favorites.Favorite;
import org.sonarqube.ws.client.WsClient;
import static org.assertj.core.api.Assertions.assertThat;
@@ -53,24 +51,22 @@ public class FavoritesWsTest {
@Test
public void favorites_web_service() {
- Sonar oldWsClient = orchestrator.getServer().getAdminWsClient();
-
// GET (nothing)
- List<Favourite> favourites = oldWsClient.findAll(new FavouriteQuery());
- assertThat(favourites).isEmpty();
+ List<Favorite> favorites = adminClient.favorites().search(null, null).getFavoritesList();
+ assertThat(favorites).isEmpty();
// POST (create favorites)
adminClient.favorites().add("sample");
adminClient.favorites().add("sample:src/main/xoo/sample/Sample.xoo");
// GET (created favorites)
- favourites = oldWsClient.findAll(new FavouriteQuery());
- assertThat(favourites.stream().map(Favourite::getKey)).containsOnly("sample", "sample:src/main/xoo/sample/Sample.xoo");
+ favorites = adminClient.favorites().search(null, null).getFavoritesList();
+ assertThat(favorites.stream().map(Favorite::getKey)).containsOnly("sample", "sample:src/main/xoo/sample/Sample.xoo");
// DELETE (a favorite)
adminClient.favorites().remove("sample");
- favourites = oldWsClient.findAll(new FavouriteQuery());
- assertThat(favourites.stream().map(Favourite::getKey)).containsOnly("sample:src/main/xoo/sample/Sample.xoo");
+ favorites = adminClient.favorites().search(null, null).getFavoritesList();
+ assertThat(favorites.stream().map(Favorite::getKey)).containsOnly("sample:src/main/xoo/sample/Sample.xoo");
}
}