aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-08-01 11:26:22 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-08-01 11:49:42 +0200
commit8d91875b28c2ef7c274781a9507edf512716a372 (patch)
tree8cd6f09f768bf86666060b97c396e9862ea44c32 /sonar-batch
parent57dff3366d1b1dfb995b1009aa4dd2077507569a (diff)
downloadsonarqube-8d91875b28c2ef7c274781a9507edf512716a372.tar.gz
sonarqube-8d91875b28c2ef7c274781a9507edf512716a372.zip
SONAR-5389 Improve duplication API
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultDuplicationBuilder.java74
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultTokenBuilder.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationBlockValueCoder.java1
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java11
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroup.java76
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroupValueCoder.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DuplicationPersister.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/SensorContextAdaptor.java21
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java21
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/duplication/DuplicationCacheTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DuplicationPersisterTest.java6
12 files changed, 56 insertions, 175 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultDuplicationBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultDuplicationBuilder.java
deleted file mode 100644
index d6dd18026a2..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultDuplicationBuilder.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.duplication;
-
-import com.google.common.base.Preconditions;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.duplication.DuplicationBuilder;
-
-import java.util.ArrayList;
-
-public class DefaultDuplicationBuilder implements DuplicationBuilder {
-
- private final InputFile inputFile;
- private final DuplicationCache duplicationCache;
- private boolean done = false;
- private DuplicationGroup current = null;
- private ArrayList<DuplicationGroup> duplications;
-
- public DefaultDuplicationBuilder(InputFile inputFile, DuplicationCache duplicationCache) {
- this.inputFile = inputFile;
- this.duplicationCache = duplicationCache;
- duplications = new ArrayList<DuplicationGroup>();
- }
-
- @Override
- public DuplicationBuilder originBlock(int startLine, int endLine) {
- if (current != null) {
- duplications.add(current);
- }
- current = new DuplicationGroup(new DuplicationGroup.Block(((DefaultInputFile) inputFile).key(), startLine, endLine - startLine + 1));
- return this;
- }
-
- @Override
- public DuplicationBuilder isDuplicatedBy(InputFile sameOrOtherFile, int startLine, int endLine) {
- return isDuplicatedBy(((DefaultInputFile) sameOrOtherFile).key(), startLine, endLine);
- }
-
- /**
- * For internal use. Global duplications are referencing files outside of current project so
- * no way to manipulate an InputFile.
- */
- public DuplicationBuilder isDuplicatedBy(String fileKey, int startLine, int endLine) {
- Preconditions.checkNotNull(current, "Call originBlock() first");
- current.addDuplicate(new DuplicationGroup.Block(fileKey, startLine, endLine - startLine + 1));
- return this;
- }
-
- @Override
- public void done() {
- Preconditions.checkState(!done, "done() already called");
- Preconditions.checkNotNull(current, "Call originBlock() first");
- duplications.add(current);
- duplicationCache.put(((DefaultInputFile) inputFile).key(), duplications);
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultTokenBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultTokenBuilder.java
index 6c7836d9e39..b4af6917440 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultTokenBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/duplication/DefaultTokenBuilder.java
@@ -25,7 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.duplication.TokenBuilder;
+import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
import org.sonar.duplications.block.Block;
import org.sonar.duplications.block.FileBlocks;
import org.sonar.duplications.internal.pmd.PmdBlockChunker;
@@ -35,7 +35,7 @@ import org.sonar.duplications.internal.pmd.TokensLine;
import java.util.ArrayList;
import java.util.List;
-public class DefaultTokenBuilder implements TokenBuilder {
+public class DefaultTokenBuilder implements DuplicationTokenBuilder {
private static final Logger LOG = LoggerFactory.getLogger(DefaultTokenBuilder.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationBlockValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationBlockValueCoder.java
index ab1dad47009..26c857a5d23 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationBlockValueCoder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationBlockValueCoder.java
@@ -22,6 +22,7 @@ package org.sonar.batch.duplication;
import com.persistit.Value;
import com.persistit.encoding.CoderContext;
import com.persistit.encoding.ValueCoder;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
class DuplicationBlockValueCoder implements ValueCoder {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java
index e0265215efc..573ac7a7a13 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java
@@ -20,20 +20,21 @@
package org.sonar.batch.duplication;
import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
import org.sonar.batch.index.Cache;
import org.sonar.batch.index.Cache.Entry;
import org.sonar.batch.index.Caches;
import javax.annotation.CheckForNull;
-import java.util.ArrayList;
+import java.util.List;
/**
* Cache of duplication blocks. This cache is shared amongst all project modules.
*/
public class DuplicationCache implements BatchComponent {
- private final Cache<ArrayList<DuplicationGroup>> cache;
+ private final Cache<List<DuplicationGroup>> cache;
public DuplicationCache(Caches caches) {
caches.registerValueCoder(DuplicationGroup.class, new DuplicationGroupValueCoder());
@@ -41,16 +42,16 @@ public class DuplicationCache implements BatchComponent {
cache = caches.createCache("duplications");
}
- public Iterable<Entry<ArrayList<DuplicationGroup>>> entries() {
+ public Iterable<Entry<List<DuplicationGroup>>> entries() {
return cache.entries();
}
@CheckForNull
- public ArrayList<DuplicationGroup> byComponent(String effectiveKey) {
+ public List<DuplicationGroup> byComponent(String effectiveKey) {
return cache.get(effectiveKey);
}
- public DuplicationCache put(String effectiveKey, ArrayList<DuplicationGroup> blocks) {
+ public DuplicationCache put(String effectiveKey, List<DuplicationGroup> blocks) {
cache.put(effectiveKey, blocks);
return this;
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroup.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroup.java
deleted file mode 100644
index dc9a7aa2602..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroup.java
+++ /dev/null
@@ -1,76 +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.duplication;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class DuplicationGroup {
-
- public static class Block {
- private final String resourceKey;
- private final int startLine;
- private final int length;
-
- public Block(String resourceKey, int startLine, int length) {
- this.resourceKey = resourceKey;
- this.startLine = startLine;
- this.length = length;
- }
-
- public String resourceKey() {
- return resourceKey;
- }
-
- public int startLine() {
- return startLine;
- }
-
- public int length() {
- return length;
- }
- }
-
- private final Block originBlock;
-
- private List<Block> duplicates = new ArrayList<DuplicationGroup.Block>();
-
- public DuplicationGroup(Block originBlock) {
- this.originBlock = originBlock;
- }
-
- public void setDuplicates(List<Block> duplicates) {
- this.duplicates = duplicates;
- }
-
- public DuplicationGroup addDuplicate(Block anotherBlock) {
- this.duplicates.add(anotherBlock);
- return this;
- }
-
- public Block originBlock() {
- return originBlock;
- }
-
- public List<Block> duplicates() {
- return duplicates;
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroupValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroupValueCoder.java
index b813d728354..5b6ed6d8401 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroupValueCoder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationGroupValueCoder.java
@@ -22,7 +22,8 @@ package org.sonar.batch.duplication;
import com.persistit.Value;
import com.persistit.encoding.CoderContext;
import com.persistit.encoding.ValueCoder;
-import org.sonar.batch.duplication.DuplicationGroup.Block;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup.Block;
import java.util.ArrayList;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DuplicationPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DuplicationPersister.java
index 9ac3085880c..9461d46dfd7 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DuplicationPersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DuplicationPersister.java
@@ -20,6 +20,7 @@
package org.sonar.batch.index;
import org.apache.commons.lang.StringEscapeUtils;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
import org.sonar.api.database.model.MeasureMapper;
import org.sonar.api.database.model.MeasureModel;
import org.sonar.api.database.model.Snapshot;
@@ -29,12 +30,11 @@ import org.sonar.api.measures.PersistenceMode;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.RuleFinder;
import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.duplication.DuplicationGroup;
import org.sonar.batch.index.Cache.Entry;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import java.util.ArrayList;
+import java.util.List;
public final class DuplicationPersister implements ScanPersister {
private final MyBatis mybatis;
@@ -62,7 +62,7 @@ public final class DuplicationPersister implements ScanPersister {
try {
MeasureMapper mapper = session.getMapper(MeasureMapper.class);
org.sonar.api.measures.Metric duplicationMetricWithId = metricFinder.findByKey(CoreMetrics.DUPLICATIONS_DATA_KEY);
- for (Entry<ArrayList<DuplicationGroup>> entry : duplicationCache.entries()) {
+ for (Entry<List<DuplicationGroup>> entry : duplicationCache.entries()) {
String effectiveKey = entry.key()[0].toString();
Measure measure = new Measure(duplicationMetricWithId, toXml(entry.value())).setPersistenceMode(PersistenceMode.DATABASE);
Resource resource = resourceCache.get(effectiveKey);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
index 58cc4f461af..a42ca1ae1b0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/BatchMediumTester.java
@@ -29,6 +29,7 @@ import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.measure.Measure;
@@ -42,7 +43,6 @@ import org.sonar.batch.bootstrap.PluginsReferential;
import org.sonar.batch.bootstrapper.Batch;
import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.duplication.DuplicationGroup;
import org.sonar.batch.highlighting.SyntaxHighlightingData;
import org.sonar.batch.highlighting.SyntaxHighlightingRule;
import org.sonar.batch.index.Cache.Entry;
@@ -264,7 +264,7 @@ public class BatchMediumTester {
}
DuplicationCache duplicationCache = container.getComponentByType(DuplicationCache.class);
- for (Entry<ArrayList<DuplicationGroup>> entry : duplicationCache.entries()) {
+ for (Entry<List<DuplicationGroup>> entry : duplicationCache.entries()) {
String effectiveKey = entry.key()[0].toString();
duplications.put(effectiveKey, entry.value());
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/SensorContextAdaptor.java b/sonar-batch/src/main/java/org/sonar/batch/scan/SensorContextAdaptor.java
index d285a6c8646..1cf87b1d6d3 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/SensorContextAdaptor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/SensorContextAdaptor.java
@@ -19,6 +19,7 @@
*/
package org.sonar.batch.scan;
+import com.google.common.base.Preconditions;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
@@ -28,7 +29,9 @@ import org.sonar.api.batch.measure.Metric;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.duplication.DuplicationBuilder;
-import org.sonar.api.batch.sensor.duplication.TokenBuilder;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
+import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
+import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplicationBuilder;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.IssueBuilder;
@@ -52,7 +55,6 @@ import org.sonar.api.resources.Resource;
import org.sonar.api.resources.Scopes;
import org.sonar.api.rule.RuleKey;
import org.sonar.batch.duplication.BlockCache;
-import org.sonar.batch.duplication.DefaultDuplicationBuilder;
import org.sonar.batch.duplication.DefaultTokenBuilder;
import org.sonar.batch.duplication.DuplicationCache;
import org.sonar.batch.highlighting.DefaultHighlightingBuilder;
@@ -61,6 +63,7 @@ import org.sonar.batch.symbol.DefaultSymbolTableBuilder;
import org.sonar.duplications.internal.pmd.PmdBlockChunker;
import java.io.Serializable;
+import java.util.List;
/**
* Implements {@link SensorContext} but forward everything to {@link org.sonar.api.batch.SensorContext} for backward compatibility.
@@ -267,14 +270,24 @@ public class SensorContextAdaptor implements SensorContext {
}
@Override
- public TokenBuilder tokenBuilder(InputFile inputFile) {
+ public DuplicationTokenBuilder duplicationTokenBuilder(InputFile inputFile) {
PmdBlockChunker blockChunker = new PmdBlockChunker(getBlockSize(inputFile.language()));
return new DefaultTokenBuilder(inputFile, blockCache, blockChunker);
}
@Override
public DuplicationBuilder duplicationBuilder(InputFile inputFile) {
- return new DefaultDuplicationBuilder(inputFile, duplicationCache);
+ return new DefaultDuplicationBuilder(inputFile);
+ }
+
+ @Override
+ public void saveDuplications(InputFile inputFile, List<DuplicationGroup> duplications) {
+ Preconditions.checkState(duplications.size() > 0, "Empty duplications");
+ String effectiveKey = ((DefaultInputFile) inputFile).key();
+ for (DuplicationGroup duplicationGroup : duplications) {
+ Preconditions.checkState(effectiveKey.equals(duplicationGroup.originBlock().resourceKey()), "Invalid duplication group");
+ }
+ duplicationCache.put(effectiveKey, duplications);
}
private int getBlockSize(String languageKey) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
index 73d6429bfcd..afd21a8d358 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultSensorContext.java
@@ -19,6 +19,7 @@
*/
package org.sonar.batch.scan2;
+import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.FileSystem;
@@ -29,7 +30,9 @@ import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.rule.internal.DefaultActiveRule;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.duplication.DuplicationBuilder;
-import org.sonar.api.batch.sensor.duplication.TokenBuilder;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
+import org.sonar.api.batch.sensor.duplication.DuplicationTokenBuilder;
+import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplicationBuilder;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.IssueBuilder;
@@ -44,7 +47,6 @@ import org.sonar.api.config.Settings;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.MessageException;
import org.sonar.batch.duplication.BlockCache;
-import org.sonar.batch.duplication.DefaultDuplicationBuilder;
import org.sonar.batch.duplication.DefaultTokenBuilder;
import org.sonar.batch.duplication.DuplicationCache;
import org.sonar.batch.highlighting.DefaultHighlightingBuilder;
@@ -56,6 +58,7 @@ import org.sonar.core.component.ComponentKeys;
import org.sonar.duplications.internal.pmd.PmdBlockChunker;
import java.io.Serializable;
+import java.util.List;
public class DefaultSensorContext implements SensorContext {
@@ -188,7 +191,7 @@ public class DefaultSensorContext implements SensorContext {
}
@Override
- public TokenBuilder tokenBuilder(InputFile inputFile) {
+ public DuplicationTokenBuilder duplicationTokenBuilder(InputFile inputFile) {
PmdBlockChunker blockChunker = new PmdBlockChunker(getBlockSize(inputFile.language()));
return new DefaultTokenBuilder(inputFile, blockCache, blockChunker);
@@ -196,7 +199,17 @@ public class DefaultSensorContext implements SensorContext {
@Override
public DuplicationBuilder duplicationBuilder(InputFile inputFile) {
- return new DefaultDuplicationBuilder(inputFile, duplicationCache);
+ return new DefaultDuplicationBuilder(inputFile);
+ }
+
+ @Override
+ public void saveDuplications(InputFile inputFile, List<DuplicationGroup> duplications) {
+ Preconditions.checkState(duplications.size() > 0, "Empty duplications");
+ String effectiveKey = ((DefaultInputFile) inputFile).key();
+ for (DuplicationGroup duplicationGroup : duplications) {
+ Preconditions.checkState(effectiveKey.equals(duplicationGroup.originBlock().resourceKey()), "Invalid duplication group");
+ }
+ duplicationCache.put(effectiveKey, duplications);
}
private int getBlockSize(String languageKey) {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/duplication/DuplicationCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/duplication/DuplicationCacheTest.java
index ade701fce45..6317093f00a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/duplication/DuplicationCacheTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/duplication/DuplicationCacheTest.java
@@ -25,11 +25,13 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
import org.sonar.batch.index.Caches;
import org.sonar.batch.index.CachesTest;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import static org.fest.assertions.Assertions.assertThat;
@@ -74,7 +76,7 @@ public class DuplicationCacheTest {
assertThat(cache.entries()).hasSize(1);
- ArrayList<DuplicationGroup> entry = cache.byComponent("foo");
+ List<DuplicationGroup> entry = cache.byComponent("foo");
assertThat(entry.get(0).originBlock().resourceKey()).isEqualTo("foo");
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DuplicationPersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DuplicationPersisterTest.java
index 1860732e80d..644d7400999 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DuplicationPersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DuplicationPersisterTest.java
@@ -22,17 +22,17 @@ package org.sonar.batch.index;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.sonar.api.batch.sensor.duplication.DuplicationGroup;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.MetricFinder;
import org.sonar.api.resources.File;
import org.sonar.api.rules.RuleFinder;
import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.duplication.DuplicationGroup;
import org.sonar.core.persistence.AbstractDaoTestCase;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -77,7 +77,7 @@ public class DuplicationPersisterTest extends AbstractDaoTestCase {
.addDuplicate(new DuplicationGroup.Block("foo:org/foo/Foo.java", 5, 9));
when(duplicationCache.entries()).thenReturn(
- Arrays.<Cache.Entry<ArrayList<DuplicationGroup>>>asList(new Cache.Entry(new String[] {"foo:org/foo/Bar.java"}, Arrays.asList(group))));
+ Arrays.<Cache.Entry<List<DuplicationGroup>>>asList(new Cache.Entry(new String[] {"foo:org/foo/Bar.java"}, Arrays.asList(group))));
duplicationPersister.persist();