]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10008 Make date facet tests independent from the machine's time zone
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Mon, 23 Oct 2017 08:49:46 +0000 (10:49 +0200)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Tue, 24 Oct 2017 15:40:56 +0000 (17:40 +0200)
53 files changed:
server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndex.java
server/sonar-server/src/main/java/org/sonar/server/es/Facets.java
server/sonar-server/src/main/java/org/sonar/server/es/SearchIdResult.java
server/sonar-server/src/main/java/org/sonar/server/es/SearchResult.java
server/sonar-server/src/main/java/org/sonar/server/issue/webhook/IssueChangeWebhookImpl.java
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java
server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java
server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndex.java
server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndex.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/issue/ScmAccountToUserLoaderTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexDebtTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/webhook/IssueChangeWebhookImplTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/TagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/OrganizationCreationImplTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/RemoveMemberActionTest.java
server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileComparisonTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/QProfilesWsMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ShowActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RuleUpdaterTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/TagsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/test/ws/CoveredFilesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java
sonar-plugin-api/src/main/java/org/sonar/api/utils/internal/TestSystem2.java

index 8a492913ef4865f9a2559708078afe39f1855e28..6f5190d130f78d7876c4a96092f28459fe836b27 100644 (file)
@@ -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) {
index 574ceb158e7766a056144de0607f355c8c2651a0..a2e99960eb6ea1f68937b003b7cc4c6e9bbeb9ac 100644 (file)
 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()));
   }
index 41787359a6879d282431307ecf33591c3a4ad3ea..a68ca5915339e8ada079f937f42fcd9c3e63606f 100644 (file)
@@ -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);
   }
index 3cde890717c5ca393f0d0d6d17e1c0cfdfe33d98..cf3c1fcd5ea75f98ab608fc555934ee48ecf0852 100644 (file)
@@ -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);
   }
