aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-data-test/src/test/java/org/sonar/data/issues/IssuesIndexInjectionTest.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java30
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java43
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java49
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java24
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderText.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderText.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java17
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderText.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java17
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java17
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java21
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java17
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java17
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java33
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java46
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java19
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java18
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java19
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/no_issue.json4
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_file_uuid.json12
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_project_uuid.json13
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/sort_by_updated_at.json25
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java10
29 files changed, 503 insertions, 46 deletions
diff --git a/server/sonar-data-test/src/test/java/org/sonar/data/issues/IssuesIndexInjectionTest.java b/server/sonar-data-test/src/test/java/org/sonar/data/issues/IssuesIndexInjectionTest.java
index 5b8904fb227..ea9b96fe89a 100644
--- a/server/sonar-data-test/src/test/java/org/sonar/data/issues/IssuesIndexInjectionTest.java
+++ b/server/sonar-data-test/src/test/java/org/sonar/data/issues/IssuesIndexInjectionTest.java
@@ -100,7 +100,7 @@ public class IssuesIndexInjectionTest extends AbstractTest {
assertThat(issueIndex.countAll()).isEqualTo(ISSUE_COUNT);
long time = stop - start;
- LOGGER.info("Processed {} Issues in {} ms with avg {} Issue/second", ISSUE_COUNT, time, documentPerSecond(time));
+ LOGGER.info("Inserted {} Issues in {} ms with avg {} Issue/second", ISSUE_COUNT, time, documentPerSecond(time));
assertDurationAround(time, Long.parseLong(getProperty("IssuesIndexInjectionTest.inject_issues")));
} finally {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
index 7d1c5067b73..e7c40e541a5 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
@@ -293,17 +293,7 @@ public class SearchAction extends SearchRequestHandler<IssueQuery, Issue> {
}
}
- collectFacetKeys(result, IssueFilterParameters.PROJECT_UUIDS, projectUuids);
- collectParameterValues(request, IssueFilterParameters.PROJECT_UUIDS, projectUuids);
- collectFacetKeys(result, IssueFilterParameters.COMPONENT_UUIDS, componentUuids);
- collectParameterValues(request, IssueFilterParameters.COMPONENT_UUIDS, componentUuids);
- collectParameterValues(request, IssueFilterParameters.COMPONENT_ROOT_UUIDS, componentUuids);
- collectFacetKeys(result, IssueFilterParameters.ASSIGNEES, userLogins);
- collectParameterValues(request, IssueFilterParameters.ASSIGNEES, userLogins);
- collectFacetKeys(result, IssueFilterParameters.REPORTERS, userLogins);
- collectParameterValues(request, IssueFilterParameters.REPORTERS, userLogins);
- collectFacetKeys(result, IssueFilterParameters.ACTION_PLANS, actionPlanKeys);
- collectParameterValues(request, IssueFilterParameters.ACTION_PLANS, actionPlanKeys);
+ collectFacetsData(request, result, projectUuids, componentUuids, userLogins, actionPlanKeys);
UserSession userSession = UserSession.get();
if (userSession.isLoggedIn()) {
@@ -323,7 +313,6 @@ public class SearchAction extends SearchRequestHandler<IssueQuery, Issue> {
List<ComponentDto> subProjectDtos = dbClient.componentDao().findSubProjectsByComponentUuids(session, componentUuids);
componentDtos.addAll(fileDtos);
componentDtos.addAll(subProjectDtos);
-
for (ComponentDto component: componentDtos) {
projectUuids.add(component.projectUuid());
}
@@ -333,7 +322,6 @@ public class SearchAction extends SearchRequestHandler<IssueQuery, Issue> {
for (ComponentDto componentDto : componentDtos) {
componentsByUuid.put(componentDto.uuid(), componentDto);
}
-
projectsByComponentUuid = getProjectsByComponentUuid(componentDtos, projectDtos);
writeProjects(json, projectDtos);
@@ -404,6 +392,20 @@ public class SearchAction extends SearchRequestHandler<IssueQuery, Issue> {
}
}
+ private void collectFacetsData(Request request, Result<Issue> result, Set<String> projectUuids, Set<String> componentUuids, List<String> userLogins, Set<String> actionPlanKeys){
+ collectFacetKeys(result, IssueFilterParameters.PROJECT_UUIDS, projectUuids);
+ collectParameterValues(request, IssueFilterParameters.PROJECT_UUIDS, projectUuids);
+ collectFacetKeys(result, IssueFilterParameters.COMPONENT_UUIDS, componentUuids);
+ collectParameterValues(request, IssueFilterParameters.COMPONENT_UUIDS, componentUuids);
+ collectParameterValues(request, IssueFilterParameters.COMPONENT_ROOT_UUIDS, componentUuids);
+ collectFacetKeys(result, IssueFilterParameters.ASSIGNEES, userLogins);
+ collectParameterValues(request, IssueFilterParameters.ASSIGNEES, userLogins);
+ collectFacetKeys(result, IssueFilterParameters.REPORTERS, userLogins);
+ collectParameterValues(request, IssueFilterParameters.REPORTERS, userLogins);
+ collectFacetKeys(result, IssueFilterParameters.ACTION_PLANS, actionPlanKeys);
+ collectParameterValues(request, IssueFilterParameters.ACTION_PLANS, actionPlanKeys);
+ }
+
private void collectFacetKeys(Result<Issue> result, String facetName, Collection<String> facetKeys) {
Collection<FacetValue> facetValues = result.getFacetValues(facetName);
if (facetValues != null) {
@@ -670,7 +672,7 @@ public class SearchAction extends SearchRequestHandler<IssueQuery, Issue> {
private Map<String, ComponentDto> getProjectsByComponentUuid(Collection<ComponentDto> components, Collection<ComponentDto> projects) {
Map<String, ComponentDto> projectsByUuid = newHashMap();
- for (ComponentDto project: projects) {
+ for (ComponentDto project : projects) {
if (project == null) {
throw new IllegalStateException("Found a null project in issues");
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java
index 627d8ea5a5e..453557ea790 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilder.java
@@ -76,8 +76,9 @@ public class ProxyMultiGetRequestBuilder extends MultiGetRequestBuilder {
message.append(String.format(", index '%s'", item.index()));
String type = item.type();
if (type != null) {
- message.append(String.format(", type '%s'],", type));
+ message.append(String.format(", type '%s'", type));
}
+ message.append("],");
}
return message.toString();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java
index 0cb21e8e292..aa3c7df8139 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilder.java
@@ -45,7 +45,7 @@ public class ProxySearchScrollRequestBuilder extends SearchScrollRequestBuilder
} catch (Exception e) {
throw new IllegalStateException(String.format("Fail to execute %s", toString()), e);
} finally {
- if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
+ if (profiling.isProfilingEnabled(Profiling.Level.BASIC)) {
fullProfile.stop("%s", toString());
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java b/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java
index a9f6b926613..65e8843f73d 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java
@@ -35,7 +35,6 @@ import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java
index 3dbb7b73ebd..2a472eef843 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueQueryServiceTest.java
@@ -38,6 +38,7 @@ import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Maps.newHashMap;
import static java.util.Arrays.asList;
import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -125,4 +126,46 @@ public class IssueQueryServiceTest {
assertThat(IssueQueryService.toRules(asList("squid:AvoidCycle", "findbugs:NullRef"))).containsOnly(RuleKey.of("squid", "AvoidCycle"), RuleKey.of("findbugs", "NullRef"));
}
+ @Test
+ public void fail_if_components_and_components_uuid_params_are_set_at_the_same_time() {
+ Map<String, Object> map = newHashMap();
+ map.put("components", newArrayList("org.apache"));
+ map.put("componentUuids", newArrayList("ABCD"));
+
+ try {
+ issueQueryService.createFromMap(map);
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("components and componentUuids cannot be set simultaneously");
+ }
+ }
+
+ @Test
+ public void fail_if_projects_and_project_uuids_params_are_set_at_the_same_time() {
+ Map<String, Object> map = newHashMap();
+ map.put("projects", newArrayList("org.apache"));
+ map.put("projectUuids", newArrayList("ABCD"));
+
+ try {
+ issueQueryService.createFromMap(map);
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("projects and projectUuids cannot be set simultaneously");
+ }
+ }
+
+ @Test
+ public void fail_if_component_roots_and_component_root_uuids_params_are_set_at_the_same_time() {
+ Map<String, Object> map = newHashMap();
+ map.put("componentRoots", newArrayList("org.apache"));
+ map.put("componentRootUuids", newArrayList("ABCD"));
+
+ try {
+ issueQueryService.createFromMap(map);
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("componentRoots and componentRootUuids cannot be set simultaneously");
+ }
+ }
+
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
index 4643bb6f69d..de74ca9b62e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
@@ -43,6 +43,7 @@ import org.sonar.core.user.UserDto;
import org.sonar.server.component.ComponentTesting;
import org.sonar.server.component.SnapshotTesting;
import org.sonar.server.db.DbClient;
+import org.sonar.server.issue.IssueQuery;
import org.sonar.server.issue.IssueTesting;
import org.sonar.server.issue.db.IssueDao;
import org.sonar.server.issue.filter.IssueFilterParameters;
@@ -102,7 +103,7 @@ public class SearchActionMediumTest {
+ "Third Line\n"
+ "Fourth Line\n"
+ "Fifth Line\n");
- tester.get(SnapshotSourceDao.class).insert(snapshotSource );
+ tester.get(SnapshotSourceDao.class).insert(snapshotSource);
UserDto john = new UserDto().setLogin("john").setName("John").setEmail("john@email.com");
db.userDao().insert(session, john);
@@ -325,6 +326,38 @@ public class SearchActionMediumTest {
}
@Test
+ public void search_by_project_uuid() throws Exception {
+ db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
+ session.commit();
+
+ wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
+ .setParam(IssueFilterParameters.PROJECT_UUIDS, project.uuid())
+ .execute()
+ .assertJson(this.getClass(), "search_by_project_uuid.json", false);
+
+ wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
+ .setParam(IssueFilterParameters.PROJECT_UUIDS, "unknown")
+ .execute()
+ .assertJson(this.getClass(), "no_issue.json", false);
+ }
+
+ @Test
+ public void search_by_component_uuid() throws Exception {
+ db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2"));
+ session.commit();
+
+ wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
+ .setParam(IssueFilterParameters.COMPONENT_UUIDS, file.uuid())
+ .execute()
+ .assertJson(this.getClass(), "search_by_file_uuid.json", false);
+
+ wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
+ .setParam(IssueFilterParameters.COMPONENT_UUIDS, "unknown")
+ .execute()
+ .assertJson(this.getClass(), "no_issue.json", false);
+ }
+
+ @Test
public void return_full_number_of_issues_when_only_one_component_is_set() throws Exception {
for (int i = 0; i < QueryContext.MAX_LIMIT + 1; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
@@ -400,6 +433,20 @@ public class SearchActionMediumTest {
}
@Test
+ public void sort_by_updated_at() throws Exception {
+ db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac1").setIssueUpdateDate(DateUtils.parseDate("2014-11-02")));
+ db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac2").setIssueUpdateDate(DateUtils.parseDate("2014-11-01")));
+ db.issueDao().insert(session, IssueTesting.newDto(rule, file, project).setKee("82fd47d4-b650-4037-80bc-7b112bd4eac3").setIssueUpdateDate(DateUtils.parseDate("2014-11-03")));
+ session.commit();
+
+ WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
+ .setParam("sort", IssueQuery.SORT_BY_UPDATE_DATE)
+ .setParam("asc", "false")
+ .execute();
+ result.assertJson(this.getClass(), "sort_by_updated_at.json", false);
+ }
+
+ @Test
public void paging() throws Exception {
for (int i = 0; i < 12; i++) {
IssueDto issue = IssueTesting.newDto(rule, file, project);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java
index d5c3142df87..febf81402ee 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyBulkRequestBuilderTest.java
@@ -74,6 +74,30 @@ public class ProxyBulkRequestBuilderTest {
.contains("[Action 'IndexRequest' for key 'rule1' on index 'rules' on type 'rules'],");
}
+ @Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ BulkRequestBuilder bulkRequestBuilder = searchClient.prepareBulk();
+ bulkRequestBuilder.add(new UpdateRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").doc(Collections.emptyMap()));
+ bulkRequestBuilder.add(new DeleteRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1"));
+ bulkRequestBuilder.add(new IndexRequest(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexName(), "rule1").source(Collections.emptyMap()));
+ try {
+ bulkRequestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage())
+ .contains("Fail to execute ES bulk request for [Action 'UpdateRequest' for key 'rule1' on index 'rules' on type 'rules'],")
+ .contains("[Action 'DeleteRequest' for key 'rule1' on index 'rules' on type 'rules'],")
+ .contains("[Action 'IndexRequest' for key 'rule1' on index 'rules' on type 'rules'],");
+ }
+
+ // TODO assert profiling
+ }
+
@Test(expected = UnsupportedOperationException.class)
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
searchClient.prepareBulk().get("1");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java
index eebeda718af..c180ca3ef85 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterHealthRequestBuilderTest.java
@@ -55,6 +55,24 @@ public class ProxyClusterHealthRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ ClusterHealthRequestBuilder requestBuilder = searchClient.prepareHealth();
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster health request");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
try {
searchClient.prepareHealth().get("1");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderText.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderText.java
index 6629a9cf430..1450e3debeb 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderText.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStateRequestBuilderText.java
@@ -55,6 +55,24 @@ public class ProxyClusterStateRequestBuilderText {
}
@Test
+ public void with_profiling_basic() {
+ try {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ ClusterStateRequestBuilder requestBuilder = searchClient.prepareState();
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster state request");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
try {
searchClient.prepareState().get("1");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderText.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderText.java
index d7f4704c51c..af0d1737ae3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderText.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyClusterStatsRequestBuilderText.java
@@ -55,6 +55,24 @@ public class ProxyClusterStatsRequestBuilderText {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ ClusterStatsRequestBuilder requestBuilder = searchClient.prepareClusterStats();
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES cluster stats request");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
try {
searchClient.prepareClusterStats().get("1");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java
index f13d19470ae..016e2bd3f86 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCountRequestBuilderTest.java
@@ -55,6 +55,23 @@ public class ProxyCountRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareCount(IndexDefinition.RULE.getIndexName()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES count request on indices 'rules'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_count_bad_query() throws Exception {
try {
searchClient.prepareCount("unknown_index1, unknown_index2").setTypes("unknown_type").get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderText.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderText.java
index 5c035bb78f0..ea715872792 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderText.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyCreateIndexRequestBuilderText.java
@@ -54,6 +54,24 @@ public class ProxyCreateIndexRequestBuilderText {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ CreateIndexRequestBuilder requestBuilder = searchClient.prepareCreate("new");
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES create index 'new'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
try {
searchClient.prepareCreate("new").get("1");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java
index 0a9dc264f87..e939c528553 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyDeleteByQueryRequestBuilderTest.java
@@ -55,6 +55,23 @@ public class ProxyDeleteByQueryRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).setQuery(QueryBuilders.matchAllQuery()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES delete by query request on indices 'rules'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_bulk_bad_query() throws Exception {
try {
searchClient.prepareDeleteByQuery(IndexDefinition.RULE.getIndexName()).get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java
index 30ee20ed132..5639c9ed0bf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyFlushRequestBuilderTest.java
@@ -54,6 +54,23 @@ public class ProxyFlushRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareFlush(IndexDefinition.RULE.getIndexName()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES flush request on indices 'rules'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_refresh() throws Exception {
try {
searchClient.prepareFlush("unknown").get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java
index 9afa92ad67f..27d371db52f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyGetRequestBuilderTest.java
@@ -65,6 +65,27 @@ public class ProxyGetRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareGet()
+ .setIndex(IndexDefinition.RULE.getIndexName())
+ .setType(IndexDefinition.RULE.getIndexType())
+ .setId("ruleKey")
+ .get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES get request for key 'ruleKey' on index 'rules' on type 'rule'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_get_bad_query() throws Exception {
GetRequestBuilder requestBuilder = searchClient.prepareGet()
.setIndex("unknown")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java
index fc60d98d111..c528dd17c1b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesExistsRequestBuilderTest.java
@@ -48,6 +48,23 @@ public class ProxyIndicesExistsRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareExists(IndexDefinition.RULE.getIndexName()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices exists request on indices 'rules'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_exists() throws Exception {
try {
searchClient.prepareExists().get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java
index 958b1967350..0886a0fb3d9 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyIndicesStatsRequestBuilderTest.java
@@ -54,6 +54,23 @@ public class ProxyIndicesStatsRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareStats(IndexDefinition.RULE.getIndexName()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (IllegalStateException e) {
+ assertThat(e.getMessage()).isEqualTo("Fail to execute ES indices stats request on indices 'rules'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_stats() throws Exception {
try {
searchClient.prepareStats("unknown").get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java
index b6543be4440..e53ce97fdfc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyMultiGetRequestBuilderTest.java
@@ -22,7 +22,6 @@ package org.sonar.server.search.request;
import org.elasticsearch.action.get.MultiGetRequest;
import org.elasticsearch.action.get.MultiGetRequestBuilder;
-import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.search.fetch.source.FetchSourceContext;
import org.junit.Test;
@@ -45,7 +44,7 @@ public class ProxyMultiGetRequestBuilderTest {
MultiGetRequestBuilder request = searchClient.prepareMultiGet();
request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
.fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
- MultiGetResponse response = request.get();
+ request.get();
// expected to fail because elasticsearch is not correctly configured, but that does not matter
fail();
@@ -57,12 +56,32 @@ public class ProxyMultiGetRequestBuilderTest {
@Test
public void to_string() {
- MultiGetRequestBuilder request = searchClient.prepareMultiGet();
- assertThat(request.toString()).isEqualTo("ES multi get request");
+ assertThat(searchClient.prepareMultiGet().toString()).isEqualTo("ES multi get request");
+ assertThat(searchClient.prepareMultiGet().add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), null, "ruleKey")
+ .fetchSourceContext(FetchSourceContext.FETCH_SOURCE)).toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules'],");
+ assertThat(searchClient.prepareMultiGet().add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
+ .fetchSourceContext(FetchSourceContext.FETCH_SOURCE)).toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules', type 'rule'],");
+ }
+
+ @Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ MultiGetRequestBuilder request = searchClient.prepareMultiGet();
+ request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
+ .fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
+ request.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES multi get request");
+ }
- request.add(new MultiGetRequest.Item(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), "ruleKey")
- .fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
- assertThat(request.toString()).isEqualTo("ES multi get request [key 'ruleKey', index 'rules', type 'rule'],");
+ // TODO assert profiling
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java
index 26db7eade79..ab14b04ac84 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyNodesStatsRequestBuilderTest.java
@@ -55,6 +55,24 @@ public class ProxyNodesStatsRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareNodesStats().get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES nodes stats request");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void get_with_string_timeout_is_not_yet_implemented() throws Exception {
try {
searchClient.prepareNodesStats(IndexDefinition.RULE.getIndexName()).get("1");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java
index addcb133fbc..1093fc56507 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyPutMappingRequestBuilderTest.java
@@ -43,18 +43,18 @@ public class ProxyPutMappingRequestBuilderTest {
@Test
public void put_mapping() {
try {
- PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
- .setType(IndexDefinition.RULE.getIndexType())
- .setIgnoreConflicts(true)
- .setSource(mapDomain());
- requestBuilder.get();
-
- // expected to fail because elasticsearch is not correctly configured, but that does not matter
- fail();
- } catch (Exception e) {
- assertThat(e).isInstanceOf(IllegalStateException.class);
- assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
- }
+ PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
+ .setType(IndexDefinition.RULE.getIndexType())
+ .setIgnoreConflicts(true)
+ .setSource(mapDomain());
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
+ }
}
@Test
@@ -66,6 +66,28 @@ public class ProxyPutMappingRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ PutMappingRequestBuilder requestBuilder = searchClient.preparePutMapping(IndexDefinition.RULE.getIndexName())
+ .setType(IndexDefinition.RULE.getIndexType())
+ .setIgnoreConflicts(true)
+ .setSource(mapDomain());
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES put mapping request");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_on_bad_query() throws Exception {
try {
searchClient.preparePutMapping().get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java
index ad26a4e43e9..4c786a5cc93 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxyRefreshRequestBuilderTest.java
@@ -57,6 +57,25 @@ public class ProxyRefreshRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ RefreshRequestBuilder requestBuilder = searchClient.prepareRefresh(IndexDefinition.RULE.getIndexName());
+ requestBuilder.get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES refresh request on indices 'rules'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_refresh() throws Exception {
try {
searchClient.prepareRefresh("unknown").get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java
index 9523b4e3872..e9dd3820ce1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchRequestBuilderTest.java
@@ -57,6 +57,24 @@ public class ProxySearchRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+
+ try {
+ searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES search request '{").contains("}' on indices '[rules]'");
+ }
+
+ // TODO assert profiling
+ }
+
+ @Test
public void fail_to_search_bad_query() throws Exception {
try {
searchClient.prepareSearch(IndexDefinition.RULE.getIndexName()).setQuery("bad query").get();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java
index 1db411b15af..c845075c75e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/search/request/ProxySearchScrollRequestBuilderTest.java
@@ -55,6 +55,25 @@ public class ProxySearchScrollRequestBuilderTest {
}
@Test
+ public void with_profiling_basic() {
+ try {
+ Profiling profiling = new Profiling(new Settings().setProperty(Profiling.CONFIG_PROFILING_LEVEL, Profiling.Level.BASIC.name()));
+ SearchClient searchClient = new SearchClient(new Settings(), profiling);
+ SearchResponse search = searchClient.prepareSearch(IndexDefinition.RULE.getIndexName())
+ .setSearchType(SearchType.SCAN)
+ .setScroll(TimeValue.timeValueSeconds(3L))
+ .get();
+ searchClient.prepareSearchScroll(search.getScrollId()).get();
+
+ // expected to fail because elasticsearch is not correctly configured, but that does not matter
+ fail();
+ } catch (Exception e) {
+ assertThat(e).isInstanceOf(IllegalStateException.class);
+ assertThat(e.getMessage()).contains("Fail to execute ES search request '{:{}}' on indices '[rules]'");
+ }
+ }
+
+ @Test
public void fail_to_search_bad_query() throws Exception {
try {
searchClient.prepareSearchScroll("unknown").get();
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/no_issue.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/no_issue.json
new file mode 100644
index 00000000000..ce8bbfbeeb7
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/no_issue.json
@@ -0,0 +1,4 @@
+{
+ "total": 0,
+ "issues": []
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_file_uuid.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_file_uuid.json
new file mode 100644
index 00000000000..f13cd2e997f
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_file_uuid.json
@@ -0,0 +1,12 @@
+{
+ "total": 1,
+ "p": 1,
+ "issues": [
+ {
+ "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
+ "component": "MyComponent",
+ "project": "MyProject",
+ "rule": "xoo:x1"
+ }
+ ]
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_project_uuid.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_project_uuid.json
new file mode 100644
index 00000000000..5df35493a30
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/search_by_project_uuid.json
@@ -0,0 +1,13 @@
+{
+ "total": 1,
+ "p": 1,
+ "ps": 100,
+ "issues": [
+ {
+ "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
+ "component": "MyComponent",
+ "project": "MyProject",
+ "rule": "xoo:x1"
+ }
+ ]
+}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/sort_by_updated_at.json b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/sort_by_updated_at.json
new file mode 100644
index 00000000000..6711ed00118
--- /dev/null
+++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/sort_by_updated_at.json
@@ -0,0 +1,25 @@
+{
+ "issues": [
+ {
+ "key": "82fd47d4-b650-4037-80bc-7b112bd4eac2",
+ "component": "MyComponent",
+ "project": "MyProject",
+ "rule": "xoo:x1",
+ "updateDate": "2014-11-01T00:00:00+0100"
+ },
+ {
+ "key": "82fd47d4-b650-4037-80bc-7b112bd4eac1",
+ "component": "MyComponent",
+ "project": "MyProject",
+ "rule": "xoo:x1",
+ "updateDate": "2014-11-02T00:00:00+0100"
+ },
+ {
+ "key": "82fd47d4-b650-4037-80bc-7b112bd4eac3",
+ "component": "MyComponent",
+ "project": "MyProject",
+ "rule": "xoo:x1",
+ "updateDate": "2014-11-03T00:00:00+0100"
+ }
+ ]
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
index fae97eca964..4f43f45dfaf 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
@@ -33,13 +33,7 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import static org.sonar.core.graph.graphson.ElementPropertyConfig.ElementPropertiesRule;
@@ -467,7 +461,7 @@ class GraphsonUtil {
JSONObject convertedMap = new JSONObject();
JSONObject jsonObject = (JSONObject) value;
- Map<Object, Object> jsonObjectMap = (Map<Object, Object>) jsonObject;
+ Map<Object, Object> jsonObjectMap = jsonObject;
for (Map.Entry<Object, Object> entry : jsonObjectMap.entrySet()) {
// no need to getValue() here as this is already a ObjectNode and should have type info