aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-10-23 10:49:46 +0200
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-10-24 17:40:56 +0200
commitb226884e6334d06b73005852500a16074e2b3495 (patch)
tree2e163e938ffa32c508f63d52635a8e5a10fab648 /server
parentd1f8eb5bbc8f4779d23f23e43b1326e00e3c9131 (diff)
downloadsonarqube-b226884e6334d06b73005852500a16074e2b3495.tar.gz
sonarqube-b226884e6334d06b73005852500a16074e2b3495.zip
SONAR-10008 Make date facet tests independent from the machine's time zone
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/Facets.java17
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/SearchIdResult.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/SearchResult.java5
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/webhook/IssueChangeWebhookImpl.java9
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java11
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndex.java11
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndex.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java20
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java32
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/webhook/IssueChangeWebhookImplTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java2
52 files changed, 136 insertions, 103 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java b/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java
index 8a492913ef4..6f5190d130f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java
@@ -43,6 +43,7 @@ import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.ScoreSortBuilder;
import org.elasticsearch.search.sort.SortOrder;
+import org.sonar.api.utils.System2;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.SearchIdResult;
import org.sonar.server.es.SearchOptions;
@@ -71,10 +72,12 @@ public class ComponentIndex {
private final EsClient client;
private final AuthorizationTypeSupport authorizationTypeSupport;
+ private final System2 system2;
- public ComponentIndex(EsClient client, AuthorizationTypeSupport authorizationTypeSupport) {
+ public ComponentIndex(EsClient client, AuthorizationTypeSupport authorizationTypeSupport, System2 system2) {
this.client = client;
this.authorizationTypeSupport = authorizationTypeSupport;
+ this.system2 = system2;
}
public SearchIdResult<String> search(ComponentQuery query, SearchOptions searchOptions) {
@@ -100,7 +103,7 @@ public class ComponentIndex {
requestBuilder.setQuery(esQuery);
requestBuilder.addSort(SORTABLE_ANALYZER.subField(FIELD_NAME), SortOrder.ASC);
- return new SearchIdResult<>(requestBuilder.get(), id -> id);
+ return new SearchIdResult<>(requestBuilder.get(), id -> id, system2.getDefaultTimeZone());
}
public ComponentIndexResults searchSuggestions(SuggestionQuery query) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java b/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java
index 574ceb158e7..a2e99960eb6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/Facets.java
@@ -20,10 +20,12 @@
package org.sonar.server.es;
import java.util.Collections;
+import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TimeZone;
import javax.annotation.CheckForNull;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
@@ -38,7 +40,6 @@ import org.elasticsearch.search.aggregations.bucket.missing.Missing;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
-import static org.sonar.api.utils.DateUtils.formatDate;
import static org.sonar.api.utils.DateUtils.parseDateTime;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.FACET_MODE_EFFORT;
@@ -48,13 +49,16 @@ public class Facets {
private static final java.lang.String NO_DATA_PREFIX = "no_data_";
private final LinkedHashMap<String, LinkedHashMap<String, Long>> facetsByName;
+ private final TimeZone timeZone;
- public Facets(LinkedHashMap<String, LinkedHashMap<String, Long>> facetsByName) {
+ public Facets(LinkedHashMap<String, LinkedHashMap<String, Long>> facetsByName, TimeZone timeZone) {
this.facetsByName = facetsByName;
+ this.timeZone = timeZone;
}
- public Facets(SearchResponse response) {
+ public Facets(SearchResponse response, TimeZone timeZone) {
this.facetsByName = new LinkedHashMap<>();
+ this.timeZone = timeZone;
Aggregations aggregations = response.getAggregations();
if (aggregations != null) {
for (Aggregation facet : aggregations) {
@@ -130,7 +134,7 @@ public class Facets {
private void processDateHistogram(Histogram aggregation) {
LinkedHashMap<String, Long> facet = getOrCreateFacet(aggregation.getName());
for (Histogram.Bucket value : aggregation.getBuckets()) {
- String day = formatDate(parseDateTime(value.getKeyAsString()));
+ String day = dateTimeToDate(value.getKeyAsString(), timeZone);
if (value.getAggregations().getAsMap().containsKey(FACET_MODE_EFFORT)) {
facet.put(day, Math.round(((Sum) value.getAggregations().get(FACET_MODE_EFFORT)).getValue()));
} else {
@@ -139,6 +143,11 @@ public class Facets {
}
}
+ private static String dateTimeToDate(String timestamp, TimeZone timeZone) {
+ Date date = parseDateTime(timestamp);
+ return date.toInstant().atZone(timeZone.toZoneId()).toLocalDate().toString();
+ }
+
private void processSum(Sum aggregation) {
getOrCreateFacet(aggregation.getName()).put(TOTAL, Math.round(aggregation.getValue()));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/SearchIdResult.java b/server/sonar-server/src/main/java/org/sonar/server/es/SearchIdResult.java
index 41787359a68..a68ca591533 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/SearchIdResult.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/SearchIdResult.java
@@ -22,6 +22,7 @@ package org.sonar.server.es;
import com.google.common.base.Function;
import java.util.ArrayList;
import java.util.List;
+import java.util.TimeZone;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
@@ -33,8 +34,8 @@ public class SearchIdResult<ID> {
private final Facets facets;
private final long total;
- public SearchIdResult(SearchResponse response, Function<String, ID> converter) {
- this.facets = new Facets(response);
+ public SearchIdResult(SearchResponse response, Function<String, ID> converter, TimeZone timeZone) {
+ this.facets = new Facets(response, timeZone);
this.total = response.getHits().getTotalHits();
this.ids = convertToIds(response.getHits(), converter);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/SearchResult.java b/server/sonar-server/src/main/java/org/sonar/server/es/SearchResult.java
index 3cde890717c..cf3c1fcd5ea 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/SearchResult.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/SearchResult.java
@@ -21,6 +21,7 @@ package org.sonar.server.es;
import java.util.List;
import java.util.Map;
+import java.util.TimeZone;
import java.util.function.Function;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.elasticsearch.action.search.SearchResponse;
@@ -31,8 +32,8 @@ public class SearchResult<DOC extends BaseDoc> {
private final Facets facets;
private final long total;
- public SearchResult(SearchResponse response, Function<Map<String, Object>, DOC> converter) {
- this.facets = new Facets(response);
+ public SearchResult(SearchResponse response, Function<Map<String, Object>, DOC> converter, TimeZone timeZone) {
+ this.facets = new Facets(response, timeZone);
this.total = response.getHits().getTotalHits();
this.docs = EsUtils.convertToDocs(response.getHits(), converter);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/webhook/IssueChangeWebhookImpl.java b/server/sonar-server/src/main/java/org/sonar/server/issue/webhook/IssueChangeWebhookImpl.java
index ad587e4326c..b379eb629a7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/webhook/IssueChangeWebhookImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/webhook/IssueChangeWebhookImpl.java
@@ -31,6 +31,7 @@ import org.sonar.api.config.Configuration;
import org.sonar.api.issue.DefaultTransitions;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.rules.RuleType;
+import org.sonar.api.utils.System2;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.IssueChangeContext;
import org.sonar.db.DbClient;
@@ -71,14 +72,16 @@ public class IssueChangeWebhookImpl implements IssueChangeWebhook {
private final ProjectConfigurationLoader projectConfigurationLoader;
private final WebhookPayloadFactory webhookPayloadFactory;
private final IssueIndex issueIndex;
+ private final System2 system2;
public IssueChangeWebhookImpl(DbClient dbClient, WebHooks webhooks, ProjectConfigurationLoader projectConfigurationLoader,
- WebhookPayloadFactory webhookPayloadFactory, IssueIndex issueIndex) {
+ WebhookPayloadFactory webhookPayloadFactory, IssueIndex issueIndex, System2 system2) {
this.dbClient = dbClient;
this.webhooks = webhooks;
this.projectConfigurationLoader = projectConfigurationLoader;
this.webhookPayloadFactory = webhookPayloadFactory;
this.issueIndex = issueIndex;
+ this.system2 = system2;
}
@Override
@@ -167,7 +170,7 @@ public class IssueChangeWebhookImpl implements IssueChangeWebhook {
return webhookPayloadFactory.create(projectAnalysis);
}
- private static QualityGate createQualityGate(ComponentDto branch, IssueIndex issueIndex) {
+ private QualityGate createQualityGate(ComponentDto branch, IssueIndex issueIndex) {
SearchResponse searchResponse = issueIndex.search(IssueQuery.builder()
.projectUuids(singletonList(branch.getMainBranchProjectUuid()))
.branchUuid(branch.uuid())
@@ -176,7 +179,7 @@ public class IssueChangeWebhookImpl implements IssueChangeWebhook {
.checkAuthorization(false)
.build(),
new SearchOptions().addFacets(RuleIndex.FACET_TYPES));
- LinkedHashMap<String, Long> typeFacet = new Facets(searchResponse)
+ LinkedHashMap<String, Long> typeFacet = new Facets(searchResponse, system2.getDefaultTimeZone())
.get(RuleIndex.FACET_TYPES);
Set<QualityGate.Condition> conditions = ShortLivingBranchQualityGate.CONDITIONS.stream()
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 f4883716271..5293f0491c9 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
@@ -42,6 +42,7 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.Paging;
+import org.sonar.api.utils.System2;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.server.es.Facets;
import org.sonar.server.es.SearchOptions;
@@ -117,14 +118,16 @@ public class SearchAction implements IssuesWsAction {
private final IssueQueryFactory issueQueryFactory;
private final SearchResponseLoader searchResponseLoader;
private final SearchResponseFormat searchResponseFormat;
+ private final System2 system2;
public SearchAction(UserSession userSession, IssueIndex issueIndex, IssueQueryFactory issueQueryFactory,
- SearchResponseLoader searchResponseLoader, SearchResponseFormat searchResponseFormat) {
+ SearchResponseLoader searchResponseLoader, SearchResponseFormat searchResponseFormat, System2 system2) {
this.userSession = userSession;
this.issueIndex = issueIndex;
this.issueQueryFactory = issueQueryFactory;
this.searchResponseLoader = searchResponseLoader;
this.searchResponseFormat = searchResponseFormat;
+ this.system2 = system2;
}
@Override
@@ -334,7 +337,7 @@ public class SearchAction implements IssuesWsAction {
collectRequestParams(collector, request);
Facets facets = null;
if (!options.getFacets().isEmpty()) {
- facets = new Facets(result);
+ facets = new Facets(result, system2.getDefaultTimeZone());
// add missing values to facets. For example if assignee "john" and facet on "assignees" are requested, then
// "john" should always be listed in the facet. If it is not present, then it is added with value zero.
// This is a constraint from webapp UX.
@@ -371,7 +374,7 @@ public class SearchAction implements IssuesWsAction {
return options;
}
- private static Facets reorderFacets(@Nullable Facets facets, Collection<String> orderedNames) {
+ private Facets reorderFacets(@Nullable Facets facets, Collection<String> orderedNames) {
if (facets == null) {
return null;
}
@@ -382,7 +385,7 @@ public class SearchAction implements IssuesWsAction {
orderedFacets.put(facetName, facet);
}
}
- return new Facets(orderedFacets);
+ return new Facets(orderedFacets, system2.getDefaultTimeZone());
}
private void completeFacets(Facets facets, SearchWsRequest request, Request wsRequest) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
index dc7c3db668f..53119df0569 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
@@ -50,6 +50,7 @@ import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
+import org.sonar.api.utils.System2;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.server.es.DefaultIndexSettingsElement;
import org.sonar.server.es.EsClient;
@@ -156,10 +157,12 @@ public class ProjectMeasuresIndex {
private final EsClient client;
private final AuthorizationTypeSupport authorizationTypeSupport;
+ private final System2 system2;
- public ProjectMeasuresIndex(EsClient client, AuthorizationTypeSupport authorizationTypeSupport) {
+ public ProjectMeasuresIndex(EsClient client, AuthorizationTypeSupport authorizationTypeSupport, System2 system2) {
this.client = client;
this.authorizationTypeSupport = authorizationTypeSupport;
+ this.system2 = system2;
}
public SearchIdResult<String> search(ProjectMeasuresQuery query, SearchOptions searchOptions) {
@@ -176,7 +179,7 @@ public class ProjectMeasuresIndex {
addFacets(requestBuilder, searchOptions, filters, query);
addSort(query, requestBuilder);
- return new SearchIdResult<>(requestBuilder.get(), id -> id);
+ return new SearchIdResult<>(requestBuilder.get(), id -> id, system2.getDefaultTimeZone());
}
public ProjectMeasuresStatistics searchTelemetryStatistics() {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
index 5825312645e..87e6454194a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
@@ -55,6 +55,7 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.rules.RuleType;
+import org.sonar.api.utils.System2;
import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
@@ -131,9 +132,11 @@ public class RuleIndex {
private static final String AGGREGATION_NAME_FOR_TAGS = "tagsAggregation";
private final EsClient client;
+ private final System2 system2;
- public RuleIndex(EsClient client) {
+ public RuleIndex(EsClient client, System2 system2) {
this.client = client;
+ this.system2 = system2;
}
public SearchIdResult<RuleKey> search(RuleQuery query, SearchOptions options) {
@@ -158,7 +161,7 @@ public class RuleIndex {
}
esSearch.setQuery(boolQuery().must(qb).filter(fb));
- return new SearchIdResult<>(esSearch.get(), RuleKey::parse);
+ return new SearchIdResult<>(esSearch.get(), RuleKey::parse, system2.getDefaultTimeZone());
}
/**
diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndex.java b/server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndex.java
index 90dd3cc000d..63ead033573 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndex.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndex.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.lucene.search.join.ScoreMode;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.search.SearchHit;
+import org.sonar.api.utils.System2;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.SearchOptions;
import org.sonar.server.es.SearchResult;
@@ -41,9 +42,11 @@ import static org.sonar.server.test.index.TestIndexDefinition.FIELD_TEST_UUID;
public class TestIndex {
private final EsClient client;
+ private final System2 system2;
- public TestIndex(EsClient client) {
+ public TestIndex(EsClient client, System2 system2) {
this.client = client;
+ this.system2 = system2;
}
public List<CoveredFileDoc> coveredFiles(String testUuid) {
@@ -65,7 +68,7 @@ public class TestIndex {
.setFrom(searchOptions.getOffset())
.setQuery(boolQuery().must(matchAllQuery()).filter(termQuery(FIELD_FILE_UUID, testFileUuid)));
- return new SearchResult<>(searchRequest.get(), TestDoc::new);
+ return new SearchResult<>(searchRequest.get(), TestDoc::new, system2.getDefaultTimeZone());
}
public SearchResult<TestDoc> searchBySourceFileUuidAndLineNumber(String sourceFileUuid, int lineNumber, SearchOptions searchOptions) {
@@ -79,7 +82,7 @@ public class TestIndex {
.must(termQuery(FIELD_COVERED_FILES + "." + FIELD_COVERED_FILE_LINES, lineNumber)),
ScoreMode.Avg));
- return new SearchResult<>(searchRequest.get(), TestDoc::new);
+ return new SearchResult<>(searchRequest.get(), TestDoc::new, system2.getDefaultTimeZone());
}
public TestDoc getByTestUuid(String testUuid) {
@@ -108,6 +111,6 @@ public class TestIndex {
.setFrom(searchOptions.getOffset())
.setQuery(boolQuery().must(matchAllQuery()).filter(termQuery(FIELD_TEST_UUID, testUuid)));
- return new SearchResult<>(searchRequest.get(), TestDoc::new);
+ return new SearchResult<>(searchRequest.get(), TestDoc::new, system2.getDefaultTimeZone());
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndex.java b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndex.java
index 0ddb194e46d..cd937915bcc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndex.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndex.java
@@ -35,6 +35,7 @@ import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.sort.SortOrder;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
+import org.sonar.api.utils.System2;
import org.sonar.server.es.EsClient;
import org.sonar.server.es.SearchOptions;
import org.sonar.server.es.SearchResult;
@@ -57,9 +58,11 @@ import static org.sonar.server.user.index.UserIndexDefinition.FIELD_SCM_ACCOUNTS
public class UserIndex {
private final EsClient esClient;
+ private final System2 system2;
- public UserIndex(EsClient esClient) {
+ public UserIndex(EsClient esClient, System2 system2) {
this.esClient = esClient;
+ this.system2 = system2;
}
@CheckForNull
@@ -123,7 +126,7 @@ public class UserIndex {
request.setQuery(boolQuery().must(esQuery).filter(filter));
- return new SearchResult<>(request.get(), UserDoc::new);
+ return new SearchResult<>(request.get(), UserDoc::new, system2.getDefaultTimeZone());
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
index b26cecc240c..e637593bbd4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
@@ -58,7 +58,7 @@ public class ComponentIndexSearchTest {
private ComponentIndexer indexer = new ComponentIndexer(db.getDbClient(), es.client());
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, indexer);
- private ComponentIndex underTest = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ private ComponentIndex underTest = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
@Test
public void filter_by_language() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
index bbbb51a2d43..75d2d4ce7bf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
@@ -60,7 +60,7 @@ public abstract class ComponentIndexTest {
public ComponentTextSearchFeatureRule features = new ComponentTextSearchFeatureRule();
protected ComponentIndexer indexer = new ComponentIndexer(db.getDbClient(), es.client());
- protected ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ protected ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
protected PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, indexer);
private OrganizationDto organization;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
index 79689b048f5..3a6cc5e891b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
@@ -96,7 +96,7 @@ public class SearchActionTest {
private Languages languages = mock(Languages.class);
private ComponentIndexer indexer = new ComponentIndexer(db.getDbClient(), es.client());
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, indexer);
- private ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ private ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
private UserDto user;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
index 1428b905147..ed3a6786785 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
@@ -128,7 +128,7 @@ public class SearchProjectsActionTest {
private DbSession dbSession = db.getSession();
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, new ProjectMeasuresIndexer(dbClient, es.client()));
- private ProjectMeasuresIndex index = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ private ProjectMeasuresIndex index = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
private ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(db.getDbClient(), es.client());
private WsActionTester ws = new WsActionTester(
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
index 670893dfed9..7858f907b8f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
@@ -98,7 +98,7 @@ public class SuggestionsActionTest {
private ComponentIndexer componentIndexer = new ComponentIndexer(db.getDbClient(), es.client());
private FavoriteFinder favoriteFinder = mock(FavoriteFinder.class);
- private ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSessionRule));
+ private ComponentIndex index = new ComponentIndex(es.client(), new AuthorizationTypeSupport(userSessionRule), System2.INSTANCE);
private SuggestionsAction underTest = new SuggestionsAction(db.getDbClient(), index, favoriteFinder, userSessionRule, resourceTypes);
private OrganizationDto organization;
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, componentIndexer);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java
index e8a08221bf2..77ec01b55d7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java
@@ -22,6 +22,7 @@ package org.sonar.server.computation.task.projectanalysis.issue;
import java.util.Collections;
import org.junit.Test;
import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.LogTester;
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.server.es.EsTester;
@@ -51,7 +52,7 @@ public class ScmAccountToUserLoaderTest {
.setScmAccounts(asList("charlie", "jesuis@charlie.com"));
esTester.putDocuments(UserIndexDefinition.INDEX_TYPE_USER.getIndex(), UserIndexDefinition.INDEX_TYPE_USER.getType(), user);
- UserIndex index = new UserIndex(esTester.client());
+ UserIndex index = new UserIndex(esTester.client(), System2.INSTANCE);
ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(index);
assertThat(underTest.load("missing")).isNull();
@@ -75,7 +76,7 @@ public class ScmAccountToUserLoaderTest {
.setScmAccounts(asList("charlie"));
esTester.putDocuments(UserIndexDefinition.INDEX_TYPE_USER.getIndex(), UserIndexDefinition.INDEX_TYPE_USER.getType(), user2);
- UserIndex index = new UserIndex(esTester.client());
+ UserIndex index = new UserIndex(esTester.client(), System2.INSTANCE);
ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(index);
assertThat(underTest.load("charlie")).isNull();
@@ -84,7 +85,7 @@ public class ScmAccountToUserLoaderTest {
@Test
public void load_by_multiple_scm_accounts_is_not_supported_yet() {
- UserIndex index = new UserIndex(esTester.client());
+ UserIndex index = new UserIndex(esTester.client(), System2.INSTANCE);
ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(index);
try {
underTest.loadAll(Collections.<String>emptyList());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
index 2e13410c33b..4b283b2fd78 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
@@ -31,6 +31,7 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
+import org.sonar.api.utils.internal.TestSystem2;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
@@ -50,15 +51,13 @@ import org.sonar.server.view.index.ViewIndexDefinition;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.DEPRECATED_FACET_MODE_DEBT;
import static org.sonarqube.ws.client.issue.IssuesWsParameters.FACET_MODE_EFFORT;
public class IssueIndexDebtTest {
- private System2 system2 = System2.INSTANCE;
+ private System2 system2 = new TestSystem2().setNow(1_500_000_000_000L).setDefaultTimeZone(TimeZone.getTimeZone("GMT-01:00"));
@Rule
public EsTester es = new EsTester(new IssueIndexDefinition(new MapSettings().asConfig()), new ViewIndexDefinition(new MapSettings().asConfig()));
@@ -73,10 +72,7 @@ public class IssueIndexDebtTest {
@Before
public void setUp() {
- System2 system = mock(System2.class);
- when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("+01:00"));
- when(system.now()).thenReturn(System.currentTimeMillis());
- underTest = new IssueIndex(es.client(), system, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
+ underTest = new IssueIndex(es.client(), system2, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
}
@Test
@@ -196,7 +192,7 @@ public class IssueIndexDebtTest {
}
private Facets search(String additionalFacet) {
- return new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(asList(additionalFacet))));
+ return new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(asList(additionalFacet))), system2.getDefaultTimeZone());
}
@Test
@@ -210,7 +206,7 @@ public class IssueIndexDebtTest {
IssueDocTesting.newDoc("I3", file).setAssignee("simon").setEffort(10L),
IssueDocTesting.newDoc("I4", file).setAssignee(null).setEffort(10L));
- Facets facets = new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(asList("assignees"))));
+ Facets facets = new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(asList("assignees"))), system2.getDefaultTimeZone());
assertThat(facets.getNames()).containsOnly("assignees", FACET_MODE_EFFORT);
assertThat(facets.get("assignees")).containsOnly(entry("steph", 10L), entry("simon", 20L), entry("", 10L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L));
@@ -227,7 +223,7 @@ public class IssueIndexDebtTest {
IssueDocTesting.newDoc("I3", file).setAuthorLogin("simon").setEffort(10L),
IssueDocTesting.newDoc("I4", file).setAuthorLogin(null).setEffort(10L));
- Facets facets = new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(asList("authors"))));
+ Facets facets = new Facets(underTest.search(newQueryBuilder().build(), new SearchOptions().addFacets(asList("authors"))), system2.getDefaultTimeZone());
assertThat(facets.getNames()).containsOnly("authors", FACET_MODE_EFFORT);
assertThat(facets.get("authors")).containsOnly(entry("steph", 10L), entry("simon", 20L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 40L));
@@ -238,7 +234,7 @@ public class IssueIndexDebtTest {
SearchOptions searchOptions = fixtureForCreatedAtFacet();
Builder query = newQueryBuilder().createdBefore(DateUtils.parseDateTime("2016-01-01T00:00:00+0100"));
- Map<String, Long> createdAt = new Facets(underTest.search(query.build(), searchOptions)).get("createdAt");
+ Map<String, Long> createdAt = new Facets(underTest.search(query.build(), searchOptions), system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2011-01-01", 10L),
entry("2012-01-01", 0L),
@@ -259,7 +255,7 @@ public class IssueIndexDebtTest {
IssueDocTesting.newDoc("I3", ComponentTesting.newFileDto(project2, null)).setEffort(10L));
Facets facets = new Facets(underTest.search(IssueQuery.builder().facetMode(DEPRECATED_FACET_MODE_DEBT).build(),
- new SearchOptions().addFacets(asList("projectUuids"))));
+ new SearchOptions().addFacets(asList("projectUuids"))), system2.getDefaultTimeZone());
assertThat(facets.getNames()).containsOnly("projectUuids", FACET_MODE_EFFORT);
assertThat(facets.get("projectUuids")).containsOnly(entry("ABCD", 20L), entry("EFGH", 10L));
assertThat(facets.get(FACET_MODE_EFFORT)).containsOnly(entry("total", 30L));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
index acc20812f26..25cf4657915 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
@@ -34,7 +34,6 @@ import org.assertj.core.api.Fail;
import org.assertj.core.groups.Tuple;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.search.SearchHit;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -43,6 +42,7 @@ import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
import org.sonar.api.utils.System2;
+import org.sonar.api.utils.internal.TestSystem2;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
@@ -71,8 +71,6 @@ import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.assertj.core.api.Assertions.tuple;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
import static org.sonar.api.rules.RuleType.BUG;
import static org.sonar.api.rules.RuleType.CODE_SMELL;
@@ -101,7 +99,7 @@ public class IssueIndexTest {
public UserSessionRule userSessionRule = UserSessionRule.standalone();
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private System2 system2 = mock(System2.class);
+ private System2 system2 = new TestSystem2().setNow(1_500_000_000_000L).setDefaultTimeZone(TimeZone.getTimeZone("GMT-01:00"));
@Rule
public DbTester db = DbTester.create(system2);
private IssueIndexer issueIndexer = new IssueIndexer(es.client(), db.getDbClient(), new IssueIteratorFactory(db.getDbClient()));
@@ -111,12 +109,6 @@ public class IssueIndexTest {
private IssueIndex underTest = new IssueIndex(es.client(), system2, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
- @Before
- public void setUp() {
- when(system2.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("GMT-1:00"));
- when(system2.now()).thenReturn(System.currentTimeMillis());
- }
-
@Test
public void filter_by_keys() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(newOrganizationDto());
@@ -785,7 +777,7 @@ public class IssueIndexTest {
.checkAuthorization(false)
.build();
SearchResponse result = underTest.search(query, options);
- Map<String, Long> buckets = new Facets(result).get("createdAt");
+ Map<String, Long> buckets = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(buckets).containsOnly(
entry("2014-08-31", 0L),
entry("2014-09-01", 2L),
@@ -805,7 +797,7 @@ public class IssueIndexTest {
.createdAfter(parseDateTime("2014-09-01T00:00:00+0100"))
.createdBefore(parseDateTime("2014-09-21T00:00:00+0100")).build(),
options);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2014-08-25", 0L),
entry("2014-09-01", 4L),
@@ -821,7 +813,7 @@ public class IssueIndexTest {
.createdAfter(parseDateTime("2014-09-01T00:00:00+0100"))
.createdBefore(parseDateTime("2015-01-19T00:00:00+0100")).build(),
options);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2014-08-01", 0L),
entry("2014-09-01", 5L),
@@ -839,7 +831,7 @@ public class IssueIndexTest {
.createdAfter(parseDateTime("2011-01-01T00:00:00+0100"))
.createdBefore(parseDateTime("2016-01-01T00:00:00+0100")).build(),
options);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2010-01-01", 0L),
entry("2011-01-01", 1L),
@@ -857,7 +849,7 @@ public class IssueIndexTest {
.createdAfter(parseDateTime("2014-09-01T00:00:00-0100"))
.createdBefore(parseDateTime("2014-09-02T00:00:00-0100")).build(),
options);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2014-09-01", 2L));
}
@@ -870,7 +862,7 @@ public class IssueIndexTest {
.createdAfter(parseDateTime("2009-01-01T00:00:00+0100"))
.createdBefore(parseDateTime("2016-01-01T00:00:00+0100"))
.build(), options);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2008-01-01", 0L),
entry("2009-01-01", 0L),
@@ -889,7 +881,7 @@ public class IssueIndexTest {
SearchResponse result = underTest.search(IssueQuery.builder()
.createdBefore(parseDateTime("2016-01-01T00:00:00+0100")).build(),
searchOptions);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).containsOnly(
entry("2011-01-01", 1L),
entry("2012-01-01", 0L),
@@ -903,7 +895,7 @@ public class IssueIndexTest {
SearchOptions searchOptions = new SearchOptions().addFacets("createdAt");
SearchResponse result = underTest.search(IssueQuery.builder().build(), searchOptions);
- Map<String, Long> createdAt = new Facets(result).get("createdAt");
+ Map<String, Long> createdAt = new Facets(result, system2.getDefaultTimeZone()).get("createdAt");
assertThat(createdAt).isNull();
}
@@ -1422,14 +1414,14 @@ public class IssueIndexTest {
private void assertThatFacetHasExactly(IssueQuery.Builder query, String facet, Map.Entry<String, Long>... expectedEntries) {
SearchResponse result = underTest.search(query.build(), new SearchOptions().addFacets(asList(facet)));
- Facets facets = new Facets(result);
+ Facets facets = new Facets(result, system2.getDefaultTimeZone());
assertThat(facets.getNames()).containsOnly(facet);
assertThat(facets.get(facet)).containsExactly(expectedEntries);
}
private void assertThatFacetHasOnly(IssueQuery.Builder query, String facet, Map.Entry<String, Long>... expectedEntries) {
SearchResponse result = underTest.search(query.build(), new SearchOptions().addFacets(asList(facet)));
- Facets facets = new Facets(result);
+ Facets facets = new Facets(result, system2.getDefaultTimeZone());
assertThat(facets.getNames()).containsOnly(facet);
assertThat(facets.get(facet)).containsOnly(expectedEntries);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/webhook/IssueChangeWebhookImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/webhook/IssueChangeWebhookImplTest.java
index fcd7301bffb..95b7232d102 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/webhook/IssueChangeWebhookImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/webhook/IssueChangeWebhookImplTest.java
@@ -145,10 +145,10 @@ public class IssueChangeWebhookImplTest {
private IssueIndex issueIndex = new IssueIndex(esTester.client(), System2.INSTANCE, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
private DbClient spiedOnDbClient = spy(dbClient);
private ProjectConfigurationLoader projectConfigurationLoader = mock(ProjectConfigurationLoader.class);
- private IssueChangeWebhookImpl underTest = new IssueChangeWebhookImpl(spiedOnDbClient, webHooks, projectConfigurationLoader, webhookPayloadFactory, issueIndex);
+ private IssueChangeWebhookImpl underTest = new IssueChangeWebhookImpl(spiedOnDbClient, webHooks, projectConfigurationLoader, webhookPayloadFactory, issueIndex, System2.INSTANCE);
private DbClient mockedDbClient = mock(DbClient.class);
private IssueIndex spiedOnIssueIndex = spy(issueIndex);
- private IssueChangeWebhookImpl mockedUnderTest = new IssueChangeWebhookImpl(mockedDbClient, webHooks, projectConfigurationLoader, webhookPayloadFactory, spiedOnIssueIndex);
+ private IssueChangeWebhookImpl mockedUnderTest = new IssueChangeWebhookImpl(mockedDbClient, webHooks, projectConfigurationLoader, webhookPayloadFactory, spiedOnIssueIndex, System2.INSTANCE);
@Test
public void on_type_change_has_no_effect_if_SearchResponseData_has_no_issue() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
index ca0539ed339..51309b4c317 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
@@ -104,7 +104,7 @@ public class SearchActionComponentsTest {
private SearchResponseFormat searchResponseFormat = new SearchResponseFormat(new Durations(), new WsResponseCommonFormat(languages), languages, new AvatarResolverImpl());
private PermissionIndexerTester permissionIndexer = new PermissionIndexerTester(es, issueIndexer);
- private WsActionTester ws = new WsActionTester(new SearchAction(userSession, issueIndex, issueQueryFactory, searchResponseLoader, searchResponseFormat));
+ private WsActionTester ws = new WsActionTester(new SearchAction(userSession, issueIndex, issueQueryFactory, searchResponseLoader, searchResponseFormat, System2.INSTANCE));
@Test
public void search_all_issues_when_no_parameter() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
index 14bea4cc667..c8e3753999c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
@@ -102,7 +102,7 @@ public class SearchActionTest {
private SearchResponseLoader searchResponseLoader = new SearchResponseLoader(userSessionRule, dbClient, new TransitionService(userSessionRule, issueWorkflow));
private Languages languages = new Languages();
private SearchResponseFormat searchResponseFormat = new SearchResponseFormat(new Durations(), new WsResponseCommonFormat(languages), languages, new AvatarResolverImpl());
- private WsActionTester ws = new WsActionTester(new SearchAction(userSessionRule, issueIndex, issueQueryFactory, searchResponseLoader, searchResponseFormat));
+ private WsActionTester ws = new WsActionTester(new SearchAction(userSessionRule, issueIndex, issueQueryFactory, searchResponseLoader, searchResponseFormat, System2.INSTANCE));
private OrganizationDto defaultOrganization;
private OrganizationDto otherOrganization1;
private OrganizationDto otherOrganization2;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java
index 3c54528d4bb..3241e73902d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java
@@ -68,7 +68,7 @@ public class TagsActionTest {
private RuleIndexer ruleIndexer = new RuleIndexer(esTester.client(), dbTester.getDbClient());
private PermissionIndexerTester permissionIndexerTester = new PermissionIndexerTester(esTester, issueIndexer);
private IssueIndex issueIndex = new IssueIndex(esTester.client(), System2.INSTANCE, userSession, new AuthorizationTypeSupport(userSession));
- private RuleIndex ruleIndex = new RuleIndex(esTester.client());
+ private RuleIndex ruleIndex = new RuleIndex(esTester.client(), System2.INSTANCE);
private WsActionTester ws = new WsActionTester(new TagsAction(issueIndex, ruleIndex, dbTester.getDbClient(), TestDefaultOrganizationProvider.from(dbTester)));
private OrganizationDto organization;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
index c63fdb68e4c..c2dd80e8daf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
@@ -35,6 +35,7 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.utils.System2;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.organization.OrganizationDto;
@@ -111,7 +112,7 @@ public class ProjectMeasuresIndexTest {
private ProjectMeasuresIndexer projectMeasureIndexer = new ProjectMeasuresIndexer(null, es.client());
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, projectMeasureIndexer);
- private ProjectMeasuresIndex underTest = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ private ProjectMeasuresIndex underTest = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
@Test
public void return_empty_if_no_projects() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
index 6673302c3df..3dc91491a63 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.utils.System2;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.organization.OrganizationTesting;
@@ -66,7 +67,7 @@ public class ProjectMeasuresIndexTextSearchTest {
private ProjectMeasuresIndexer projectMeasureIndexer = new ProjectMeasuresIndexer(null, es.client());
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, projectMeasureIndexer);
- private ProjectMeasuresIndex underTest = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ private ProjectMeasuresIndex underTest = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
@Test
public void match_exact_case_insensitive_name() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java
index 6ba745d2b4d..675444ac1ef 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java
@@ -104,7 +104,7 @@ public class OrganizationCreationImplTest {
private OrganizationValidation organizationValidation = mock(OrganizationValidation.class);
private MapSettings settings = new MapSettings();
private UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
- private UserIndex userIndex = new UserIndex(es.client());
+ private UserIndex userIndex = new UserIndex(es.client(), system2);
private DefaultGroupCreator defaultGroupCreator = new DefaultGroupCreatorImpl(dbClient);
private OrganizationCreationImpl underTest = new OrganizationCreationImpl(dbClient, system2, uuidFactory, organizationValidation, settings.asConfig(), userIndexer,
builtInQProfileRepositoryRule, defaultGroupCreator);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
index d5aa40abea1..ffd72018d66 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
@@ -28,6 +28,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
@@ -68,7 +69,7 @@ public class AddMemberActionTest {
public UserSessionRule userSession = UserSessionRule.standalone().logIn().setRoot();
@Rule
public EsTester es = new EsTester(new UserIndexDefinition(new MapSettings().asConfig()));
- private UserIndex userIndex = new UserIndex(es.client());
+ private UserIndex userIndex = new UserIndex(es.client(), System2.INSTANCE);
@Rule
public DbTester db = DbTester.create();
private DbClient dbClient = db.getDbClient();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
index e387274390f..0806889e0ee 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
@@ -98,7 +98,7 @@ public class CreateActionTest {
private UuidFactory uuidFactory = mock(UuidFactory.class);
private OrganizationValidation organizationValidation = new OrganizationValidationImpl();
private UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
- private UserIndex userIndex = new UserIndex(es.client());
+ private UserIndex userIndex = new UserIndex(es.client(), System2.INSTANCE);
private OrganizationCreation organizationCreation = new OrganizationCreationImpl(dbClient, system2, uuidFactory, organizationValidation, settings.asConfig(), userIndexer,
mock(BuiltInQProfileRepository.class), new DefaultGroupCreatorImpl(dbClient));
private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone().setEnabled(true);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
index cdbe6cfab22..95b37cc554d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
@@ -85,7 +85,7 @@ public class DeleteActionTest {
private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone().setEnabled(true);
private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
private QProfileFactory qProfileFactory = new QProfileFactoryImpl(dbClient, mock(UuidFactory.class), System2.INSTANCE, mock(ActiveRuleIndexer.class));
- private UserIndex userIndex = new UserIndex(es.client());
+ private UserIndex userIndex = new UserIndex(es.client(), System2.INSTANCE);
private UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
private WsActionTester wsTester = new WsActionTester(new DeleteAction(userSession, dbClient, defaultOrganizationProvider, componentCleanerService, organizationFlags, userIndexer, qProfileFactory));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java
index a6bfbb75049..f4c28e38504 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java
@@ -28,6 +28,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
@@ -80,7 +81,7 @@ public class RemoveMemberActionTest {
private DbClient dbClient = db.getDbClient();
private DbSession dbSession = db.getSession();
- private UserIndex userIndex = new UserIndex(es.client());
+ private UserIndex userIndex = new UserIndex(es.client(), System2.INSTANCE);
private UserIndexer userIndexer = new UserIndexer(dbClient, es.client());
private WsActionTester ws = new WsActionTester(new RemoveMemberAction(dbClient, userSession, userIndexer));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
index ecf87cde61f..584dadca43b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
@@ -27,6 +27,7 @@ import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.server.ws.WebService.Param;
+import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
@@ -70,7 +71,7 @@ public class SearchMembersActionTest {
private DefaultOrganizationProvider organizationProvider = TestDefaultOrganizationProvider.from(db);
private UserIndexer indexer = new UserIndexer(dbClient, es.client());
- private WsActionTester ws = new WsActionTester(new SearchMembersAction(dbClient, new UserIndex(es.client()), organizationProvider, userSession, new AvatarResolverImpl()));
+ private WsActionTester ws = new WsActionTester(new SearchMembersAction(dbClient, new UserIndex(es.client(), System2.INSTANCE), organizationProvider, userSession, new AvatarResolverImpl()));
private SearchMembersWsRequest request = new SearchMembersWsRequest();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
index ecefab80741..640295fd6af 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
@@ -28,6 +28,7 @@ import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import org.sonar.db.organization.OrganizationDto;
@@ -65,7 +66,7 @@ public class SearchActionTest {
private ProjectMeasuresIndexer projectMeasureIndexer = new ProjectMeasuresIndexer(null, es.client());
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es, projectMeasureIndexer);
- private ProjectMeasuresIndex index = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession));
+ private ProjectMeasuresIndex index = new ProjectMeasuresIndex(es.client(), new AuthorizationTypeSupport(userSession), System2.INSTANCE);
private WsActionTester ws = new WsActionTester(new SearchAction(index));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
index c7de68eb00f..e0e92cbd334 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
@@ -74,7 +74,7 @@ public class QProfileComparisonTest {
ruleActivator = new RuleActivator(
System2.INSTANCE,
db,
- new RuleIndex(esTester.client()),
+ new RuleIndex(esTester.client(), System2.INSTANCE),
new RuleActivatorContextFactory(db),
new TypeValidations(singletonList(new IntegerTypeValidation())),
new ActiveRuleIndexer(db, esTester.client()),
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java
index 3e76d1a83f3..ef48fb24dcf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java
@@ -83,7 +83,7 @@ public class RuleActivatorTest {
public EsTester es = new EsTester(RuleIndexDefinition.createForTest(new MapSettings().asConfig()));
@Rule
public UserSessionRule userSession = UserSessionRule.standalone();
- private RuleIndex ruleIndex = new RuleIndex(es.client());
+ private RuleIndex ruleIndex = new RuleIndex(es.client(), system2);
private RuleActivatorContextFactory contextFactory = new RuleActivatorContextFactory(db.getDbClient());
private ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(db.getDbClient(), es.client());
private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), db.getDbClient());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
index 0d13b987845..0b42aa38b60 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
@@ -104,7 +104,7 @@ public class ChangeParentActionTest {
dbClient = db.getDbClient();
dbSession = db.getSession();
EsClient esClient = esTester.client();
- ruleIndex = new RuleIndex(esClient);
+ ruleIndex = new RuleIndex(esClient, System2.INSTANCE);
ruleIndexer = new RuleIndexer(esClient, dbClient);
activeRuleIndexer = new ActiveRuleIndexer(dbClient, esClient);
RuleActivatorContextFactory ruleActivatorContextFactory = new RuleActivatorContextFactory(dbClient);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
index a64522226a9..bb1d60400d6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
@@ -90,7 +90,7 @@ public class CreateActionTest {
private DbClient dbClient = db.getDbClient();
private DbSession dbSession = db.getSession();
- private RuleIndex ruleIndex = new RuleIndex(es.client());
+ private RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE);
private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), dbClient);
private ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(dbClient, es.client());
private ProfileImporter[] profileImporters = createImporters();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
index af5979d4dd9..ec5e34aa621 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
@@ -101,7 +101,7 @@ public class InheritanceActionTest {
ruleActivator = new RuleActivator(
System2.INSTANCE,
dbClient,
- new RuleIndex(esClient),
+ new RuleIndex(esClient, System2.INSTANCE),
new RuleActivatorContextFactory(dbClient),
new TypeValidations(new ArrayList<>()),
activeRuleIndexer,
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
index 4c7be42f5cf..16616f424d0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
@@ -84,7 +84,7 @@ public class QProfilesWsMediumTest {
private DbClient dbClient = dbTester.getDbClient();
private DbSession dbSession = dbTester.getSession();
- private RuleIndex ruleIndex = new RuleIndex(esTester.client());
+ private RuleIndex ruleIndex = new RuleIndex(esTester.client(), System2.INSTANCE);
private RuleIndexer ruleIndexer = new RuleIndexer(esTester.client(), dbClient);
private ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(dbClient, esTester.client());
private RuleActivatorContextFactory ruleActivatorContextFactory = new RuleActivatorContextFactory(dbClient);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
index 52d23cd5a7c..4ec5fb1230e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
@@ -28,6 +28,7 @@ import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.DateUtils;
+import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.rule.RuleDefinitionDto;
@@ -73,7 +74,7 @@ public class ShowActionTest {
private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), db.getDbClient());
private ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(db.getDbClient(), es.client());
- private RuleIndex ruleIndex = new RuleIndex(es.client());
+ private RuleIndex ruleIndex = new RuleIndex(es.client(), System2.INSTANCE);
private WsActionTester ws = new WsActionTester(
new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db)), LANGUAGES, ruleIndex));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
index b3202d0d02e..8813cbbf968 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
@@ -101,7 +101,7 @@ public class RegisterRulesTest {
public void before() {
when(system.now()).thenReturn(DATE1.getTime());
ruleIndexer = new RuleIndexer(esTester.client(), dbClient);
- ruleIndex = new RuleIndex(esTester.client());
+ ruleIndex = new RuleIndex(esTester.client(), system);
activeRuleIndexer = new ActiveRuleIndexer(dbClient, esTester.client());
defaultOrganization = dbTester.getDefaultOrganization();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java
index 3e0c0cb7cdb..90c3f9ad644 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java
@@ -68,7 +68,7 @@ public class RuleCreatorTest {
@Rule
public EsTester es = new EsTester(new RuleIndexDefinition(new MapSettings().asConfig()));
- private RuleIndex ruleIndex = new RuleIndex(es.client());
+ private RuleIndex ruleIndex = new RuleIndex(es.client(), system2);
private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), dbTester.getDbClient());
private DbSession dbSession = dbTester.getSession();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java
index ed78fbc9f5f..65a83e1a8c5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java
@@ -79,7 +79,7 @@ public class RuleUpdaterTest {
@Rule
public EsTester es = new EsTester(new RuleIndexDefinition(new MapSettings().asConfig()));
- private RuleIndex ruleIndex = new RuleIndex(es.client());
+ private RuleIndex ruleIndex = new RuleIndex(es.client(), system2);
private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), db.getDbClient());
private DbSession dbSession = db.getSession();
private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java
index 0c0f15ee884..9f295b6aa76 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java
@@ -104,7 +104,7 @@ public class RuleIndexTest {
public void setUp() {
ruleIndexer = new RuleIndexer(es.client(), db.getDbClient());
activeRuleIndexer = new ActiveRuleIndexer(db.getDbClient(), es.client());
- underTest = new RuleIndex(es.client());
+ underTest = new RuleIndex(es.client(), system2);
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
index 009f1c818a7..a2c0897b8c7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
@@ -106,7 +106,7 @@ public class SearchActionTest {
public EsTester es = new EsTester(new RuleIndexDefinition(new MapSettings().asConfig()));
private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private RuleIndex ruleIndex = new RuleIndex(es.client());
+ private RuleIndex ruleIndex = new RuleIndex(es.client() ,system2);
private RuleIndexer ruleIndexer = new RuleIndexer(es.client(), db.getDbClient());
private ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(db.getDbClient(), es.client());
private Languages languages = LanguageTesting.newLanguages(JAVA, "js");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java
index 29caf1b717e..4c5971a322d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java
@@ -25,6 +25,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
@@ -54,7 +55,7 @@ public class TagsActionTest {
private DbClient dbClient = db.getDbClient();
private EsClient esClient = es.client();
- private RuleIndex ruleIndex = new RuleIndex(esClient);
+ private RuleIndex ruleIndex = new RuleIndex(esClient, System2.INSTANCE);
private RuleIndexer ruleIndexer = new RuleIndexer(esClient, dbClient);
private WsActionTester ws = new WsActionTester(new org.sonar.server.rule.ws.TagsAction(ruleIndex, dbClient, TestDefaultOrganizationProvider.from(db)));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java b/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
index 091be0cd577..b62eef280f1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
@@ -99,8 +99,8 @@ public class TelemetryDaemonTest {
private ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(db.getDbClient(), es.client());
private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), es.client());
- private TelemetryDaemon underTest = new TelemetryDaemon(new TelemetryDataLoader(server, db.getDbClient(), pluginRepository, new UserIndex(es.client()),
- new ProjectMeasuresIndex(es.client(), null)), client, settings.asConfig(), internalProperties, system2);
+ private TelemetryDaemon underTest = new TelemetryDaemon(new TelemetryDataLoader(server, db.getDbClient(), pluginRepository, new UserIndex(es.client(), system2),
+ new ProjectMeasuresIndex(es.client(), null, system2)), client, settings.asConfig(), internalProperties, system2);
@After
public void tearDown() throws Exception {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java
index c478ab3ab57..a277b42399c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java
@@ -24,6 +24,7 @@ import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.utils.System2;
import org.sonar.server.es.EsTester;
import org.sonar.server.es.SearchOptions;
@@ -36,7 +37,7 @@ public class TestIndexTest {
@Rule
public EsTester es = new EsTester(new TestIndexDefinition(new MapSettings().asConfig()));
- TestIndex underTest = new TestIndex(es.client());
+ TestIndex underTest = new TestIndex(es.client(), System2.INSTANCE);
@Test
public void coveredFiles() throws Exception {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
index 8a36be5bfa8..5a6d6606fe0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
@@ -24,6 +24,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
import org.sonar.core.util.Uuids;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
@@ -58,7 +59,7 @@ public class CoveredFilesActionTest {
@Rule
public DbTester db = DbTester.create();
- private TestIndex testIndex = new TestIndex(es.client());
+ private TestIndex testIndex = new TestIndex(es.client(), System2.INSTANCE);
private TestIndexer testIndexer = new TestIndexer(db.getDbClient(), es.client());
private WsActionTester ws = new WsActionTester(new CoveredFilesAction(db.getDbClient(), testIndex, userSession));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
index 53b07b273f5..28e4986f50e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
@@ -25,6 +25,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
@@ -74,7 +75,7 @@ public class ListActionTest {
private DbClient dbClient = db.getDbClient();
- private TestIndex testIndex = new TestIndex(es.client());
+ private TestIndex testIndex = new TestIndex(es.client(), System2.INSTANCE);
private TestIndexer testIndexer = new TestIndexer(db.getDbClient(), es.client());
private ComponentDto project;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java
index f7026e2958f..1e150e0a4c4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java
@@ -26,6 +26,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.utils.System2;
import org.sonar.server.es.EsTester;
import org.sonar.server.es.SearchOptions;
@@ -51,7 +52,7 @@ public class UserIndexTest {
@Before
public void setUp() {
- underTest = new UserIndex(esTester.client());
+ underTest = new UserIndex(esTester.client(), System2.INSTANCE);
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
index 704dc379de7..e6e6d81463a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
@@ -77,7 +77,7 @@ public class CreateActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private UserIndex index = new UserIndex(esTester.client());
+ private UserIndex index = new UserIndex(esTester.client(), System2.INSTANCE);
private UserIndexer userIndexer = new UserIndexer(db.getDbClient(), esTester.client());
private GroupDto defaultGroupInDefaultOrg;
private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
index b4ac5d581e1..d7b05746b5f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
@@ -83,7 +83,7 @@ public class DeactivateActionTest {
public UserSessionRule userSession = UserSessionRule.standalone();
private DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private UserIndex index = new UserIndex(esTester.client());
+ private UserIndex index = new UserIndex(esTester.client(), system2);
private DbClient dbClient = db.getDbClient();
private UserIndexer userIndexer = new UserIndexer(dbClient, esTester.client());
private DbSession dbSession = db.getSession();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java
index 2001d838249..ccb5a9a21c4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java
@@ -66,7 +66,7 @@ public class SearchActionTest {
private DbClient dbClient = db.getDbClient();
private DbSession dbSession = db.getSession();
- private UserIndex index = new UserIndex(esTester.client());
+ private UserIndex index = new UserIndex(esTester.client(), system2);
private UserIndexer userIndexer = new UserIndexer(dbClient, esTester.client());
private WsTester ws = new WsTester(new UsersWs(new SearchAction(userSession, index, dbClient, new AvatarResolverImpl())));