aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-10-19 14:25:51 +0200
committerSonarTech <sonartech@sonarsource.com>2018-11-07 20:21:02 +0100
commit945beaac05d9a6b77b300ce877d4046f5918eded (patch)
treea7807f43e19a3777911b16c10fa27a1b90cd0bc5 /sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd
parent647a6bbfd4ec768467ba75c82977e88bea1e8e2e (diff)
downloadsonarqube-945beaac05d9a6b77b300ce877d4046f5918eded.tar.gz
sonarqube-945beaac05d9a6b77b300ce877d4046f5918eded.zip
SONAR-11367 skip CPD for unchanged files in SLB
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
index 929afe6a7c0..ce60085a323 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
@@ -77,6 +77,7 @@ public class CpdExecutorTest {
private ExecutorService executorService = mock(ExecutorService.class);
private CpdSettings settings = mock(CpdSettings.class);
private ReportPublisher publisher = mock(ReportPublisher.class);
+ private BranchConfiguration branchConfiguration = mock(BranchConfiguration.class);
private SonarCpdBlockIndex index = new SonarCpdBlockIndex(publisher, settings);
private ScannerReportReader reader;
private DefaultInputFile batchComponent1;
@@ -94,7 +95,7 @@ public class CpdExecutorTest {
DefaultInputModule inputModule = TestInputFileBuilder.newDefaultInputModule("foo", baseDir);
componentStore = new InputComponentStore(inputModule, mock(BranchConfiguration.class));
- executor = new CpdExecutor(settings, index, publisher, componentStore, executorService);
+ executor = new CpdExecutor(settings, index, publisher, componentStore, branchConfiguration, executorService);
reader = new ScannerReportReader(outputDir);
batchComponent1 = createComponent("src/Foo.php", 5);
@@ -197,7 +198,11 @@ public class CpdExecutorTest {
@Test
public void should_ignore_unmodified_files_in_SLB() {
- Block block = Block.builder().setBlockHash(new ByteArray("AAAABBBBCCCC")).build();
+ when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ Block block = Block.builder()
+ .setBlockHash(new ByteArray("AAAABBBBCCCC"))
+ .setResourceId(batchComponent4.key())
+ .build();
index.insert(batchComponent4, Collections.singletonList(block));
executor.execute();