aboutsummaryrefslogtreecommitdiffstats
path: root/it/it-tests
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-26 18:20:57 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-31 13:53:44 +0100
commit934bf664b8e032c76c9e64e28ddb3ee46d7adbc3 (patch)
tree9b4c907167c91936a7b214b49d284c6f35945b23 /it/it-tests
parent346e8661756f15aa105a585b1d8a05fe326e1244 (diff)
downloadsonarqube-934bf664b8e032c76c9e64e28ddb3ee46d7adbc3.tar.gz
sonarqube-934bf664b8e032c76c9e64e28ddb3ee46d7adbc3.zip
SONAR-8704 Refactor Elasticsearch types "authorization"
Multiple indices define a type "authorization". The related code was duplicated, and sometimes had some minor differences. This commits share all the management of these types in the same bunch of classes. It also allows to quickly create a project-related index, without having to fix the different locations which may require project re-indexing.
Diffstat (limited to 'it/it-tests')
-rw-r--r--it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java b/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java
index 7790ae1589e..9b969f78e6f 100644
--- a/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java
+++ b/it/it-tests/src/test/java/it/projectSearch/SearchProjectsTest.java
@@ -35,6 +35,9 @@ import static org.assertj.core.api.Java6Assertions.assertThat;
import static util.ItUtils.newAdminWsClient;
import static util.ItUtils.projectDir;
+/**
+ * Tests WS api/components/search_projects
+ */
public class SearchProjectsTest {
@ClassRule
@@ -46,16 +49,16 @@ public class SearchProjectsTest {
}
@Test
- public void search_projects_with_filter_having_one_criterion() throws Exception {
+ public void filter_projects_by_measure_values() throws Exception {
orchestrator.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")));
- SearchProjectsWsResponse response = searchProjects("ncloc > 1");
-
- assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("sample");
+ verifyFilterMatches("ncloc > 1");
+ verifyFilterMatches("ncloc > 1 and comment_lines < 10000");
+ verifyFilterDoesNotMatch("ncloc <= 1");
}
@Test
- public void return_project_even_without_analysis() throws Exception {
+ public void provisioned_projects_should_be_included_to_results() throws Exception {
orchestrator.getServer().provisionProject("sample", "sample");
SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().build());
@@ -63,6 +66,7 @@ public class SearchProjectsTest {
assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly("sample");
}
+
private SearchProjectsWsResponse searchProjects(String filter) throws IOException {
return searchProjects(SearchProjectsRequest.builder().setFilter(filter).build());
}
@@ -70,4 +74,12 @@ public class SearchProjectsTest {
private SearchProjectsWsResponse searchProjects(SearchProjectsRequest request) throws IOException {
return newAdminWsClient(orchestrator).components().searchProjects(request);
}
+
+ private void verifyFilterMatches(String filter) throws IOException {
+ assertThat(searchProjects(filter).getComponentsList()).extracting(Component::getKey).containsOnly("sample");
+ }
+
+ private void verifyFilterDoesNotMatch(String filter) throws IOException {
+ assertThat(searchProjects(filter).getComponentsCount()).isZero();
+ }
}