aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-08 18:34:17 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-09-12 14:11:58 +0200
commit42f50979169d897b102d2c3fbab708286178d381 (patch)
tree647a7188a01fe97bb018c666c778f676ddaa1e65 /server
parented88db984397af686dcf8333e2f1e31cade1063e (diff)
downloadsonarqube-42f50979169d897b102d2c3fbab708286178d381.tar.gz
sonarqube-42f50979169d897b102d2c3fbab708286178d381.zip
SONAR-7908 allow web followers to index docs into Elasticsearch
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java2
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/es/EsIndexerEnabler.java49
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/es/package-info.java23
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/es/EsIndexerEnablerTest.java61
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java46
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java1
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ApplyPermissionsStepTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/IndexTestsStepTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java15
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java35
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.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/rule/RegisterRulesTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleDeleterMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/RuleServiceMediumTest.java1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java34
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java12
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java2
-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
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java6
42 files changed, 59 insertions, 309 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index 43386927a57..279b4e5bc4e 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -44,7 +44,6 @@ import org.sonar.ce.CeHttpModule;
import org.sonar.ce.CeQueueModule;
import org.sonar.ce.CeTaskCommonsModule;
import org.sonar.ce.db.ReadOnlyPropertiesDao;
-import org.sonar.ce.es.EsIndexerEnabler;
import org.sonar.ce.platform.ComputeEngineExtensionInstaller;
import org.sonar.ce.settings.ProjectSettingsFactory;
import org.sonar.ce.user.CeUserSession;
@@ -398,7 +397,6 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
private static Object[] startupComponents() {
return new Object[] {
- EsIndexerEnabler.class,
LogServerId.class,
ServerLifecycleNotifier.class,
PurgeCeActivities.class,
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/es/EsIndexerEnabler.java b/server/sonar-ce/src/main/java/org/sonar/ce/es/EsIndexerEnabler.java
deleted file mode 100644
index f5e210dd286..00000000000
--- a/server/sonar-ce/src/main/java/org/sonar/ce/es/EsIndexerEnabler.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.ce.es;
-
-import org.picocontainer.Startable;
-import org.sonar.server.es.BaseIndexer;
-import org.sonar.server.es.IndexerStartupTask;
-
-/**
- * Replaces the {@link IndexerStartupTask} to enable indexers but without triggering a full
- * indexation (it's the WebServer's responsibility).
- */
-public class EsIndexerEnabler implements Startable {
-
- private final BaseIndexer[] indexers;
-
- public EsIndexerEnabler(BaseIndexer[] indexers) {
- this.indexers = indexers;
- }
-
- @Override
- public void start() {
- for (BaseIndexer indexer : indexers) {
- indexer.setEnabled(true);
- }
- }
-
- @Override
- public void stop() {
- // nothing to do at stop
- }
-}
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/es/package-info.java b/server/sonar-ce/src/main/java/org/sonar/ce/es/package-info.java
deleted file mode 100644
index 9a869a3cced..00000000000
--- a/server/sonar-ce/src/main/java/org/sonar/ce/es/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.ce.es;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/es/EsIndexerEnablerTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/es/EsIndexerEnablerTest.java
deleted file mode 100644
index 984e9883f0b..00000000000
--- a/server/sonar-ce/src/test/java/org/sonar/ce/es/EsIndexerEnablerTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.ce.es;
-
-import org.junit.After;
-import org.junit.Test;
-import org.sonar.server.activity.index.ActivityIndexer;
-import org.sonar.server.es.BaseIndexer;
-import org.sonar.server.issue.index.IssueAuthorizationIndexer;
-import org.sonar.server.issue.index.IssueIndexer;
-import org.sonar.server.test.index.TestIndexer;
-import org.sonar.server.user.index.UserIndexer;
-import org.sonar.server.view.index.ViewIndexer;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class EsIndexerEnablerTest {
- private TestIndexer testIndexer = mock(TestIndexer.class);
- private IssueAuthorizationIndexer issueAuthorizationIndexer = mock(IssueAuthorizationIndexer.class);
- private IssueIndexer issueIndexer = mock(IssueIndexer.class);
- private UserIndexer userIndexer = mock(UserIndexer.class);
- private ViewIndexer viewIndexer = mock(ViewIndexer.class);
- private ActivityIndexer activityIndexer = mock(ActivityIndexer.class);
- private EsIndexerEnabler underTest = new EsIndexerEnabler(new BaseIndexer[]{testIndexer, issueAuthorizationIndexer, issueIndexer, userIndexer, viewIndexer, activityIndexer});
-
- @After
- public void tearDown() {
- underTest.stop();
-
- }
-
- @Test
- public void start_enables_all_indexers() {
- underTest.start();
-
- verify(testIndexer).setEnabled(true);
- verify(issueAuthorizationIndexer).setEnabled(true);
- verify(issueIndexer).setEnabled(true);
- verify(userIndexer).setEnabled(true);
- verify(viewIndexer).setEnabled(true);
- verify(activityIndexer).setEnabled(true);
- }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java
index 53af7750c8c..629f08cbe93 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/BaseIndexer.java
@@ -37,17 +37,6 @@ public abstract class BaseIndexer implements Startable {
protected final EsClient esClient;
private volatile long lastUpdatedAt = -1L;
- /**
- * Indexers are disabled during server startup, to avoid too many consecutive refreshes of the same index
- * An example is RegisterQualityProfiles. If {@link org.sonar.server.activity.index.ActivityIndexer} is enabled by
- * default during startup, then each new activated rule generates a bulk request with a single document and then
- * asks for index refresh -> big performance hit.
- *
- * Indices are populated and refreshed when all startup components have been executed. See
- * {@link IndexerStartupTask}
- */
- private boolean enabled = false;
-
protected BaseIndexer(EsClient client, long threadKeepAliveSeconds, String indexName, String typeName,
String dateFieldName) {
this.indexName = indexName;
@@ -59,23 +48,21 @@ public abstract class BaseIndexer implements Startable {
}
public void index(final IndexerTask task) {
- if (enabled) {
- final long requestedAt = System.currentTimeMillis();
- Future submit = executor.submit(() -> {
- if (lastUpdatedAt == -1L) {
- lastUpdatedAt = esClient.getMaxFieldValue(indexName, typeName, dateFieldName);
- }
- if (requestedAt > lastUpdatedAt) {
- long l = task.index(lastUpdatedAt);
- // l can be 0 if no documents were indexed
- lastUpdatedAt = Math.max(l, lastUpdatedAt);
- }
- });
- try {
- Uninterruptibles.getUninterruptibly(submit);
- } catch (ExecutionException e) {
- Throwables.propagate(e);
+ final long requestedAt = System.currentTimeMillis();
+ Future submit = executor.submit(() -> {
+ if (lastUpdatedAt == -1L) {
+ lastUpdatedAt = esClient.getMaxFieldValue(indexName, typeName, dateFieldName);
+ }
+ if (requestedAt > lastUpdatedAt) {
+ long l = task.index(lastUpdatedAt);
+ // l can be 0 if no documents were indexed
+ lastUpdatedAt = Math.max(l, lastUpdatedAt);
}
+ });
+ try {
+ Uninterruptibles.getUninterruptibly(submit);
+ } catch (ExecutionException e) {
+ Throwables.propagate(e);
}
}
@@ -85,11 +72,6 @@ public abstract class BaseIndexer implements Startable {
protected abstract long doIndex(long lastUpdatedAt);
- public BaseIndexer setEnabled(boolean b) {
- this.enabled = b;
- return this;
- }
-
@Override
public void start() {
// nothing to do at startup
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java b/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
index e3d23474baa..e983fc5c4ec 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
@@ -61,20 +61,20 @@ public class IndexerStartupTask {
public void execute() {
if (!settings.getBoolean("sonar.internal.es.disableIndexes")) {
LOG.info("Index activities");
- activityIndexer.setEnabled(true).index();
+ activityIndexer.index();
LOG.info("Index issues");
- issueAuthorizationIndexer.setEnabled(true).index();
- issueIndexer.setEnabled(true).index();
+ issueAuthorizationIndexer.index();
+ issueIndexer.index();
LOG.info("Index tests");
- testIndexer.setEnabled(true).index();
+ testIndexer.index();
LOG.info("Index users");
- userIndexer.setEnabled(true).index();
+ userIndexer.index();
LOG.info("Index views");
- viewIndexer.setEnabled(true).index();
+ viewIndexer.index();
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java
index 0d49dee0587..99010504bd1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java
@@ -20,7 +20,6 @@
package org.sonar.server.platform.platformlevel;
import org.sonar.server.app.ProcessCommandWrapper;
-import org.sonar.server.es.BaseIndexer;
import org.sonar.server.es.IndexerStartupTask;
import org.sonar.server.issue.filter.RegisterIssueFilters;
import org.sonar.server.platform.ServerLifecycleNotifier;
@@ -80,7 +79,6 @@ public class PlatformLevelStartup extends PlatformLevel {
getOptional(IndexerStartupTask.class).ifPresent(IndexerStartupTask::execute);
get(ServerLifecycleNotifier.class).notifyStart();
get(ProcessCommandWrapper.class).notifyOperational();
- getAll(BaseIndexer.class).forEach(i -> i.setEnabled(true));
}
});
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java
index b65ed63e4d9..dae95a37cd1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java
@@ -89,7 +89,6 @@ public class RegisterQualityProfiles {
Profiler profiler = Profiler.create(Loggers.get(getClass())).startInfo("Register quality profiles");
DbSession session = dbClient.openSession(false);
try {
- activeRuleIndexer.setEnabled(true);
List<ActiveRuleChange> changes = new ArrayList<>();
ListMultimap<String, RulesProfile> profilesByLanguage = profilesByLanguage();
for (String language : profilesByLanguage.keySet()) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
index 9da3af25f22..bf083f0761e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -106,8 +106,7 @@ public class RegisterRules implements Startable {
List<RuleDto> activeRules = processRemainingDbRules(allRules.values(), session);
List<ActiveRuleChange> changes = removeActiveRulesOnStillExistingRepositories(session, activeRules, context);
session.commit();
- ruleIndexer.setEnabled(true).index();
- activeRuleIndexer.setEnabled(true);
+ ruleIndexer.index();
activeRuleIndexer.index(changes);
profiler.stopDebug();
} finally {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
index 5090295ae9b..d164307ceea 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
@@ -89,7 +89,7 @@ public class RuleCreator {
}
dbSession.commit();
- ruleIndexer.setEnabled(true).index();
+ ruleIndexer.index();
return customRuleKey;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
index fd0ef2727a9..667930f127e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
@@ -96,7 +96,7 @@ public class RuleUpdater {
update(dbSession, context.rule);
updateParameters(dbSession, update, context);
dbSession.commit();
- ruleIndexer.setEnabled(true).index();
+ ruleIndexer.index();
return true;
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
index eb946583b3f..ecaa6874dcf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/activity/ActivityServiceTest.java
@@ -58,7 +58,6 @@ public class ActivityServiceTest {
DbClient dbClient = db.getDbClient();
ActivityIndexer indexer = new ActivityIndexer(dbClient, es.client());
// indexers are disabled by default
- indexer.setEnabled(true);
service = new ActivityService(dbClient, indexer, userSession);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ApplyPermissionsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ApplyPermissionsStepTest.java
index ff5b54931b6..ad50ac5fd0b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ApplyPermissionsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ApplyPermissionsStepTest.java
@@ -89,7 +89,6 @@ public class ApplyPermissionsStepTest extends BaseStepTest {
dbSession = dbClient.openSession(false);
issueAuthorizationIndexer = new IssueAuthorizationIndexer(dbClient, esTester.client());
- issueAuthorizationIndexer.setEnabled(true);
step = new ApplyPermissionsStep(dbClient, dbIdsRepository, issueAuthorizationIndexer, new PermissionRepository(dbClient, settings), treeRootHolder);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/IndexTestsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/IndexTestsStepTest.java
index 8e6eb0ac922..fcfb197ab14 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/IndexTestsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/IndexTestsStepTest.java
@@ -55,7 +55,6 @@ public class IndexTestsStepTest extends BaseStepTest {
@Override
protected ComputationStep step() {
TestIndexer testIndexer = new TestIndexer(dbClient, esTester.client());
- testIndexer.setEnabled(true);
return new IndexTestsStep(testIndexer, treeRootHolder);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
index 37153200261..7ee1c7eae4d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
@@ -82,7 +82,6 @@ public class IssueServiceMediumTest {
session = db.openSession(false);
service = tester.get(IssueService.class);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
index aadc7ebde80..be6d55fe3c8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
@@ -53,20 +53,11 @@ public class IssueIndexerTest {
@Test
public void index_nothing() {
IssueIndexer indexer = createIndexer();
- indexer.index(Iterators.<IssueDoc>emptyIterator());
+ indexer.index(Iterators.emptyIterator());
assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isEqualTo(0L);
}
@Test
- public void index_nothing_if_disabled() {
- dbTester.prepareDbUnit(getClass(), "index.xml");
-
- createIndexer().setEnabled(false).index();
-
- assertThat(esTester.countDocuments("issues", "issue")).isEqualTo(0);
- }
-
- @Test
public void index() {
dbTester.prepareDbUnit(getClass(), "index.xml");
@@ -165,9 +156,7 @@ public class IssueIndexerTest {
}
private IssueIndexer createIndexer() {
- IssueIndexer indexer = new IssueIndexer(new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client());
- indexer.setEnabled(true);
- return indexer;
+ return new IssueIndexer(new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client());
}
private void addIssue(String projectUuid, String issueKey) throws Exception {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
index cab4790cd1c..3d4a045c2cf 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
@@ -89,9 +89,7 @@ public class QProfileBackuperMediumTest {
db = tester.get(DbClient.class);
dbSession = db.openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
// create pre-defined rules
RuleDto xooRule1 = newXooX1().setSeverity("MINOR").setLanguage("xoo");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java
index b7b1131dc20..be5c393671a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileCopierMediumTest.java
@@ -73,9 +73,7 @@ public class QProfileCopierMediumTest {
index = tester.get(ActiveRuleIndex.class);
copier = tester.get(QProfileCopier.class);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
// create pre-defined rules
RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java
index 9fed6b82926..dfe02d8c683 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java
@@ -79,7 +79,6 @@ public class QProfileExportersTest {
exporters = tester.get(QProfileExporters.class);
loader = tester.get(QProfileLoader.class);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
index 80e26aff327..836f995a6f9 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryMediumTest.java
@@ -78,9 +78,7 @@ public class QProfileFactoryMediumTest {
factory = tester.get(QProfileFactory.class);
activeRuleIndex = tester.get(ActiveRuleIndex.class);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
index a515b80bb2b..e24f36df565 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
@@ -108,9 +108,7 @@ public class RuleActivatorMediumTest {
ruleActivator = tester.get(RuleActivator.class);
activeRuleIndex = tester.get(ActiveRuleIndex.class);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
// create pre-defined rules
RuleDto javaRule = newDto(RuleKey.of("squid", "j1"))
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
index de3fd69d1ee..611bf999d87 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
@@ -21,7 +21,6 @@ package org.sonar.server.qualityprofile.index;
import com.google.common.collect.Iterators;
import java.util.Arrays;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.config.MapSettings;
@@ -47,7 +46,6 @@ import static org.sonar.server.qualityprofile.index.ActiveRuleDocTesting.newDoc;
import static org.sonar.server.rule.index.RuleIndexDefinition.INDEX;
import static org.sonar.server.rule.index.RuleIndexDefinition.TYPE_ACTIVE_RULE;
-
public class ActiveRuleIndexerTest {
static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1;
@@ -63,28 +61,11 @@ public class ActiveRuleIndexerTest {
@Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
- ActiveRuleIndexer indexer;
-
- @Before
- public void setUp() {
- indexer = new ActiveRuleIndexer(dbTester.getDbClient(), esTester.client());
- indexer.setEnabled(true);
- }
+ private ActiveRuleIndexer indexer = new ActiveRuleIndexer(dbTester.getDbClient(), esTester.client());
@Test
public void index_nothing() {
- indexer.index(Iterators.<ActiveRuleDoc>emptyIterator());
- assertThat(esTester.countDocuments(INDEX, TYPE_ACTIVE_RULE)).isZero();
- }
-
- @Test
- public void index_nothing_if_disabled() {
- dbTester.prepareDbUnit(getClass(), "index.xml");
-
- ActiveRuleIndexer indexer = new ActiveRuleIndexer(dbTester.getDbClient(), esTester.client());
- indexer.setEnabled(false);
- indexer.index();
-
+ indexer.index(Iterators.emptyIterator());
assertThat(esTester.countDocuments(INDEX, TYPE_ACTIVE_RULE)).isZero();
}
@@ -111,8 +92,7 @@ public class ActiveRuleIndexerTest {
assertThat(esTester.getIds(INDEX, TYPE_ACTIVE_RULE)).containsOnly(
ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_2).toString(),
- ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_3).toString()
- );
+ ActiveRuleKey.of(QUALITY_PROFILE_KEY2, RULE_KEY_3).toString());
}
@Test
@@ -133,13 +113,11 @@ public class ActiveRuleIndexerTest {
indexer.index(Arrays.asList(
ActiveRuleChange.createFor(ACTIVATED, activeRuleKey1),
ActiveRuleChange.createFor(DEACTIVATED, activeRuleKey2),
- ActiveRuleChange.createFor(DEACTIVATED, activeRuleKey3)
- ));
+ ActiveRuleChange.createFor(DEACTIVATED, activeRuleKey3)));
assertThat(esTester.getIds(INDEX, TYPE_ACTIVE_RULE)).containsOnly(
activeRuleKey1.toString(),
- activeRuleKey4.toString()
- );
+ activeRuleKey4.toString());
}
@Test
@@ -173,8 +151,7 @@ public class ActiveRuleIndexerTest {
assertThat(esTester.getIds(INDEX, TYPE_ACTIVE_RULE)).containsOnly(
activeRule.getKey().toString(),
- activeRule2.getKey().toString()
- );
+ activeRule2.getKey().toString());
}
private void indexActiveRules(ActiveRuleDoc... docs) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
index 69c43061c52..bc0019df2e0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ChangeParentActionMediumTest.java
@@ -75,9 +75,7 @@ public class ChangeParentActionMediumTest {
wsTester = tester.get(WsTester.class);
session = db.openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
ruleIndex = tester.get(RuleIndex.class);
userSessionRule.login("gandalf").setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
index 05fe39b1b27..2a16b50a65b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
@@ -67,9 +67,7 @@ public class InheritanceActionMediumTest {
db = tester.get(DbClient.class);
session = db.openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
wsTester = new WsTester(tester.get(QProfilesWs.class));
}
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 82dd715b4b1..ef8c96a8c7a 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
@@ -86,9 +86,7 @@ public class QProfilesWsMediumTest {
session = db.openSession(false);
ruIndexer = tester.get(RuleIndexer.class);
- ruIndexer.setEnabled(true);
activeRuIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuIndexer.setEnabled(true);
}
@After
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 9d456267d05..dad23d01d4e 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
@@ -84,10 +84,8 @@ public class RegisterRulesTest {
public void before() {
when(system.now()).thenReturn(DATE1.getTime());
ruleIndexer = new RuleIndexer(dbClient, esTester.client());
- ruleIndexer.setEnabled(true);
ruleIndex = new RuleIndex(esTester.client());
activeRuleIndexer = new ActiveRuleIndexer(dbClient, esTester.client());
- activeRuleIndexer.setEnabled(true);
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
index 62ed9e3bd9b..f809c40bf96 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
@@ -71,7 +71,6 @@ public class RuleCreatorMediumTest {
tester.clearDbAndIndexes();
dbSession = tester.get(DbClient.class).openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleDeleterMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleDeleterMediumTest.java
index d9cb10cf025..22c27706a23 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleDeleterMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleDeleterMediumTest.java
@@ -66,8 +66,6 @@ public class RuleDeleterMediumTest {
@Before
public void before() {
tester.clearDbAndIndexes();
- ruleIndexer.setEnabled(true);
- activeRuleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleServiceMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleServiceMediumTest.java
index 93839de1ae7..79f86211988 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleServiceMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleServiceMediumTest.java
@@ -60,7 +60,6 @@ public class RuleServiceMediumTest {
tester.clearDbAndIndexes();
dbSession = tester.get(DbClient.class).openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java
index 03d352f3929..a4beda7ad8f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java
@@ -69,21 +69,11 @@ public class RuleIndexerTest {
@Test
public void index_nothing() {
RuleIndexer indexer = createIndexer();
- indexer.index(Iterators.<RuleDoc>emptyIterator());
+ indexer.index(Iterators.emptyIterator());
assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isEqualTo(0L);
}
@Test
- public void index_nothing_if_disabled() {
- dbClient.ruleDao().insert(dbSession, rule);
- dbSession.commit();
-
- createIndexer().setEnabled(false).index();
-
- assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isZero();
- }
-
- @Test
public void index() {
dbClient.ruleDao().insert(dbSession, rule);
dbSession.commit();
@@ -113,9 +103,7 @@ public class RuleIndexerTest {
}
private RuleIndexer createIndexer() {
- RuleIndexer indexer = new RuleIndexer(dbTester.getDbClient(), esTester.client());
- indexer.setEnabled(true);
- return indexer;
+ return new RuleIndexer(dbTester.getDbClient(), esTester.client());
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java
index b2363717888..94932aef4f2 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/RulesWsMediumTest.java
@@ -72,9 +72,7 @@ public class RulesWsMediumTest {
ws = tester.get(RulesWs.class);
session = tester.get(DbClient.class).openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
index 2d83461aafb..f1b39230adc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
@@ -88,9 +88,7 @@ public class SearchActionMediumTest {
ws = tester.get(RulesWs.class);
dbSession = tester.get(DbClient.class).openSession(false);
ruleIndexer = tester.get(RuleIndexer.class);
- ruleIndexer.setEnabled(true);
activeRuleIndexer = tester.get(ActiveRuleIndexer.class);
- activeRuleIndexer.setEnabled(true);
}
@After
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java
index c1a5705738b..afb33ed0334 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java
@@ -134,20 +134,19 @@ public class ShowActionMediumTest {
@Test
public void show_rule_with_overridden_debt() throws Exception {
- RuleDto ruleDto =
- RuleTesting.newDto(RuleKey.of("java", "S001"))
- .setName("Rule S001")
- .setDescription("Rule S001 <b>description</b>")
- .setSeverity(MINOR)
- .setStatus(RuleStatus.BETA)
- .setConfigKey("InternalKeyS001")
- .setLanguage("xoo")
- .setDefaultRemediationFunction(null)
- .setDefaultRemediationGapMultiplier(null)
- .setDefaultRemediationBaseEffort(null)
- .setRemediationFunction("LINEAR_OFFSET")
- .setRemediationGapMultiplier("5d")
- .setRemediationBaseEffort("10h");
+ RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("java", "S001"))
+ .setName("Rule S001")
+ .setDescription("Rule S001 <b>description</b>")
+ .setSeverity(MINOR)
+ .setStatus(RuleStatus.BETA)
+ .setConfigKey("InternalKeyS001")
+ .setLanguage("xoo")
+ .setDefaultRemediationFunction(null)
+ .setDefaultRemediationGapMultiplier(null)
+ .setDefaultRemediationBaseEffort(null)
+ .setRemediationFunction("LINEAR_OFFSET")
+ .setRemediationGapMultiplier("5d")
+ .setRemediationBaseEffort("10h");
ruleDao.insert(session, ruleDto);
session.commit();
session.clearCache();
@@ -278,13 +277,12 @@ public class ShowActionMediumTest {
tester.get(ActiveRuleDao.class).insertParam(session, activeRuleDto, new ActiveRuleParamDto()
.setRulesParameterId(regexParam.getId())
.setKey(regexParam.getName())
- .setValue(".*?")
- );
+ .setValue(".*?"));
session.commit();
session.clearCache();
- tester.get(RuleIndexer.class).setEnabled(true).index();
- tester.get(ActiveRuleIndexer.class).setEnabled(true).index();
+ tester.get(RuleIndexer.class).index();
+ tester.get(ActiveRuleIndexer.class).index();
WsTester.TestRequest request = wsTester.newGetRequest("api/rules", "show")
.setParam("key", ruleDto.getKey().toString())
diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java
index 00046be642e..08289f2964d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java
@@ -30,7 +30,6 @@ import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.config.MapSettings;
@@ -66,11 +65,6 @@ public class TestIndexerTest {
private TestIndexer underTest = new TestIndexer(db.getDbClient(), es.client());
- @Before
- public void setUp() {
- underTest.setEnabled(true);
- }
-
@Test
public void index_tests() throws Exception {
db.prepareDbUnit(getClass(), "db.xml");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java
index cce9baabd2b..dfc007a22d9 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/UserUpdaterTest.java
@@ -90,7 +90,7 @@ public class UserUpdaterTest {
@Before
public void setUp() {
- userIndexer = (UserIndexer) new UserIndexer(dbClient, es.client()).setEnabled(true);
+ userIndexer = new UserIndexer(dbClient, es.client());
userUpdater = new UserUpdater(newUserNotifier, settings, dbClient,
userIndexer, system2);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java
index 68f746ed4fe..79bf8a06162 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java
@@ -64,17 +64,7 @@ public class UserIndexerTest {
assertThat(doc.updatedAt()).isEqualTo(1500000000000L);
}
- @Test
- public void do_nothing_if_disabled() {
- dbTester.prepareDbUnit(getClass(), "index.xml");
-
- createIndexer().setEnabled(false).index();
- assertThat(esTester.countDocuments("users", "user")).isEqualTo(0);
- }
-
private UserIndexer createIndexer() {
- UserIndexer indexer = new UserIndexer(new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client());
- indexer.setEnabled(true);
- return indexer;
+ return new UserIndexer(new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client());
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
index 0b14e34a80d..60f8c8e6fe3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/ChangePasswordActionTest.java
@@ -95,7 +95,7 @@ public class ChangePasswordActionTest {
groupDao.insert(session, new GroupDto().setName("sonar-users"));
session.commit();
- userIndexer = (UserIndexer) new UserIndexer(dbClient, esTester.client()).setEnabled(true);
+ userIndexer = new UserIndexer(dbClient, esTester.client());
index = new UserIndex(esTester.client());
userUpdater = new UserUpdater(mock(NewUserNotifier.class), settings, dbClient, userIndexer, system2);
tester = new WsTester(new UsersWs(new ChangePasswordAction(userUpdater, userSessionRule)));
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 8f338ebb33a..9ef9707fe16 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
@@ -91,7 +91,7 @@ public class CreateActionTest {
groupDao.insert(session, new GroupDto().setName("sonar-users"));
session.commit();
- userIndexer = (UserIndexer) new UserIndexer(dbClient, esTester.client()).setEnabled(true);
+ userIndexer = new UserIndexer(dbClient, esTester.client());
index = new UserIndex(esTester.client());
tester = new WsTester(new UsersWs(new CreateAction(dbClient,
new UserUpdater(mock(NewUserNotifier.class), settings, dbClient, userIndexer, system2),
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 c1f5e3d4504..925c2767fec 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
@@ -79,7 +79,7 @@ public class DeactivateActionTest {
dbSession = db.getSession();
dbSession.commit();
- userIndexer = (UserIndexer) new UserIndexer(dbClient, esTester.client()).setEnabled(true);
+ userIndexer = new UserIndexer(dbClient, esTester.client());
index = new UserIndex(esTester.client());
ws = new WsTester(new UsersWs(new DeactivateAction(
new UserUpdater(mock(NewUserNotifier.class), settings, dbClient, userIndexer, system2), userSessionRule,
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 7f7eb7fffab..91cbb2d3064 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
@@ -70,7 +70,7 @@ public class SearchActionTest {
DbSession dbSession = db.getSession();
UserIndex index = new UserIndex(esTester.client());
- UserIndexer userIndexer = (UserIndexer) new UserIndexer(dbClient, esTester.client()).setEnabled(true);
+ UserIndexer userIndexer = new UserIndexer(dbClient, esTester.client());
WsTester ws = new WsTester(new UsersWs(new SearchAction(index, dbClient, new UserJsonWriter(userSession))));
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
index f6ffb4c2fcd..95c527dd96f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/UpdateActionTest.java
@@ -76,7 +76,7 @@ public class UpdateActionTest {
dbClient.groupDao().insert(session, new GroupDto().setName("sonar-users"));
session.commit();
- userIndexer = (UserIndexer) new UserIndexer(dbClient, esTester.client()).setEnabled(true);
+ userIndexer = new UserIndexer(dbClient, esTester.client());
tester = new WsTester(new UsersWs(new UpdateAction(
new UserUpdater(mock(NewUserNotifier.class), settings, dbClient, userIndexer, system2), userSessionRule,
new UserJsonWriter(userSessionRule), dbClient)));
diff --git a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
index dba33b0e442..705716c6660 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java
@@ -68,7 +68,7 @@ public class ViewIndexerTest {
DbSession dbSession = dbTester.getSession();
- ViewIndexer indexer = (ViewIndexer) new ViewIndexer(dbClient, esTester.client()).setEnabled(true);
+ private ViewIndexer indexer = (ViewIndexer) new ViewIndexer(dbClient, esTester.client());
@Test
public void index_nothing() {
@@ -146,8 +146,8 @@ public class ViewIndexerTest {
@Test
public void clear_views_lookup_cache_on_index_view_uuid() {
IssueIndex issueIndex = new IssueIndex(esTester.client(), System2.INSTANCE, userSessionRule);
- IssueIndexer issueIndexer = (IssueIndexer) new IssueIndexer(dbClient, esTester.client()).setEnabled(true);
- IssueAuthorizationIndexer issueAuthorizationIndexer = (IssueAuthorizationIndexer) new IssueAuthorizationIndexer(dbClient, esTester.client()).setEnabled(true);
+ IssueIndexer issueIndexer = new IssueIndexer(dbClient, esTester.client());
+ IssueAuthorizationIndexer issueAuthorizationIndexer = new IssueAuthorizationIndexer(dbClient, esTester.client());
String viewUuid = "ABCD";