index ad587e4326c7ee1274ea9e8825ed5d9131b83bf6..b379eb629a7b32208ed22101ebbc96f5313b2171 100644 (file)
@@ -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()
index f4883716271d4cdc33858be17d91290bb2e01912..5293f0491c96c72424737a718dfe9841a6082139 100644 (file)
@@ -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) {
index dc7c3db668f6450d927b71deabfcaf0eea360cc6..53119df0569f6824422afe23015a319fc24d586a 100644 (file)
@@ -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() {
index 5825312645e86f85f090576bbb335b50b1b4f40b..87e6454194aa1bd42b4db2112d58555e8c140bcd 100644 (file)
@@ -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());
   }
 
   /**
index 90dd3cc000d4b2a9cb08f0599bd6879834976b85..63ead033573783f8a90efa7d024228debce65331 100644 (file)
@@ -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());
   }
 }
index 0ddb194e46d39cd6f89d82b9bfd3a01fdccff17e..cd937915bcccc73e21fa73e191c0f33807b9e5a4 100644 (file)
@@ -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());
   }
 
 }
index b26cecc240c53716dd991d5a69beff0995fe54cf..e637593bbd41f0065aa8c861646bebaf0c66e5ab 100644 (file)
@@ -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() {
index bbbb51a2d4367d69e7dabc52e3b7fffc9f165dbf..75d2d4ce7bf9effc7e81cdfb25cc7757f9e9c047 100644 (file)
@@ -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;
 
index 79689b048f5933a32144e70330cd1fe5a0c464bd..3a6cc5e891b083dad81f23e269febeb7c5a3f403 100644 (file)
@@ -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;
 
index 1428b905147f296314c8cac5d4a0c65b884cf375..ed3a6786785ac2135068bd1bbe81a2df6f9dfd7b 100644 (file)
@@ -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(
index 670893dfed96940fd2da56e029f475d69990cb86..7858f907b8f32d303ddce55c871a15953f95468b 100644 (file)
@@ -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);
index e8a08221bf27e2da58462bc672fc3675a5123273..77ec01b55d71b1c0ccedbacb2faf7b767a792933 100644 (file)
@@ -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());
index 2e13410c33b489219095a136a227f020f15c8edc..4b283b2fd786f2f91f4d12ff8170ce4ebae79382 100644 (file)
@@ -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));
index acc20812f26f58d98004da490e607af75fc13df7..25cf465791579928d6954500c4058e5c23f3b94d 100644 (file)
@@ -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);
   }
index fcd7301bffbadaf618e35ae2870c6db9c6cf3107..95b7232d1026abe2589178cf01288f04834be98c 100644 (file)
@@ -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() {
index ca0539ed339536f2d58c06909a30afd10646aa0e..51309b4c317f78d8331c961e1d9541f855b46c19 100644 (file)
@@ -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() {
index 14bea4cc667c86ec9c1a52516c126efcfc36f14f..c8e3753999c3bbbcf94efb99638f0cdd4f5e4033 100644 (file)
@@ -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;
index 3c54528d4bb1bf052ab09277f2b4ac6a03415cc7..3241e73902d0d37bf444645d0d97e082d6689886 100644 (file)
@@ -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;
index c63fdb68e4c96deca002a53af2cf0ec33c7f0aa4..c2dd80e8daf15820ef91a30c2cb7656e7093e291 100644 (file)
@@ -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() {
index 6673302c3dfad9a6d4d481162ec41e4690b95458..3dc91491a63aa565bebe92b2bdb125301165c5a8 100644 (file)
@@ -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() {
index 6ba745d2b4dec8e0d7d0781102b347f6b1fb6385..675444ac1ef6b42999df4df4ee938478f1049596 100644 (file)
@@ -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);
index d5aa40abea1882f1a48f3149b8c41ca080d0c228..ffd72018d660b0ed119fa02eddaeb3f479c378b2 100644 (file)
@@ -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();
index e387274390f4885ec8d1982e6ad9e654bace00da..0806889e0ee397551ca717c78ffe68873c242b68 100644 (file)
@@ -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);
index cdbe6cfab2247a163295a4033ab665c2bddd1c3f..95b37cc554da9b0a43cd97b5d3db8288ef1ae2de 100644 (file)
@@ -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));
index a6bfbb750497afa8c0cc26f88e5bd58fa5c4cf2e..f4c28e385047145bc1a2759292e1d5b7992baaa1 100644 (file)
@@ -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));
index ecf87cde61fa4545219f48ca20a0efda117c0991..584dadca43b800c070a9ee31a7463c8e6f97c201 100644 (file)
@@ -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();
 
index ecefab80741fd7b6f86c78f3637f3f83b2e4f20e..640295fd6af7aa01b49a2188dc04ae07d3e48553 100644 (file)
@@ -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));
 
index c7de68eb00faf9655cfe3219c6cbe0396adb858e..e0e92cbd3344c292ddfc51340ca7f3f07b276a20 100644 (file)
@@ -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()),
index 3e76d1a83f3ab6404c362bae42125085f2c22b6a..ef48fb24dcf3dfc13247eb69608dbeee24362a8d 100644 (file)
@@ -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());
index 0d13b98784557bb7b9198bdbd7986ade225ca041..0b42aa38b608e1752691546737f6c1ba4e6a3ad7 100644 (file)
@@ -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);
index a64522226a9bd70ed8edf079f49ad8abc9d60101..bb1d60400d6e66de9408ba67cba68be5dbdbf103 100644 (file)
@@ -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();
index af5979d4dd9b35a82be732e4482f95591c63e443..ec5e34aa621a3d80f88cc796da1c49cb613799c6 100644 (file)
@@ -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,
index 4c7be42f5cf360eb7ff9d4030c12ab07ab687767..16616f424d0c9e4340561fe5ed342e487716c150 100644 (file)
@@ -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);
index 52d23cd5a7cd7f92cd5d91b12c705f8e2271f53e..4ec5fb1230e282fee5a89632eda3c51e5ce69e75 100644 (file)
@@ -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));
index b3202d0d02e311367f447730064a78bbad77b656..8813cbbf9682c685bec4ee866a98935dc058e588 100644 (file)
@@ -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();
   }
index 3e0c0cb7cdbffdcc3e091b2eeffd405f36b5d659..90c3f9ad6441cd16ceda20f56e0a90b57649e30a 100644 (file)
@@ -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();
 
index ed78fbc9f5ffe79f4f07b0e375cbaced802102e2..65a83e1a8c53770b8c6a859b3b6f67ed77cc9339 100644 (file)
@@ -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);
index 0c0f15ee884c7d0fa790d95e8baf3804dc331e0a..9f295b6aa76e9c8ae9dff426afec0cdc0cc77b86 100644 (file)
@@ -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
index 009f1c818a7cc7ee5697b2f72554e71b5ff71a29..a2c0897b8c7c0b39349e0153e43007a7eef3fec6 100644 (file)
@@ -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");
index 29caf1b717e576885cbee7722a5258184a09ba06..4c5971a322dbd23bc110654cf69a23239c4eb581 100644 (file)
@@ -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)));
index 091be0cd577dc1248b19ccd926b8d3af91a0ed60..b62eef280f183406fa74b5e7af8a07f19f86448b 100644 (file)
@@ -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 {
index c478ab3ab572b70e7de994d59d9509248a43bdc6..a277b42399c741b31e9cea107ec33057a422f8c0 100644 (file)
@@ -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 {
index 8a36be5bfa85634b0ad26ed89c0e27db56fbfbc4..5a6d6606fe0d66601301a1ff28cb251df2bec700 100644 (file)
@@ -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));
index 53b07b273f5a507737fde740f65e3b24db57076c..28e4986f50e837853e16d4c3e107a4b8cbaa99b3 100644 (file)
@@ -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;
index f7026e2958f9bf9041ea4859bb00149cbaf8ff25..1e150e0a4c4b5397d0e2ec800b162aff05ab4660 100644 (file)
@@ -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
index 704dc379de70d1370a8c6dd1ffbda87f070c7e6c..e6e6d81463a9add29327a3f184c120a18f1254b1 100644 (file)
@@ -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);
index b4ac5d581e1001a0e43109fd063a966087f98f80..d7b05746b5f639d5ef7d54819728a308ddf289af 100644 (file)
@@ -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();
index 2001d838249a0024190e8b2bac09ef95925ff266..ccb5a9a21c421b9349add17abf73aaad9112b53c 100644 (file)
@@ -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())));
 
index 11695d312009123038949d7a7eefef0aa9ed6864..2f0e1828fe2a27c957e6fd71e4af8f7cb4de8c05 100644 (file)
  */
 package org.sonar.api.utils.internal;
 
+import java.util.TimeZone;
 import org.sonar.api.utils.System2;
 
 public class TestSystem2 extends System2 {
 
   private long now = 0L;
+  private TimeZone defaultTimeZone = getDefaultTimeZone();
 
   public TestSystem2 setNow(long l) {
     this.now = l;
@@ -37,4 +39,14 @@ public class TestSystem2 extends System2 {
     }
     return now;
   }
+
+  public TestSystem2 setDefaultTimeZone(TimeZone defaultTimeZone) {
+    this.defaultTimeZone = defaultTimeZone;
+    return this;
+  }
+
+  @Override
+  public TimeZone getDefaultTimeZone() {
+    return defaultTimeZone;
+  }
 }