aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/DefaultCpdEngine.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdEngine.java13
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java17
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java245
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoader.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicates.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java12
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/util/DeprecatedKeyUtils.java74
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/JdbcDriverHolderTest.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java11
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/DuplicationDensityDecoratorTest.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/SumDuplicationsDecoratorTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/debt/NewDebtDecoratorTest.java13
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDateTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDaysTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysisTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersionTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/DecoratorsSelectorTest.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/FormulaDecoratorTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/events/EventBusTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java1
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java130
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java1
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/EnforceIssuesFilterTest.java7
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/IgnoreIssuesFilterTest.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/IssuePatternTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/LineRangeTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternDecoderTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternMatcherTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoaderTest.java12
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/tracking/DefaultServerLineHashesLoaderTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/issue/tracking/IssueHandlersTest.java7
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java17
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/qualitygate/GenerateQualityGateEventsTest.java9
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateProviderTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/rule/QProfileDecoratorTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputPathCacheTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/util/DeprecatedKeyUtilsTest.java40
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java68
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFileTest.java79
62 files changed, 166 insertions, 804 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/DefaultCpdEngine.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/DefaultCpdEngine.java
index 52f77df74ce..3674eca2ee0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/DefaultCpdEngine.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/DefaultCpdEngine.java
@@ -30,7 +30,7 @@ import org.sonar.api.batch.CpdMapping;
import org.sonar.api.batch.fs.FilePredicates;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
@@ -119,7 +119,7 @@ public class DefaultCpdEngine extends CpdEngine {
try {
for (InputFile inputFile : sourceFiles) {
LOG.debug("Detection of duplications for {}", inputFile);
- String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
+ String resourceEffectiveKey = ((DefaultInputFile) inputFile).key();
Collection<Block> fileBlocks = index.getByInputFile(inputFile, resourceEffectiveKey);
Iterable<CloneGroup> filtered;
@@ -144,7 +144,7 @@ public class DefaultCpdEngine extends CpdEngine {
TokenizerBridge bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(languageKey));
for (InputFile inputFile : sourceFiles) {
LOG.debug("Populating index from {}", inputFile);
- String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
+ String resourceEffectiveKey = ((DefaultInputFile) inputFile).key();
List<Block> blocks2 = bridge.chunk(resourceEffectiveKey, inputFile.file());
index.insert(inputFile, blocks2);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdEngine.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdEngine.java
index 32ea95fa3d3..f705f249e6e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdEngine.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/JavaCpdEngine.java
@@ -29,7 +29,7 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.FilePredicates;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.duplication.NewDuplication;
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
@@ -62,7 +62,12 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
public class JavaCpdEngine extends CpdEngine {
@@ -125,7 +130,7 @@ public class JavaCpdEngine extends CpdEngine {
for (InputFile inputFile : sourceFiles) {
LOG.debug("Populating index from {}", inputFile);
- String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
+ String resourceEffectiveKey = ((DefaultInputFile) inputFile).key();
List<Statement> statements;
@@ -151,7 +156,7 @@ public class JavaCpdEngine extends CpdEngine {
try {
for (InputFile inputFile : sourceFiles) {
LOG.debug("Detection of duplications for {}", inputFile);
- String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
+ String resourceEffectiveKey = ((DefaultInputFile) inputFile).key();
Collection<Block> fileBlocks = index.getByInputFile(inputFile, resourceEffectiveKey);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
index a0436ba85fa..c56ddb46c17 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
@@ -96,7 +96,6 @@ public class DefaultIndex extends SonarIndex {
private final ResourceCache resourceCache;
private final MetricFinder metricFinder;
private final MeasureCache measureCache;
- private final ResourceKeyMigration migration;
private final DependencyPersister dependencyPersister;
// caches
private Project currentProject;
@@ -108,22 +107,11 @@ public class DefaultIndex extends SonarIndex {
private ModuleIssues moduleIssues;
public DefaultIndex(ResourceCache resourceCache, DependencyPersister dependencyPersister,
- DefaultProjectTree projectTree, MetricFinder metricFinder,
- ResourceKeyMigration migration, MeasureCache measureCache) {
+ DefaultProjectTree projectTree, MetricFinder metricFinder, MeasureCache measureCache) {
this.resourceCache = resourceCache;
this.dependencyPersister = dependencyPersister;
this.projectTree = projectTree;
this.metricFinder = metricFinder;
- this.migration = migration;
- this.measureCache = measureCache;
- }
-
- public DefaultIndex(ResourceCache resourceCache, DependencyPersister dependencyPersister, DefaultProjectTree projectTree, MetricFinder metricFinder, MeasureCache measureCache) {
- this.resourceCache = resourceCache;
- this.dependencyPersister = dependencyPersister;
- this.projectTree = projectTree;
- this.metricFinder = metricFinder;
- this.migration = null;
this.measureCache = measureCache;
}
@@ -137,9 +125,6 @@ public class DefaultIndex extends SonarIndex {
void doStart(Project rootProject) {
Bucket bucket = new Bucket(rootProject);
addBucket(rootProject, bucket);
- if (migration != null) {
- migration.checkIfMigrationNeeded(rootProject);
- }
resourceCache.add(rootProject, null);
currentProject = rootProject;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java
deleted file mode 100644
index 81891856cdf..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.batch.index;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchSide;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
-import org.sonar.api.database.DatabaseSession;
-import org.sonar.api.database.model.ResourceModel;
-import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
-import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.utils.PathUtils;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.batch.util.DeprecatedKeyUtils;
-
-import javax.annotation.CheckForNull;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@BatchSide
-public class ResourceKeyMigration {
-
- private static final String UNABLE_TO_UPDATE_COMPONENT_NO_MATCH_WAS_FOUND = "Unable to update component {}. No match was found.";
- private static final String COMPONENT_CHANGED_TO = "Component {} changed to {}";
- private final Logger logger;
- private final DatabaseSession session;
- private final PathResolver pathResolver;
-
- private boolean migrationNeeded = false;
-
- public ResourceKeyMigration(DatabaseSession session, PathResolver pathResolver) {
- this(session, pathResolver, LoggerFactory.getLogger(ResourceKeyMigration.class));
- }
-
- @VisibleForTesting
- ResourceKeyMigration(DatabaseSession session, PathResolver pathResolver, Logger logger) {
- this.session = session;
- this.logger = logger;
- this.pathResolver = pathResolver;
- }
-
- public void checkIfMigrationNeeded(Project rootProject) {
- ResourceModel model = session.getSingleResult(ResourceModel.class, "key", rootProject.getEffectiveKey());
- if (model != null && StringUtils.isBlank(model.getDeprecatedKey())) {
- this.migrationNeeded = true;
- }
- }
-
- public void migrateIfNeeded(Project module, DefaultModuleFileSystem fs) {
- if (migrationNeeded) {
- migrateIfNeeded(module, fs.inputFiles(fs.predicates().all()), fs);
- }
- }
-
- void migrateIfNeeded(Project module, Iterable<InputFile> inputFiles, DefaultModuleFileSystem fs) {
- logger.info("Update component keys");
- Map<String, InputFile> deprecatedFileKeyMapper = new HashMap<>();
- Map<String, InputFile> deprecatedTestKeyMapper = new HashMap<>();
- Map<String, String> deprecatedDirectoryKeyMapper = new HashMap<>();
- for (InputFile inputFile : inputFiles) {
- String deprecatedKey = computeDeprecatedKey(module.getKey(), (DeprecatedDefaultInputFile) inputFile, fs);
- if (deprecatedKey != null) {
- if (InputFile.Type.TEST == inputFile.type() && !deprecatedTestKeyMapper.containsKey(deprecatedKey)) {
- deprecatedTestKeyMapper.put(deprecatedKey, inputFile);
- } else if (InputFile.Type.MAIN == inputFile.type() && !deprecatedFileKeyMapper.containsKey(deprecatedKey)) {
- deprecatedFileKeyMapper.put(deprecatedKey, inputFile);
- }
- }
- }
-
- ResourceModel moduleModel = session.getSingleResult(ResourceModel.class, "key", module.getEffectiveKey());
- int moduleId = moduleModel.getId();
- migrateFiles(module, deprecatedFileKeyMapper, deprecatedTestKeyMapper, deprecatedDirectoryKeyMapper, moduleId);
- migrateDirectories(deprecatedDirectoryKeyMapper, moduleId);
- session.commit();
- }
-
- @CheckForNull
- private String computeDeprecatedKey(String moduleKey, DeprecatedDefaultInputFile inputFile, DefaultModuleFileSystem fs) {
- List<java.io.File> sourceDirs = InputFile.Type.MAIN == inputFile.type() ? fs.sourceDirs() : fs.testDirs();
- for (java.io.File sourceDir : sourceDirs) {
- String sourceRelativePath = pathResolver.relativePath(sourceDir, inputFile.file());
- if (sourceRelativePath != null) {
- if ("java".equals(inputFile.language())) {
- return new StringBuilder()
- .append(moduleKey).append(":").append(DeprecatedKeyUtils.getJavaFileDeprecatedKey(sourceRelativePath)).toString();
- } else {
- return new StringBuilder().append(moduleKey).append(":").append(sourceRelativePath).toString();
- }
- }
- }
- return null;
- }
-
- private void migrateFiles(Project module, Map<String, InputFile> deprecatedFileKeyMapper, Map<String, InputFile> deprecatedTestKeyMapper,
- Map<String, String> deprecatedDirectoryKeyMapper,
- int moduleId) {
- // Find all FIL or CLA resources for this module
- StringBuilder hql = newResourceQuery()
- .append(" and scope = '").append(Scopes.FILE).append("' order by qualifier, key");
- Map<String, ResourceModel> disabledResourceByKey = loadDisabledResources(moduleId, hql);
- List<ResourceModel> resources = loadEnabledResources(moduleId, hql);
- for (ResourceModel resourceModel : resources) {
- String oldEffectiveKey = resourceModel.getKey();
- boolean isTest = Qualifiers.UNIT_TEST_FILE.equals(resourceModel.getQualifier());
- InputFile matchedFile = findInputFile(deprecatedFileKeyMapper, deprecatedTestKeyMapper, oldEffectiveKey, isTest);
- if (matchedFile != null) {
- String newEffectiveKey = ((DeprecatedDefaultInputFile) matchedFile).key();
- // Now compute migration of the parent dir
- String oldKey = StringUtils.substringAfterLast(oldEffectiveKey, ":");
- String parentOldKey;
- if ("java".equals(resourceModel.getLanguageKey())) {
- parentOldKey = String.format("%s:%s", module.getEffectiveKey(), DeprecatedKeyUtils.getJavaFileParentDeprecatedKey(oldKey));
- } else {
- parentOldKey = String.format("%s:%s", module.getEffectiveKey(), oldParentKey(oldKey));
- }
- String parentNewKey = String.format("%s:%s", module.getEffectiveKey(), getParentKey(matchedFile));
- if (!deprecatedDirectoryKeyMapper.containsKey(parentOldKey)) {
- deprecatedDirectoryKeyMapper.put(parentOldKey, parentNewKey);
- } else if (!parentNewKey.equals(deprecatedDirectoryKeyMapper.get(parentOldKey))) {
- logger.warn("Directory with key " + parentOldKey + " matches both " + deprecatedDirectoryKeyMapper.get(parentOldKey) + " and "
- + parentNewKey + ". First match is arbitrary chosen.");
- }
- updateKey(resourceModel, newEffectiveKey, disabledResourceByKey);
- resourceModel.setDeprecatedKey(oldEffectiveKey);
- logger.info(COMPONENT_CHANGED_TO, oldEffectiveKey, newEffectiveKey);
- } else {
- logger.warn(UNABLE_TO_UPDATE_COMPONENT_NO_MATCH_WAS_FOUND, oldEffectiveKey);
- }
- }
- }
-
- private String oldParentKey(String oldKey) {
- String cleanKey = StringUtils.trim(oldKey.replace('\\', '/'));
- if (cleanKey.indexOf(Directory.SEPARATOR) >= 0) {
- String oldParentKey = Directory.parseKey(StringUtils.substringBeforeLast(oldKey, Directory.SEPARATOR));
- oldParentKey = StringUtils.removeStart(oldParentKey, Directory.SEPARATOR);
- oldParentKey = StringUtils.removeEnd(oldParentKey, Directory.SEPARATOR);
- return oldParentKey;
- } else {
- return Directory.ROOT;
- }
- }
-
- private void updateKey(ResourceModel resourceModel, String newEffectiveKey, Map<String, ResourceModel> disabledResourceByKey) {
- // Look for disabled resource with conflicting key
- if (disabledResourceByKey.containsKey(newEffectiveKey)) {
- ResourceModel duplicateDisabledResource = disabledResourceByKey.get(newEffectiveKey);
- String disabledKey = newEffectiveKey + "_renamed_by_resource_key_migration";
- duplicateDisabledResource.setKey(disabledKey);
- logger.info(COMPONENT_CHANGED_TO, newEffectiveKey, disabledKey);
- }
- resourceModel.setKey(newEffectiveKey);
- }
-
- private StringBuilder newResourceQuery() {
- return new StringBuilder().append("from ")
- .append(ResourceModel.class.getSimpleName())
- .append(" where enabled = :enabled")
- .append(" and rootId = :rootId ");
- }
-
- private InputFile findInputFile(Map<String, InputFile> deprecatedFileKeyMapper, Map<String, InputFile> deprecatedTestKeyMapper, String oldEffectiveKey, boolean isTest) {
- if (isTest) {
- return deprecatedTestKeyMapper.get(oldEffectiveKey);
- } else {
- return deprecatedFileKeyMapper.get(oldEffectiveKey);
- }
- }
-
- private void migrateDirectories(Map<String, String> deprecatedDirectoryKeyMapper, int moduleId) {
- // Find all DIR resources for this module
- StringBuilder hql = newResourceQuery()
- .append(" and qualifier = '").append(Qualifiers.DIRECTORY).append("'");
- Map<String, ResourceModel> disabledResourceByKey = loadDisabledResources(moduleId, hql);
- List<ResourceModel> resources = loadEnabledResources(moduleId, hql);
- for (ResourceModel resourceModel : resources) {
- String oldEffectiveKey = resourceModel.getKey();
- if (deprecatedDirectoryKeyMapper.containsKey(oldEffectiveKey)) {
- String newEffectiveKey = deprecatedDirectoryKeyMapper.get(oldEffectiveKey);
- updateKey(resourceModel, newEffectiveKey, disabledResourceByKey);
- resourceModel.setDeprecatedKey(oldEffectiveKey);
- logger.info(COMPONENT_CHANGED_TO, oldEffectiveKey, newEffectiveKey);
- } else {
- logger.warn(UNABLE_TO_UPDATE_COMPONENT_NO_MATCH_WAS_FOUND, oldEffectiveKey);
- }
- }
- }
-
- private List<ResourceModel> loadEnabledResources(int moduleId, StringBuilder hql) {
- return session.createQuery(hql.toString())
- .setParameter("rootId", moduleId)
- .setParameter("enabled", true)
- .getResultList();
- }
-
- private Map<String, ResourceModel> loadDisabledResources(int moduleId, StringBuilder hql) {
- List<ResourceModel> disabledResources = session.createQuery(hql.toString())
- .setParameter("rootId", moduleId)
- .setParameter("enabled", false)
- .getResultList();
- Map<String, ResourceModel> disabledResourceByKey = new HashMap<>();
- for (ResourceModel disabledResourceModel : disabledResources) {
- disabledResourceByKey.put(disabledResourceModel.getKey(), disabledResourceModel);
- }
- return disabledResourceByKey;
- }
-
- private String getParentKey(InputFile matchedFile) {
- String filePath = PathUtils.sanitize(matchedFile.relativePath());
- String parentFolderPath;
- if (filePath.contains(Directory.SEPARATOR)) {
- parentFolderPath = StringUtils.substringBeforeLast(filePath, Directory.SEPARATOR);
- } else {
- parentFolderPath = Directory.SEPARATOR;
- }
- return parentFolderPath;
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoader.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoader.java
index 5f3e9c308e8..1dad68550bb 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoader.java
@@ -22,7 +22,7 @@ package org.sonar.batch.issue.ignore.scanner;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.SonarException;
import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
@@ -59,7 +59,7 @@ public final class IssueExclusionsLoader {
for (InputFile inputFile : fileSystem.inputFiles(fileSystem.predicates().all())) {
try {
- String componentEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
+ String componentEffectiveKey = ((DefaultInputFile) inputFile).key();
if (componentEffectiveKey != null) {
String path = inputFile.relativePath();
inclusionPatternInitializer.initializePatternsForPath(path, componentEffectiveKey);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
index 982170b25d1..5da07abfd86 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
@@ -48,7 +48,6 @@ import org.sonar.batch.index.Caches;
import org.sonar.batch.index.DefaultIndex;
import org.sonar.batch.index.DependencyPersister;
import org.sonar.batch.index.ResourceCache;
-import org.sonar.batch.index.ResourceKeyMigration;
import org.sonar.batch.index.ResourcePersister;
import org.sonar.batch.issue.DefaultProjectIssues;
import org.sonar.batch.issue.IssueCache;
@@ -227,7 +226,6 @@ public class ProjectScanContainer extends ComponentContainer {
add(
PastMeasuresLoader.class,
ResourcePersister.class,
- ResourceKeyMigration.class,
GraphPersister.class,
// Users
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicates.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicates.java
index cb4d4461d11..9ae88762460 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicates.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicates.java
@@ -19,10 +19,9 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.api.batch.fs.internal.AbstractFilePredicate;
-
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.AbstractFilePredicate;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
/**
* Additional {@link org.sonar.api.batch.fs.FilePredicate}s that are
@@ -43,7 +42,7 @@ class AdditionalFilePredicates {
@Override
public boolean apply(InputFile f) {
- return key.equals(((DeprecatedDefaultInputFile) f).key());
+ return key.equals(((DefaultInputFile) f).key());
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
index b8b48ec47fa..5f05c9b1af3 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
@@ -27,7 +27,6 @@ import org.sonar.api.resources.Languages;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.ResourceCache;
-import org.sonar.batch.index.ResourceKeyMigration;
import org.sonar.batch.index.ResourcePersister;
import javax.annotation.Nullable;
@@ -42,23 +41,20 @@ public class ComponentIndexer {
private final Languages languages;
private final SonarIndex sonarIndex;
- private final ResourceKeyMigration migration;
private final Project module;
private final ResourcePersister resourcePersister;
private final ResourceCache resourceCache;
- public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, ResourceCache resourceCache, @Nullable ResourceKeyMigration migration,
- @Nullable ResourcePersister resourcePersister) {
+ public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, ResourceCache resourceCache, @Nullable ResourcePersister resourcePersister) {
this.module = module;
this.languages = languages;
this.sonarIndex = sonarIndex;
this.resourceCache = resourceCache;
- this.migration = migration;
this.resourcePersister = resourcePersister;
}
public ComponentIndexer(Project module, Languages languages, SonarIndex sonarIndex, ResourceCache resourceCache) {
- this(module, languages, sonarIndex, resourceCache, null, null);
+ this(module, languages, sonarIndex, resourceCache, null);
}
public void execute(DefaultModuleFileSystem fs) {
@@ -69,10 +65,6 @@ public class ComponentIndexer {
resourcePersister.persist();
}
- if (migration != null) {
- migration.migrateIfNeeded(module, fs);
- }
-
for (InputFile inputFile : fs.inputFiles(fs.predicates().all())) {
String languageKey = inputFile.language();
boolean unitTest = InputFile.Type.TEST == inputFile.type();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
index 87527835a81..f80fd47ef73 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
@@ -30,7 +30,7 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFileFilter;
import org.sonar.api.batch.fs.internal.DefaultInputDir;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.MessageException;
import org.sonar.batch.util.ProgressReport;
@@ -135,7 +135,7 @@ public class FileIndexer {
}
private void indexFile(InputFileBuilder inputFileBuilder, DefaultModuleFileSystem fileSystem, Progress progress, File sourceFile, InputFile.Type type) {
- DeprecatedDefaultInputFile inputFile = inputFileBuilder.create(sourceFile);
+ DefaultInputFile inputFile = inputFileBuilder.create(sourceFile);
if (inputFile != null) {
// Set basedir on input file prior to adding it to the FS since exclusions filters may require the absolute path
inputFile.setModuleBaseDir(fileSystem.baseDirPath());
@@ -148,12 +148,12 @@ public class FileIndexer {
}
private void indexFile(final InputFileBuilder inputFileBuilder, final DefaultModuleFileSystem fs,
- final Progress status, final DeprecatedDefaultInputFile inputFile, final InputFile.Type type) {
+ final Progress status, final DefaultInputFile inputFile, final InputFile.Type type) {
tasks.add(executorService.submit(new Callable<Void>() {
@Override
public Void call() {
- DeprecatedDefaultInputFile completedInputFile = inputFileBuilder.completeAndComputeMetadata(inputFile, type);
+ DefaultInputFile completedInputFile = inputFileBuilder.completeAndComputeMetadata(inputFile, type);
if (completedInputFile != null && accept(completedInputFile)) {
fs.add(completedInputFile);
status.markAsIndexed(completedInputFile);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
index e58d5625296..317612d9f69 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilder.java
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.FileMetadata;
import org.sonar.api.config.Settings;
import org.sonar.api.scan.filesystem.PathResolver;
@@ -80,20 +80,20 @@ class InputFileBuilder {
}
@CheckForNull
- DeprecatedDefaultInputFile create(File file) {
+ DefaultInputFile create(File file) {
String relativePath = pathResolver.relativePath(fs.baseDir(), file);
if (relativePath == null) {
LOG.warn("File '{}' is ignored. It is not located in module basedir '{}'.", file.getAbsolutePath(), fs.baseDir());
return null;
}
- return new DeprecatedDefaultInputFile(moduleKey, relativePath);
+ return new DefaultInputFile(moduleKey, relativePath);
}
/**
* Optimization to not compute InputFile metadata if the file is excluded from analysis.
*/
@CheckForNull
- DeprecatedDefaultInputFile completeAndComputeMetadata(DeprecatedDefaultInputFile inputFile, InputFile.Type type) {
+ DefaultInputFile completeAndComputeMetadata(DefaultInputFile inputFile, InputFile.Type type) {
inputFile.setType(type);
inputFile.setModuleBaseDir(fs.baseDir().toPath());
inputFile.setCharset(fs.encoding());
diff --git a/sonar-batch/src/main/java/org/sonar/batch/util/DeprecatedKeyUtils.java b/sonar-batch/src/main/java/org/sonar/batch/util/DeprecatedKeyUtils.java
deleted file mode 100644
index 30db633da28..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/util/DeprecatedKeyUtils.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.batch.util;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.JavaPackage;
-
-public class DeprecatedKeyUtils {
-
- private DeprecatedKeyUtils() {
- // Utility class
- }
-
- /**
- * Return the parent directory deprecated key for a given deprecated Java file key.
- * "com.foo.Bar" -> "com/foo"
- * "[root].Bar" -> "[root]"
- * "Bar" -> "[root]"
- */
- public static String getJavaFileParentDeprecatedKey(String deprecatedJavaFileKey) {
- String packageFullyQualifiedName;
- String realKey = StringUtils.trim(deprecatedJavaFileKey);
- if (realKey.contains(".")) {
- packageFullyQualifiedName = StringUtils.substringBeforeLast(realKey, ".");
- String deprecatedDirectoryKey = StringUtils.trimToEmpty(packageFullyQualifiedName);
- if (JavaPackage.DEFAULT_PACKAGE_NAME.equals(deprecatedDirectoryKey)) {
- return Directory.ROOT;
- }
- deprecatedDirectoryKey = deprecatedDirectoryKey.replaceAll("\\.", Directory.SEPARATOR);
- return StringUtils.defaultIfEmpty(deprecatedDirectoryKey, Directory.ROOT);
- } else {
- return Directory.ROOT;
- }
- }
-
- /**
- * Return the deprecated key of a Java file given its path relative to source directory.
- */
- public static String getJavaFileDeprecatedKey(String sourceRelativePath) {
- String pacname = null;
- String classname = sourceRelativePath;
-
- if (sourceRelativePath.indexOf('/') >= 0) {
- pacname = StringUtils.substringBeforeLast(sourceRelativePath, "/");
- pacname = StringUtils.replace(pacname, "/", ".");
- classname = StringUtils.substringAfterLast(sourceRelativePath, "/");
- }
- classname = StringUtils.substringBeforeLast(classname, ".");
- if (StringUtils.isBlank(pacname)) {
- return new StringBuilder().append(JavaPackage.DEFAULT_PACKAGE_NAME).append(".").append(classname).toString();
- } else {
- return new StringBuilder().append(pacname.trim()).append(".").append(classname).toString();
- }
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
index a96f8570550..1d49d6318f7 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java
@@ -32,11 +32,11 @@ import org.sonar.api.batch.PostJob;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.postjob.PostJobContext;
-import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.resources.Project;
import org.sonar.batch.postjob.PostJobOptimizer;
import org.sonar.batch.sensor.DefaultSensorContext;
import org.sonar.batch.sensor.SensorOptimizer;
+import org.sonar.core.platform.ComponentContainer;
import java.util.Arrays;
import java.util.Collection;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java
index 3d080e35d82..f2c2f6354a3 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginExploderTest.java
@@ -24,8 +24,8 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.core.platform.PluginInfo;
import org.sonar.core.platform.ExplodedPlugin;
+import org.sonar.core.platform.PluginInfo;
import org.sonar.home.cache.FileCache;
import org.sonar.home.cache.FileCacheBuilder;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/JdbcDriverHolderTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/JdbcDriverHolderTest.java
index 9bf262996c8..17c2096ba29 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/JdbcDriverHolderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/JdbcDriverHolderTest.java
@@ -31,7 +31,14 @@ import org.sonar.home.cache.FileCache;
import java.io.File;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
public class JdbcDriverHolderTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java
index d032e2b1cd1..60d8a465971 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.components;
-import org.sonar.batch.components.PastMeasuresLoader;
-
import org.junit.Test;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.Metric;
@@ -29,10 +27,10 @@ import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.util.Arrays;
import java.util.List;
-import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
index be6c4ab057c..8d8506a063a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderTest.java
@@ -19,12 +19,6 @@
*/
package org.sonar.batch.components;
-import org.sonar.batch.components.PastSnapshotFinder;
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByDate;
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByDays;
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByPreviousAnalysis;
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByPreviousVersion;
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByVersion;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
@@ -34,6 +28,11 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.utils.DateUtils;
+import org.sonar.batch.deprecated.components.PastSnapshotFinderByDate;
+import org.sonar.batch.deprecated.components.PastSnapshotFinderByDays;
+import org.sonar.batch.deprecated.components.PastSnapshotFinderByPreviousAnalysis;
+import org.sonar.batch.deprecated.components.PastSnapshotFinderByPreviousVersion;
+import org.sonar.batch.deprecated.components.PastSnapshotFinderByVersion;
import java.text.ParseException;
import java.text.SimpleDateFormat;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java
index 201155b1188..3d38431f780 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.components;
-import org.sonar.batch.components.PastSnapshot;
-
import org.junit.Test;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.model.Snapshot;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java
index eae7b0f8377..b4a7daac7d5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java
@@ -19,13 +19,10 @@
*/
package org.sonar.batch.components;
-import org.sonar.batch.components.TimeMachineConfiguration;
-
-import org.sonar.batch.components.PastSnapshot;
-import org.sonar.batch.deprecated.components.PeriodsDefinition;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.batch.deprecated.components.PeriodsDefinition;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.util.Date;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java b/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java
index 2c77b007350..71d80a37c5b 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cpd/JavaCpdEngineTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.duplication.NewDuplication;
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
@@ -52,7 +52,7 @@ public class JavaCpdEngineTest {
public TemporaryFolder temp = new TemporaryFolder();
SensorContext context = mock(SensorContext.class);
- DeprecatedDefaultInputFile inputFile;
+ DefaultInputFile inputFile;
private SensorStorage storage = mock(SensorStorage.class);
@Before
@@ -69,7 +69,7 @@ public class JavaCpdEngineTest {
return new DefaultDuplication(storage);
}
});
- inputFile = (DeprecatedDefaultInputFile) new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java").setLines(300);
+ inputFile = (DefaultInputFile) new DefaultInputFile("foo", "src/main/java/Foo.java").setLines(300);
inputFile.setModuleBaseDir(temp.newFolder().toPath());
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/DuplicationDensityDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/DuplicationDensityDecoratorTest.java
index 629a1cf6d5d..62aca152eb5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/DuplicationDensityDecoratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/DuplicationDensityDecoratorTest.java
@@ -19,14 +19,18 @@
*/
package org.sonar.batch.cpd.decorators;
-import org.sonar.batch.cpd.decorators.DuplicationDensityDecorator;
-
import org.junit.Test;
-import static org.mockito.Mockito.*;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
+import static org.mockito.Matchers.anyDouble;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
public class DuplicationDensityDecoratorTest {
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/SumDuplicationsDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/SumDuplicationsDecoratorTest.java
index a86cfb423ed..85f5180d186 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/SumDuplicationsDecoratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cpd/decorators/SumDuplicationsDecoratorTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.cpd.decorators;
-import org.sonar.batch.cpd.decorators.SumDuplicationsDecorator;
-
import org.junit.Test;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.measures.CoreMetrics;
@@ -28,6 +26,7 @@ import org.sonar.api.measures.Measure;
import org.sonar.api.resources.File;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.test.IsMeasure;
+
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
index d60ace37875..f4aef8284d4 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cpd/index/IndexFactoryTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.cpd.index;
-import org.sonar.batch.cpd.index.IndexFactory;
-
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@@ -31,6 +29,7 @@ import org.sonar.api.resources.Project;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.index.ResourceCache;
import org.sonar.core.duplication.DuplicationDao;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/debt/NewDebtDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/debt/NewDebtDecoratorTest.java
index 327799f2e07..8de52b074c2 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/debt/NewDebtDecoratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/debt/NewDebtDecoratorTest.java
@@ -20,9 +20,6 @@
package org.sonar.batch.debt;
-import org.sonar.batch.components.Period;
-
-import org.sonar.batch.components.TimeMachineConfiguration;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.time.DateUtils;
import org.junit.Before;
@@ -45,14 +42,18 @@ import org.sonar.api.measures.Metric;
import org.sonar.api.resources.Resource;
import org.sonar.api.test.IsMeasure;
import org.sonar.api.utils.Duration;
-import org.sonar.batch.debt.IssueChangelogDebtCalculator;
-import org.sonar.batch.debt.NewDebtDecorator;
+import org.sonar.batch.components.Period;
+import org.sonar.batch.components.TimeMachineConfiguration;
import java.util.Date;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class NewDebtDecoratorTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDateTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDateTest.java
index 2cf8b317531..7ab4b0e76e8 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDateTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDateTest.java
@@ -19,11 +19,9 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.batch.components.PastSnapshot;
-
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByDate;
import org.junit.Test;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.batch.components.PastSnapshot;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.text.ParseException;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDaysTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDaysTest.java
index 0515b30673d..6117905e446 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDaysTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDaysTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByDays;
-
import org.hamcrest.core.IsNull;
import org.junit.Test;
import org.sonar.api.database.model.Snapshot;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysisTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysisTest.java
index 9ec2024b7d4..f228d3b8ab8 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysisTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysisTest.java
@@ -19,12 +19,11 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.batch.components.PastSnapshot;
-
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByPreviousAnalysis;
import org.junit.Test;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.batch.components.PastSnapshot;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersionTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersionTest.java
index 5d8c87ad7f0..85411b26cf7 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersionTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersionTest.java
@@ -19,13 +19,12 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.batch.components.PastSnapshot;
-
-import org.sonar.batch.deprecated.components.PastSnapshotFinderByVersion;
import org.junit.Test;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.model.Snapshot;
+import org.sonar.batch.components.PastSnapshot;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
import static org.assertj.core.api.Assertions.assertThat;
public class PastSnapshotFinderByVersionTest extends AbstractDbUnitTestCase {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/DecoratorsSelectorTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/DecoratorsSelectorTest.java
index 3b7340689db..9accda935d8 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/DecoratorsSelectorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/DecoratorsSelectorTest.java
@@ -24,11 +24,15 @@ import org.junit.Test;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.DependedUpon;
-import org.sonar.api.measures.*;
-import org.sonar.core.platform.ComponentContainer;
+import org.sonar.api.measures.Formula;
+import org.sonar.api.measures.FormulaContext;
+import org.sonar.api.measures.FormulaData;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.Metric;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
+import org.sonar.core.platform.ComponentContainer;
import java.util.Arrays;
import java.util.Collection;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/FormulaDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/FormulaDecoratorTest.java
index 4507ab8cbc0..2298a09cb33 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/FormulaDecoratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/deprecated/decorator/FormulaDecoratorTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.deprecated.decorator;
-import org.sonar.batch.deprecated.decorator.FormulaDecorator;
-
import org.junit.Test;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.measures.CoreMetrics;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/events/EventBusTest.java b/sonar-batch/src/test/java/org/sonar/batch/events/EventBusTest.java
index e088ef71edb..45445524072 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/events/EventBusTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/events/EventBusTest.java
@@ -19,13 +19,12 @@
*/
package org.sonar.batch.events;
+import org.junit.Test;
import org.sonar.api.batch.events.EventHandler;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import org.junit.Test;
-
public class EventBusTest {
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index 6511d57c732..c16abe19c2d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -72,7 +72,6 @@ public class DefaultIndexTest {
DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
ResourceCache resourceCache = new ResourceCache();
index = new DefaultIndex(resourceCache, null, projectTree, metricFinder,
- mock(ResourceKeyMigration.class),
mock(MeasureCache.class));
baseDir = temp.newFolder();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java
deleted file mode 100644
index 1d3d227a4d4..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceKeyMigrationTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.batch.index;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Project;
-import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class ResourceKeyMigrationTest extends AbstractDbUnitTestCase {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- Project multiModuleProject, phpModule, javaModule;
- Iterable<InputFile> javaInputFiles;
- Iterable<InputFile> phpInputFiles;
- File baseDir;
-
- @Before
- public void before() throws Exception {
- SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
-
- multiModuleProject = newProject("root", "java");
- multiModuleProject.setName("Root").setAnalysisDate(format.parse("25/12/2010"));
-
- phpModule = newProject("a", "php");
- phpModule.setName("A").setAnalysisDate(format.parse("25/12/2010"));
- phpModule.setParent(multiModuleProject);
- phpModule.setPath("/moduleA");
-
- javaModule = newProject("b", "java");
- javaModule.setName("B").setAnalysisDate(format.parse("25/12/2010"));
- javaModule.setParent(multiModuleProject);
- javaModule.setPath("/moduleB");
-
- baseDir = temp.newFolder();
-
- javaInputFiles = (Iterable) Arrays.asList(
- newInputFile(javaModule, "src/main/java/org/foo/Bar.java", false, "java"),
- newInputFile(javaModule, "src/main/java/RootBar.java", false, "java"),
- newInputFile(javaModule, "src/test/java/org/foo/BarTest.java", true, "java"));
-
- phpInputFiles = (Iterable) Arrays.asList(
- newInputFile(phpModule, "org/foo/Bar.php", false, "php"),
- newInputFile(phpModule, "RootBar.php", false, "php"),
- newInputFile(phpModule, "test/org/foo/BarTest.php", true, "php"));
-
- }
-
- private DefaultInputFile newInputFile(Project module, String path, boolean isTest, String language) {
- return new DeprecatedDefaultInputFile(module.getKey(), path)
- .setModuleBaseDir(baseDir.toPath())
- .setLanguage(language)
- .setType(isTest ? InputFile.Type.TEST : InputFile.Type.MAIN);
- }
-
- @Test
- public void shouldMigrateResourceKeys() {
- setupData("shouldMigrateResourceKeys");
-
- Logger logger = mock(Logger.class);
- ResourceKeyMigration migration = new ResourceKeyMigration(getSession(), new PathResolver(), logger);
- migration.checkIfMigrationNeeded(multiModuleProject);
-
- DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
- when(fs.sourceDirs()).thenReturn(Arrays.asList(new File(baseDir, "src/main/java")));
- when(fs.testDirs()).thenReturn(Arrays.asList(new File(baseDir, "src/test/java")));
- migration.migrateIfNeeded(javaModule, javaInputFiles, fs);
-
- when(fs.sourceDirs()).thenReturn(Arrays.asList(new File(baseDir, ".")));
- when(fs.testDirs()).thenReturn(Arrays.asList(new File(baseDir, "test")));
- migration.migrateIfNeeded(phpModule, phpInputFiles, fs);
-
- verify(logger).info("Component {} changed to {}", "b:org.foo.Bar", "b:src/main/java/org/foo/Bar.java");
- verify(logger).warn("Directory with key b:org/foo matches both b:src/main/java/org/foo and b:src/test/java/org/foo. First match is arbitrary chosen.");
- verify(logger).info("Component {} changed to {}", "b:org.foo.BarTest", "b:src/test/java/org/foo/BarTest.java");
- verify(logger).info("Component {} changed to {}", "b:[default].RootBar", "b:src/main/java/RootBar.java");
- verify(logger).info("Component {} changed to {}", "b:org/foo", "b:src/main/java/org/foo");
- verify(logger).info("Component {} changed to {}", "b:[root]", "b:src/main/java");
-
- checkTables("shouldMigrateResourceKeys", new String[] {"build_date", "created_at", "authorization_updated_at"}, "projects");
- }
-
- private static Project newProject(String key, String language) {
- Settings settings = new Settings();
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, language);
- return new Project(key).setSettings(settings).setAnalysisType(Project.AnalysisType.DYNAMIC);
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
index e8e025b5297..92db07f34f6 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java
@@ -226,7 +226,6 @@ public class ResourcePersisterTest extends AbstractDbUnitTestCase {
when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1")));
DefaultIndex index = new DefaultIndex(resourceCache, null, projectTree, mock(MetricFinder.class),
- mock(ResourceKeyMigration.class),
mock(MeasureCache.class));
index.start();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/EnforceIssuesFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/EnforceIssuesFilterTest.java
index 4cdb67cb1da..5996ca78d36 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/EnforceIssuesFilterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/EnforceIssuesFilterTest.java
@@ -20,10 +20,6 @@
package org.sonar.batch.issue.ignore;
-import org.sonar.batch.issue.ignore.EnforceIssuesFilter;
-import org.sonar.batch.issue.ignore.pattern.IssueInclusionPatternInitializer;
-import org.sonar.batch.issue.ignore.pattern.IssuePattern;
-
import com.google.common.collect.ImmutableList;
import org.junit.Before;
import org.junit.Test;
@@ -31,6 +27,9 @@ import org.sonar.api.issue.Issue;
import org.sonar.api.issue.batch.IssueFilterChain;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.WildcardPattern;
+import org.sonar.batch.issue.ignore.pattern.IssueInclusionPatternInitializer;
+import org.sonar.batch.issue.ignore.pattern.IssuePattern;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/IgnoreIssuesFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/IgnoreIssuesFilterTest.java
index 22efcb7e62d..13b1ec042de 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/IgnoreIssuesFilterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/IgnoreIssuesFilterTest.java
@@ -20,15 +20,14 @@
package org.sonar.batch.issue.ignore;
-import org.sonar.batch.issue.ignore.IgnoreIssuesFilter;
-import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
-import org.sonar.batch.issue.ignore.pattern.IssuePattern;
-import org.sonar.batch.issue.ignore.pattern.PatternMatcher;
-
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.batch.IssueFilterChain;
+import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
+import org.sonar.batch.issue.ignore.pattern.IssuePattern;
+import org.sonar.batch.issue.ignore.pattern.PatternMatcher;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/IssuePatternTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/IssuePatternTest.java
index 71a4c1194b1..bf42b241300 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/IssuePatternTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/IssuePatternTest.java
@@ -20,12 +20,11 @@
package org.sonar.batch.issue.ignore.pattern;
-import org.sonar.batch.issue.ignore.pattern.IssuePattern;
-
import org.junit.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/LineRangeTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/LineRangeTest.java
index e45c92ee53f..c6ec66550d8 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/LineRangeTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/LineRangeTest.java
@@ -20,9 +20,8 @@
package org.sonar.batch.issue.ignore.pattern;
-import org.sonar.batch.issue.ignore.pattern.LineRange;
-
import org.junit.Test;
+
import static org.assertj.core.api.Assertions.assertThat;
public class LineRangeTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternDecoderTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternDecoderTest.java
index c3b235e4e65..4679e5ae6c6 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternDecoderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternDecoderTest.java
@@ -20,9 +20,6 @@
package org.sonar.batch.issue.ignore.pattern;
-import org.sonar.batch.issue.ignore.pattern.IssuePattern;
-import org.sonar.batch.issue.ignore.pattern.PatternDecoder;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternMatcherTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternMatcherTest.java
index 5c8416e243a..3d0acd15b5b 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternMatcherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/pattern/PatternMatcherTest.java
@@ -19,11 +19,6 @@
*/
package org.sonar.batch.issue.ignore.pattern;
-import org.sonar.batch.issue.ignore.pattern.IssuePattern;
-import org.sonar.batch.issue.ignore.pattern.LineRange;
-import org.sonar.batch.issue.ignore.pattern.PatternDecoder;
-import org.sonar.batch.issue.ignore.pattern.PatternMatcher;
-
import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoaderTest.java
index b213103a1b5..4963cd13b30 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsLoaderTest.java
@@ -29,7 +29,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.utils.SonarException;
import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
import org.sonar.batch.issue.ignore.pattern.IssueInclusionPatternInitializer;
@@ -105,10 +105,10 @@ public class IssueExclusionsLoaderTest {
@Test
public void shouldAnalyzeProject() throws IOException {
File javaFile1 = new File(baseDir, "src/main/java/Foo.java");
- fs.add(new DeprecatedDefaultInputFile("polop", "src/main/java/Foo.java")
+ fs.add(new DefaultInputFile("polop", "src/main/java/Foo.java")
.setType(InputFile.Type.MAIN));
File javaTestFile1 = new File(baseDir, "src/test/java/FooTest.java");
- fs.add(new DeprecatedDefaultInputFile("polop", "src/test/java/FooTest.java")
+ fs.add(new DefaultInputFile("polop", "src/test/java/FooTest.java")
.setType(InputFile.Type.TEST));
when(exclusionPatternInitializer.hasFileContentPattern()).thenReturn(true);
@@ -126,10 +126,10 @@ public class IssueExclusionsLoaderTest {
@Test
public void shouldAnalyseFilesOnlyWhenRegexConfigured() {
File javaFile1 = new File(baseDir, "src/main/java/Foo.java");
- fs.add(new DeprecatedDefaultInputFile("polop", "src/main/java/Foo.java")
+ fs.add(new DefaultInputFile("polop", "src/main/java/Foo.java")
.setType(InputFile.Type.MAIN));
File javaTestFile1 = new File(baseDir, "src/test/java/FooTest.java");
- fs.add(new DeprecatedDefaultInputFile("polop", "src/test/java/FooTest.java")
+ fs.add(new DefaultInputFile("polop", "src/test/java/FooTest.java")
.setType(InputFile.Type.TEST));
when(exclusionPatternInitializer.hasFileContentPattern()).thenReturn(false);
@@ -145,7 +145,7 @@ public class IssueExclusionsLoaderTest {
@Test
public void shouldReportFailure() throws IOException {
File phpFile1 = new File(baseDir, "src/Foo.php");
- fs.add(new DeprecatedDefaultInputFile("polop", "src/Foo.php")
+ fs.add(new DefaultInputFile("polop", "src/Foo.php")
.setType(InputFile.Type.MAIN));
when(exclusionPatternInitializer.hasFileContentPattern()).thenReturn(true);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/DefaultServerLineHashesLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/DefaultServerLineHashesLoaderTest.java
index 2986564bbb0..28d9b251ec9 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/DefaultServerLineHashesLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/DefaultServerLineHashesLoaderTest.java
@@ -23,8 +23,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.batch.bootstrap.ServerClient;
import org.sonar.api.utils.HttpDownloader;
+import org.sonar.batch.bootstrap.ServerClient;
import java.net.URI;
import java.net.URISyntaxException;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/IssueHandlersTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/IssueHandlersTest.java
index cbaacefc7fd..fe81ee2006b 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/IssueHandlersTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/issue/tracking/IssueHandlersTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.issue.tracking;
-import org.sonar.batch.issue.tracking.IssueHandlers;
-
import org.junit.Test;
import org.mockito.ArgumentMatcher;
import org.sonar.api.issue.IssueHandler;
@@ -30,7 +28,10 @@ import org.sonar.core.issue.IssueUpdater;
import java.util.Date;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
public class IssueHandlersTest {
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
index 0974ac53e11..0aa11588a8c 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
@@ -25,10 +25,23 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.*;
-import org.sonar.api.batch.events.*;
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DecoratorContext;
+import org.sonar.api.batch.Initializer;
+import org.sonar.api.batch.PostJob;
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.batch.events.DecoratorExecutionHandler;
+import org.sonar.api.batch.events.DecoratorsPhaseHandler;
+import org.sonar.api.batch.events.InitializerExecutionHandler;
+import org.sonar.api.batch.events.InitializersPhaseHandler;
+import org.sonar.api.batch.events.PostJobExecutionHandler;
+import org.sonar.api.batch.events.PostJobsPhaseHandler;
+import org.sonar.api.batch.events.ProjectAnalysisHandler;
import org.sonar.api.batch.events.ProjectAnalysisHandler.ProjectAnalysisEvent;
+import org.sonar.api.batch.events.SensorExecutionHandler;
import org.sonar.api.batch.events.SensorExecutionHandler.SensorExecutionEvent;
+import org.sonar.api.batch.events.SensorsPhaseHandler;
import org.sonar.api.batch.events.SensorsPhaseHandler.SensorsPhaseEvent;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/GenerateQualityGateEventsTest.java b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/GenerateQualityGateEventsTest.java
index d9a0cd95215..5cf93a9d419 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/GenerateQualityGateEventsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/GenerateQualityGateEventsTest.java
@@ -39,7 +39,14 @@ import org.sonar.batch.report.EventCache;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class GenerateQualityGateEventsTest {
private GenerateQualityGateEvents decorator;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateProviderTest.java
index 12a9976207b..d624dfbecdc 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateProviderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateProviderTest.java
@@ -26,16 +26,18 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.MetricFinder;
+import org.sonar.api.utils.HttpDownloader;
import org.sonar.api.utils.MessageException;
import org.sonar.batch.bootstrap.ServerClient;
-import org.sonar.api.utils.HttpDownloader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.util.Iterator;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class QualityGateProviderTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
index 5e806339a89..2d2a97e234d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
@@ -37,7 +37,9 @@ import org.sonar.batch.protocol.Constants.ComponentLinkType;
import org.sonar.batch.protocol.Constants.EventCategory;
import org.sonar.batch.protocol.output.BatchReport.Component;
import org.sonar.batch.protocol.output.BatchReport.Event;
-import org.sonar.batch.protocol.output.*;
+import org.sonar.batch.protocol.output.BatchReportReader;
+import org.sonar.batch.protocol.output.BatchReportWriter;
+import org.sonar.batch.protocol.output.FileStructure;
import java.io.File;
import java.util.Arrays;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
index 74389bc0466..bc22f032a19 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java
@@ -24,9 +24,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.measures.*;
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.Metric;
import org.sonar.api.measures.Metric.Level;
import org.sonar.api.measures.Metric.ValueType;
+import org.sonar.api.measures.MetricFinder;
+import org.sonar.api.measures.RuleMeasure;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rule.RuleKey;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
index 0db9253b479..9458bc31c35 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultProjectRepositoriesLoaderTest.java
@@ -24,9 +24,9 @@ import org.junit.Before;
import org.junit.Test;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ServerClient;
-import org.sonar.batch.bootstrap.AnalysisProperties;
import org.sonar.batch.rule.ModuleQProfiles;
import static org.mockito.Matchers.anyString;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileDecoratorTest.java
index 99582597466..a0b8a8e57b9 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileDecoratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileDecoratorTest.java
@@ -31,7 +31,10 @@ import java.util.Arrays;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class QProfileDecoratorTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
index 6ba93100ea0..532393a56e0 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectSettingsTest.java
@@ -29,8 +29,8 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.utils.MessageException;
-import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.BootstrapProperties;
+import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.GlobalSettings;
import org.sonar.batch.protocol.input.GlobalRepositories;
import org.sonar.batch.protocol.input.ProjectRepositories;
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java
index a2ce7e460b3..e5189633d8a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/AdditionalFilePredicatesTest.java
@@ -24,7 +24,6 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
import static org.assertj.core.api.Assertions.assertThat;
@@ -37,10 +36,10 @@ public class AdditionalFilePredicatesTest {
public void key() {
FilePredicate predicate = new AdditionalFilePredicates.KeyPredicate("struts:Action.java");
- DefaultInputFile inputFile = new DeprecatedDefaultInputFile("struts", "Action.java");
+ DefaultInputFile inputFile = new DefaultInputFile("struts", "Action.java");
assertThat(predicate.apply(inputFile)).isTrue();
- inputFile = new DeprecatedDefaultInputFile("struts", "Filter.java");
+ inputFile = new DefaultInputFile("struts", "Filter.java");
assertThat(predicate.apply(inputFile)).isFalse();
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
index c62ccb0ae8c..b5b8732d5f9 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
@@ -29,8 +29,12 @@ import org.sonar.api.batch.SonarIndex;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.AbstractLanguage;
+import org.sonar.api.resources.Java;
+import org.sonar.api.resources.Languages;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
import org.sonar.batch.index.BatchResource;
import org.sonar.batch.index.ResourceCache;
@@ -120,7 +124,7 @@ public class ComponentIndexerTest {
private DefaultInputFile newInputFile(String path, String content, String sourceRelativePath, String languageKey, boolean unitTest) throws IOException {
File file = new File(baseDir, path);
FileUtils.write(file, content);
- return new DeprecatedDefaultInputFile("foo", path)
+ return new DefaultInputFile("foo", path)
.setLanguage(languageKey)
.setType(unitTest ? InputFile.Type.TEST : InputFile.Type.MAIN);
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java
index c33afe1f59f..e1c0eb4c65e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystemTest.java
@@ -27,7 +27,7 @@ import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
@@ -136,8 +136,8 @@ public class DefaultModuleFileSystemTest {
new Project("foo"), settings, fileIndexer, initializer, componentIndexer);
File baseDir = temp.newFile();
- InputFile mainInput = new DeprecatedDefaultInputFile("foo", "Main.java").setModuleBaseDir(baseDir.toPath()).setType(InputFile.Type.MAIN);
- InputFile testInput = new DeprecatedDefaultInputFile("foo", "Test.java").setModuleBaseDir(baseDir.toPath()).setType(InputFile.Type.TEST);
+ InputFile mainInput = new DefaultInputFile("foo", "Main.java").setModuleBaseDir(baseDir.toPath()).setType(InputFile.Type.MAIN);
+ InputFile testInput = new DefaultInputFile("foo", "Test.java").setModuleBaseDir(baseDir.toPath()).setType(InputFile.Type.TEST);
when(moduleInputFileCache.inputFiles()).thenReturn(Lists.newArrayList(mainInput, testInput));
fs.index();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java
index 2797d65ea20..d27a913b0d7 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/DeprecatedFileFiltersTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.ArgumentCaptor;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.scan.filesystem.FileSystemFilter;
import org.sonar.api.scan.filesystem.FileType;
@@ -49,7 +49,7 @@ public class DeprecatedFileFiltersTest {
public void no_filters() {
DeprecatedFileFilters filters = new DeprecatedFileFilters();
- InputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java");
+ InputFile inputFile = new DefaultInputFile("foo", "src/main/java/Foo.java");
assertThat(filters.accept(inputFile)).isTrue();
}
@@ -59,7 +59,7 @@ public class DeprecatedFileFiltersTest {
File basedir = temp.newFolder();
File file = new File(basedir, "src/main/java/Foo.java");
- InputFile inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java")
+ InputFile inputFile = new DefaultInputFile("foo", "src/main/java/Foo.java")
.setModuleBaseDir(basedir.toPath())
.setType(InputFile.Type.MAIN);
when(filter.accept(eq(file), any(DeprecatedFileFilters.DeprecatedContext.class))).thenReturn(false);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
index 805749c2d3a..ff304db2e22 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
@@ -24,7 +24,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.FileMetadata;
import org.sonar.api.config.Settings;
import org.sonar.api.scan.filesystem.PathResolver;
@@ -68,7 +68,7 @@ public class InputFileBuilderTest {
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
- DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
+ DefaultInputFile inputFile = builder.create(srcFile);
builder.completeAndComputeMetadata(inputFile, InputFile.Type.MAIN);
assertThat(inputFile.type()).isEqualTo(InputFile.Type.MAIN);
@@ -91,7 +91,7 @@ public class InputFileBuilderTest {
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
- DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
+ DefaultInputFile inputFile = builder.create(srcFile);
assertThat(inputFile).isNull();
}
@@ -111,7 +111,7 @@ public class InputFileBuilderTest {
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
- DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
+ DefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.completeAndComputeMetadata(inputFile, InputFile.Type.MAIN);
assertThat(inputFile).isNull();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputPathCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputPathCacheTest.java
index 67caca6a48a..70cc1f26f04 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputPathCacheTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputPathCacheTest.java
@@ -28,7 +28,6 @@ import org.sonar.api.batch.fs.InputFile.Status;
import org.sonar.api.batch.fs.InputFile.Type;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
import java.nio.charset.StandardCharsets;
@@ -52,7 +51,7 @@ public class InputPathCacheTest {
InputPathCache cache = new InputPathCache();
DefaultInputFile fooFile = new DefaultInputFile("foo", "src/main/java/Foo.java").setModuleBaseDir(temp.newFolder().toPath());
cache.put("struts", fooFile);
- cache.put("struts-core", new DeprecatedDefaultInputFile("foo", "src/main/java/Bar.java")
+ cache.put("struts-core", new DefaultInputFile("foo", "src/main/java/Bar.java")
.setLanguage("bla")
.setType(Type.MAIN)
.setStatus(Status.ADDED)
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java
index 93b4d05145a..2adb08c91b9 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java
@@ -19,13 +19,13 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.batch.repository.language.DefaultLanguagesRepository;
-import org.sonar.batch.repository.language.LanguagesRepository;
-
import org.junit.Test;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Languages;
+import org.sonar.batch.repository.language.DefaultLanguagesRepository;
+import org.sonar.batch.repository.language.LanguagesRepository;
+
import static org.assertj.core.api.Assertions.assertThat;
public class LanguageDetectionFactoryTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
index 8d6cf8bfaf8..67e450093a2 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapterTest.java
@@ -29,7 +29,9 @@ import java.io.File;
import java.io.IOException;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class ProjectFileSystemAdapterTest {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java
index 43b4131b007..0a346666ad5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/report/JSONReportTest.java
@@ -28,7 +28,7 @@ import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputDir;
-import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
import org.sonar.api.config.Settings;
@@ -81,7 +81,7 @@ public class JSONReportTest {
when(server.getVersion()).thenReturn("3.6");
userRepository = mock(UserRepository.class);
DefaultInputDir inputDir = new DefaultInputDir("struts", "src/main/java/org/apache/struts");
- DeprecatedDefaultInputFile inputFile = new DeprecatedDefaultInputFile("struts", "src/main/java/org/apache/struts/Action.java");
+ DefaultInputFile inputFile = new DefaultInputFile("struts", "src/main/java/org/apache/struts/Action.java");
inputFile.setStatus(InputFile.Status.CHANGED);
InputPathCache fileCache = mock(InputPathCache.class);
when(fileCache.allFiles()).thenReturn(Arrays.<InputFile>asList(inputFile));
diff --git a/sonar-batch/src/test/java/org/sonar/batch/util/DeprecatedKeyUtilsTest.java b/sonar-batch/src/test/java/org/sonar/batch/util/DeprecatedKeyUtilsTest.java
deleted file mode 100644
index e365775bb02..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/util/DeprecatedKeyUtilsTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.batch.util;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DeprecatedKeyUtilsTest {
-
- @Test
- public void testGetJavaFileParentDeprecatedKey() {
- assertThat(DeprecatedKeyUtils.getJavaFileParentDeprecatedKey("org.foo.bar.Hello")).isEqualTo("org/foo/bar");
- assertThat(DeprecatedKeyUtils.getJavaFileParentDeprecatedKey("[default].Hello")).isEqualTo("[root]");
- assertThat(DeprecatedKeyUtils.getJavaFileParentDeprecatedKey("Hello")).isEqualTo("[root]");
- }
-
- @Test
- public void testGetJavaFileDeprecatedKey() {
- assertThat(DeprecatedKeyUtils.getJavaFileDeprecatedKey("org/foo/bar/Hello.java")).isEqualTo("org.foo.bar.Hello");
- assertThat(DeprecatedKeyUtils.getJavaFileDeprecatedKey("Hello.java")).isEqualTo("[default].Hello");
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java
deleted file mode 100644
index f70d4a75eea..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFile.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.api.batch.fs.internal;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-/**
- * @since 4.2
- */
-public class DeprecatedDefaultInputFile extends DefaultInputFile implements org.sonar.api.resources.InputFile {
-
- public DeprecatedDefaultInputFile(String moduleKey, String relativePath) {
- super(moduleKey, relativePath);
- }
-
- /**
- * @deprecated in 4.2. Replaced by {@link org.sonar.api.batch.fs.FileSystem#baseDir()}
- */
- @Deprecated
- @Override
- public File getFileBaseDir() {
- return moduleBaseDir.toFile();
- }
-
- /**
- * @deprecated in 4.2. Use {@link #file()}
- */
- @Deprecated
- @Override
- public File getFile() {
- return file();
- }
-
- /**
- * @deprecated in 4.2. Use {@link #relativePath()}
- */
- @Deprecated
- @Override
- public String getRelativePath() {
- return relativePath();
- }
-
- @Override
- public InputStream getInputStream() throws FileNotFoundException {
- return new BufferedInputStream(new FileInputStream(file()));
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFileTest.java
deleted file mode 100644
index 2dd4cce3fe4..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DeprecatedDefaultInputFileTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.sonar.api.batch.fs.internal;
-
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.
- */
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.fs.InputFile;
-
-import java.io.File;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DeprecatedDefaultInputFileTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Test
- public void test() throws Exception {
- DeprecatedDefaultInputFile inputFile = (DeprecatedDefaultInputFile) new DeprecatedDefaultInputFile("ABCDE", "src/Foo.php")
- .setModuleBaseDir(temp.newFolder().toPath())
- .setLines(42)
- .setLanguage("php")
- .setStatus(InputFile.Status.ADDED)
- .setType(InputFile.Type.TEST);
-
- assertThat(inputFile.relativePath()).isEqualTo("src/Foo.php");
- // deprecated method is different -> path relative to source dir
- assertThat(inputFile.getRelativePath()).isEqualTo("src/Foo.php");
- assertThat(new File(inputFile.relativePath())).isRelative();
- assertThat(inputFile.absolutePath()).endsWith("Foo.php");
- assertThat(new File(inputFile.absolutePath())).isAbsolute();
- assertThat(inputFile.language()).isEqualTo("php");
- assertThat(inputFile.status()).isEqualTo(InputFile.Status.ADDED);
- assertThat(inputFile.type()).isEqualTo(InputFile.Type.TEST);
- assertThat(inputFile.lines()).isEqualTo(42);
- }
-
- @Test
- public void test_equals_and_hashcode() throws Exception {
- DefaultInputFile f1 = new DefaultInputFile("ABCDE", "src/Foo.php");
- DefaultInputFile f1a = new DefaultInputFile("ABCDE", "src/Foo.php");
- DefaultInputFile f2 = new DefaultInputFile("ABCDE", "src/Bar.php");
-
- assertThat(f1).isEqualTo(f1);
- assertThat(f1).isEqualTo(f1a);
- assertThat(f1).isNotEqualTo(f2);
- assertThat(f1.equals("foo")).isFalse();
- assertThat(f1.equals(null)).isFalse();
-
- assertThat(f1.hashCode()).isEqualTo(f1.hashCode());
- assertThat(f1.hashCode()).isEqualTo(f1a.hashCode());
- }
-
- @Test
- public void test_toString() throws Exception {
- DefaultInputFile file = new DefaultInputFile("ABCDE", "src/Foo.php");
- assertThat(file.toString()).isEqualTo("[moduleKey=ABCDE, relative=src/Foo.php, basedir=null]");
- }
-}