aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-11-29 17:07:21 +0100
committersonartech <sonartech@sonarsource.com>2019-01-16 09:43:04 +0100
commita00e567bffae6300381d11989bfda011d2f85aba (patch)
treec35be0ea15bdde4b352c6eb452e3ffe4bfd2083a /sonar-scanner-engine/src/test
parentb7d07953ea890469dca6f917399dba7edfd5f4ed (diff)
downloadsonarqube-a00e567bffae6300381d11989bfda011d2f85aba.tar.gz
sonarqube-a00e567bffae6300381d11989bfda011d2f85aba.zip
SONAR-11465 Move post-job at project level
Diffstat (limited to 'sonar-scanner-engine/src/test')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionnaryTest.java110
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/SensorExtensionDictionnaryTest.java (renamed from sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerExtensionDictionnaryTest.java)104
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleCoverageExclusionsTest.java11
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/PostJobsExecutorTest.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/SensorsExecutorTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java10
8 files changed, 174 insertions, 84 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionnaryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionnaryTest.java
new file mode 100644
index 00000000000..a3b55c69e13
--- /dev/null
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionnaryTest.java
@@ -0,0 +1,110 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.scanner.bootstrap;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.batch.Phase;
+import org.sonar.api.batch.postjob.PostJob;
+import org.sonar.api.batch.postjob.PostJobContext;
+import org.sonar.api.batch.postjob.PostJobDescriptor;
+import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
+import org.sonar.api.batch.sensor.Sensor;
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.SensorDescriptor;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.scanner.postjob.PostJobOptimizer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class PostJobExtensionDictionnaryTest {
+ private PostJobOptimizer postJobOptimizer = mock(PostJobOptimizer.class);
+
+ @Before
+ public void setUp() {
+ when(postJobOptimizer.shouldExecute(any(DefaultPostJobDescriptor.class))).thenReturn(true);
+ }
+
+ private PostJobExtensionDictionnary newSelector(Object... extensions) {
+ ComponentContainer iocContainer = new ComponentContainer();
+ for (Object extension : extensions) {
+ iocContainer.addSingleton(extension);
+ }
+ return new PostJobExtensionDictionnary(iocContainer, postJobOptimizer, mock(PostJobContext.class));
+ }
+
+ @Test
+ public void dependsUponPhaseForPostJob() {
+ PrePostJob pre = new PrePostJob();
+ NormalPostJob normal = new NormalPostJob();
+
+ PostJobExtensionDictionnary selector = newSelector(normal, pre);
+ assertThat(selector.selectPostJobs()).extracting("wrappedPostJob").containsExactly(pre, normal);
+ }
+
+ interface Marker {
+
+ }
+
+ @Phase(name = Phase.Name.POST)
+ class PostSensor implements Sensor {
+
+ @Override
+ public void describe(SensorDescriptor descriptor) {
+ }
+
+ @Override
+ public void execute(SensorContext context) {
+ }
+
+ }
+
+ class PostSensorSubclass extends PostSensor {
+
+ }
+
+ class NormalPostJob implements PostJob {
+
+ @Override
+ public void describe(PostJobDescriptor descriptor) {
+ }
+
+ @Override
+ public void execute(PostJobContext context) {
+ }
+
+ }
+
+ @Phase(name = Phase.Name.PRE)
+ class PrePostJob implements PostJob {
+
+ @Override
+ public void describe(PostJobDescriptor descriptor) {
+ }
+
+ @Override
+ public void execute(PostJobContext context) {
+ }
+
+ }
+}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerExtensionDictionnaryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/SensorExtensionDictionnaryTest.java
index 7ddf235b0cd..b922b3a99ad 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerExtensionDictionnaryTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/SensorExtensionDictionnaryTest.java
@@ -30,16 +30,11 @@ import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
import org.sonar.api.batch.Phase;
import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.batch.postjob.PostJob;
-import org.sonar.api.batch.postjob.PostJobContext;
-import org.sonar.api.batch.postjob.PostJobDescriptor;
-import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.core.platform.ComponentContainer;
-import org.sonar.scanner.postjob.PostJobOptimizer;
import org.sonar.scanner.sensor.DefaultSensorContext;
import org.sonar.scanner.sensor.SensorOptimizer;
import org.sonar.scanner.sensor.SensorWrapper;
@@ -50,22 +45,20 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class ScannerExtensionDictionnaryTest {
+public class SensorExtensionDictionnaryTest {
private SensorOptimizer sensorOptimizer = mock(SensorOptimizer.class);
- private PostJobOptimizer postJobOptimizer = mock(PostJobOptimizer.class);
@Before
public void setUp() {
when(sensorOptimizer.shouldExecute(any(DefaultSensorDescriptor.class))).thenReturn(true);
- when(postJobOptimizer.shouldExecute(any(DefaultPostJobDescriptor.class))).thenReturn(true);
}
- private ScannerExtensionDictionnary newSelector(Object... extensions) {
+ private SensorExtensionDictionnary newSelector(Object... extensions) {
ComponentContainer iocContainer = new ComponentContainer();
for (Object extension : extensions) {
iocContainer.addSingleton(extension);
}
- return new ScannerExtensionDictionnary(iocContainer, mock(DefaultSensorContext.class), sensorOptimizer, postJobOptimizer, mock(PostJobContext.class));
+ return new SensorExtensionDictionnary(iocContainer, mock(DefaultSensorContext.class), sensorOptimizer);
}
@Test
@@ -73,7 +66,7 @@ public class ScannerExtensionDictionnaryTest {
final Sensor sensor1 = new FakeSensor();
final Sensor sensor2 = new FakeSensor();
- ScannerExtensionDictionnary selector = newSelector(sensor1, sensor2);
+ SensorExtensionDictionnary selector = newSelector(sensor1, sensor2);
Collection<Sensor> sensors = selector.select(Sensor.class, true, extension -> extension.equals(sensor1));
assertThat(sensors).contains(sensor1);
assertEquals(1, sensors.size());
@@ -85,7 +78,7 @@ public class ScannerExtensionDictionnaryTest {
Sensor sensor2 = new FakeSensor();
FieldDecorated.Decorator decorator = mock(FieldDecorated.Decorator.class);
- ScannerExtensionDictionnary selector = newSelector(sensor1, sensor2, decorator);
+ SensorExtensionDictionnary selector = newSelector(sensor1, sensor2, decorator);
Collection<Sensor> sensors = selector.select(Sensor.class, false, null);
assertThat(sensors).containsOnly(sensor1, sensor2);
@@ -106,8 +99,7 @@ public class ScannerExtensionDictionnaryTest {
ComponentContainer child = parent.createChild();
child.addSingleton(c);
- ScannerExtensionDictionnary dictionnary = new ScannerExtensionDictionnary(child, mock(DefaultSensorContext.class),
- mock(SensorOptimizer.class), mock(PostJobOptimizer.class), mock(PostJobContext.class));
+ SensorExtensionDictionnary dictionnary = new SensorExtensionDictionnary(child, mock(DefaultSensorContext.class), mock(SensorOptimizer.class));
assertThat(dictionnary.select(Sensor.class, true, null)).containsOnly(a, b, c);
}
@@ -117,7 +109,7 @@ public class ScannerExtensionDictionnaryTest {
Object b = new MethodDependentOf(a);
Object c = new MethodDependentOf(b);
- ScannerExtensionDictionnary selector = newSelector(b, c, a);
+ SensorExtensionDictionnary selector = newSelector(b, c, a);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(3);
@@ -131,7 +123,7 @@ public class ScannerExtensionDictionnaryTest {
Object a = new GeneratesSomething("foo");
Object b = new MethodDependentOf("foo");
- ScannerExtensionDictionnary selector = newSelector(a, b);
+ SensorExtensionDictionnary selector = newSelector(a, b);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions.size()).isEqualTo(2);
@@ -152,7 +144,7 @@ public class ScannerExtensionDictionnaryTest {
Object a = new GeneratesSomething("foo");
Object b = new MethodDependentOf(Arrays.asList("foo"));
- ScannerExtensionDictionnary selector = newSelector(a, b);
+ SensorExtensionDictionnary selector = newSelector(a, b);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
@@ -173,7 +165,7 @@ public class ScannerExtensionDictionnaryTest {
Object a = new GeneratesSomething("foo");
Object b = new MethodDependentOf(new String[] {"foo"});
- ScannerExtensionDictionnary selector = newSelector(a, b);
+ SensorExtensionDictionnary selector = newSelector(a, b);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
@@ -194,7 +186,7 @@ public class ScannerExtensionDictionnaryTest {
Object a = new ClassDependedUpon();
Object b = new ClassDependsUpon();
- ScannerExtensionDictionnary selector = newSelector(a, b);
+ SensorExtensionDictionnary selector = newSelector(a, b);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
@@ -217,7 +209,7 @@ public class ScannerExtensionDictionnaryTest {
Object b = new InterfaceDependsUpon() {
};
- ScannerExtensionDictionnary selector = newSelector(a, b);
+ SensorExtensionDictionnary selector = newSelector(a, b);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
@@ -238,7 +230,7 @@ public class ScannerExtensionDictionnaryTest {
Object a = new SubClass("foo");
Object b = new MethodDependentOf("foo");
- ScannerExtensionDictionnary selector = newSelector(b, a);
+ SensorExtensionDictionnary selector = newSelector(b, a);
List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null));
assertThat(extensions).hasSize(2);
@@ -256,7 +248,7 @@ public class ScannerExtensionDictionnaryTest {
@Test(expected = IllegalStateException.class)
public void annotatedMethodsCanNotBePrivate() {
- ScannerExtensionDictionnary selector = newSelector();
+ SensorExtensionDictionnary selector = newSelector();
Object wrong = new Object() {
@DependsUpon
private Object foo() {
@@ -272,26 +264,17 @@ public class ScannerExtensionDictionnaryTest {
NormalSensor normal = new NormalSensor();
PostSensor post = new PostSensor();
- ScannerExtensionDictionnary selector = newSelector(normal, post, pre);
+ SensorExtensionDictionnary selector = newSelector(normal, post, pre);
assertThat(selector.selectSensors(false)).extracting("wrappedSensor").containsExactly(pre, normal, post);
}
@Test
- public void dependsUponPhaseForPostJob() {
- PrePostJob pre = new PrePostJob();
- NormalPostJob normal = new NormalPostJob();
-
- ScannerExtensionDictionnary selector = newSelector(normal, pre);
- assertThat(selector.selectPostJobs()).extracting("wrappedPostJob").containsExactly(pre, normal);
- }
-
- @Test
public void dependsUponInheritedPhase() {
PreSensorSubclass pre = new PreSensorSubclass();
NormalSensor normal = new NormalSensor();
PostSensorSubclass post = new PostSensorSubclass();
- ScannerExtensionDictionnary selector = newSelector(normal, post, pre);
+ SensorExtensionDictionnary selector = newSelector(normal, post, pre);
List extensions = Lists.newArrayList(selector.select(Sensor.class, true, null));
assertThat(extensions).containsExactly(pre, normal, post);
@@ -301,7 +284,7 @@ public class ScannerExtensionDictionnaryTest {
public void selectSensors() {
FakeSensor nonGlobalSensor = new FakeSensor();
FakeGlobalSensor globalSensor = new FakeGlobalSensor();
- ScannerExtensionDictionnary selector = newSelector(nonGlobalSensor, globalSensor);
+ SensorExtensionDictionnary selector = newSelector(nonGlobalSensor, globalSensor);
// verify non-global sensor
Collection<SensorWrapper> extensions = selector.selectSensors(false);
@@ -319,11 +302,13 @@ public class ScannerExtensionDictionnaryTest {
class FakeSensor implements Sensor {
- @Override public void describe(SensorDescriptor descriptor) {
+ @Override
+ public void describe(SensorDescriptor descriptor) {
}
- @Override public void execute(SensorContext context) {
+ @Override
+ public void execute(SensorContext context) {
}
}
@@ -341,7 +326,8 @@ public class ScannerExtensionDictionnaryTest {
}
- @ScannerSide class MethodDependentOf implements Marker {
+ @ScannerSide
+ class MethodDependentOf implements Marker {
private Object dep;
MethodDependentOf(Object o) {
@@ -355,22 +341,27 @@ public class ScannerExtensionDictionnaryTest {
}
@ScannerSide
- @DependsUpon("flag") class ClassDependsUpon implements Marker {
+ @DependsUpon("flag")
+ class ClassDependsUpon implements Marker {
}
@ScannerSide
- @DependedUpon("flag") class ClassDependedUpon implements Marker {
+ @DependedUpon("flag")
+ class ClassDependedUpon implements Marker {
}
@ScannerSide
- @DependsUpon("flag") interface InterfaceDependsUpon extends Marker {
+ @DependsUpon("flag")
+ interface InterfaceDependsUpon extends Marker {
}
@ScannerSide
- @DependedUpon("flag") interface InterfaceDependedUpon extends Marker {
+ @DependedUpon("flag")
+ interface InterfaceDependedUpon extends Marker {
}
- @ScannerSide class GeneratesSomething implements Marker {
+ @ScannerSide
+ class GeneratesSomething implements Marker {
private Object gen;
GeneratesSomething(Object o) {
@@ -401,7 +392,8 @@ public class ScannerExtensionDictionnaryTest {
}
- @Phase(name = Phase.Name.PRE) class PreSensor implements Sensor {
+ @Phase(name = Phase.Name.PRE)
+ class PreSensor implements Sensor {
@Override
public void describe(SensorDescriptor descriptor) {
@@ -417,7 +409,8 @@ public class ScannerExtensionDictionnaryTest {
}
- @Phase(name = Phase.Name.POST) class PostSensor implements Sensor {
+ @Phase(name = Phase.Name.POST)
+ class PostSensor implements Sensor {
@Override
public void describe(SensorDescriptor descriptor) {
@@ -433,27 +426,4 @@ public class ScannerExtensionDictionnaryTest {
}
- class NormalPostJob implements PostJob {
-
- @Override
- public void describe(PostJobDescriptor descriptor) {
- }
-
- @Override
- public void execute(PostJobContext context) {
- }
-
- }
-
- @Phase(name = Phase.Name.PRE) class PrePostJob implements PostJob {
-
- @Override
- public void describe(PostJobDescriptor descriptor) {
- }
-
- @Override
- public void execute(PostJobContext context) {
- }
-
- }
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
index bcc778dc724..6c2f47ff34c 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumTest.java
@@ -574,7 +574,7 @@ public class FileSystemMediumTest {
assertThat(fileB).isNull();
assertThat(logTester.logs(LoggerLevel.WARN))
- .contains("File 'moduleB/src/sample.xoo' was excluded because patterns are still evaluated using module relative paths but this is deprecated. " +
+ .contains("File 'moduleA/src/sample.xoo' was excluded because patterns are still evaluated using module relative paths but this is deprecated. " +
"Please update file inclusion/exclusion configuration so that patterns refer to project relative paths.");
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleCoverageExclusionsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleCoverageExclusionsTest.java
index 6d95e2ff828..6be5efa45a9 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleCoverageExclusionsTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleCoverageExclusionsTest.java
@@ -20,11 +20,15 @@
package org.sonar.scanner.phases;
import java.io.File;
+import java.util.Arrays;
+import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
+import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.scanner.scan.ModuleConfiguration;
@@ -63,9 +67,12 @@ public class ModuleCoverageExclusionsTest {
assertThat(coverageExclusions.isExcluded(file)).isFalse();
}
- private ModuleConfiguration mockConfig(String... values) {
+ private DefaultInputModule mockConfig(String... values) {
ModuleConfiguration config = mock(ModuleConfiguration.class);
when(config.getStringArray("sonar.coverage.exclusions")).thenReturn(values);
- return config;
+ return new DefaultInputModule(ProjectDefinition.create()
+ .setBaseDir(baseDir)
+ .setWorkDir(baseDir)
+ .setProperty("sonar.coverage.exclusions", Arrays.asList(values).stream().collect(Collectors.joining(","))));
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/PostJobsExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/PostJobsExecutorTest.java
index f4a8ed15f92..92e7bc2a8ce 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/PostJobsExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/PostJobsExecutorTest.java
@@ -22,8 +22,9 @@ package org.sonar.scanner.phases;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
+import org.sonar.scanner.bootstrap.PostJobExtensionDictionnary;
import org.sonar.scanner.postjob.PostJobWrapper;
+import org.sonar.scanner.postjob.PostJobsExecutor;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -33,7 +34,7 @@ import static org.mockito.Mockito.when;
public class PostJobsExecutorTest {
private PostJobsExecutor executor;
- private ScannerExtensionDictionnary selector = mock(ScannerExtensionDictionnary.class);
+ private PostJobExtensionDictionnary selector = mock(PostJobExtensionDictionnary.class);
private PostJobWrapper job1 = mock(PostJobWrapper.class);
private PostJobWrapper job2 = mock(PostJobWrapper.class);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/SensorsExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/SensorsExecutorTest.java
index ca97a46a6fc..de31e20e3c3 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/SensorsExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/SensorsExecutorTest.java
@@ -31,7 +31,7 @@ import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
import org.sonar.api.batch.fs.internal.SensorStrategy;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.sensor.Sensor;
-import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;
+import org.sonar.scanner.bootstrap.SensorExtensionDictionnary;
import org.sonar.scanner.bootstrap.ScannerPluginRepository;
import org.sonar.scanner.sensor.SensorWrapper;
@@ -64,7 +64,7 @@ public class SensorsExecutorTest {
when(globalSensor.shouldExecute()).thenReturn(true);
when(globalSensor.wrappedSensor()).thenReturn(mock(Sensor.class));
- ScannerExtensionDictionnary selector = mock(ScannerExtensionDictionnary.class);
+ SensorExtensionDictionnary selector = mock(SensorExtensionDictionnary.class);
when(selector.selectSensors(false)).thenReturn(Collections.singleton(perModuleSensor));
when(selector.selectSensors(true)).thenReturn(Collections.singleton(globalSensor));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
index ee736b0578f..98785e06e62 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputComponentStoreTest.java
@@ -84,8 +84,8 @@ public class InputComponentStoreTest {
assertThat(store.filesByModule(rootModuleKey)).hasSize(1);
assertThat(store.filesByModule(subModuleKey)).hasSize(1);
- assertThat(store.allFiles()).hasSize(2);
- for (InputPath inputPath : store.allFiles()) {
+ assertThat(store.inputFiles()).hasSize(2);
+ for (InputPath inputPath : store.inputFiles()) {
assertThat(inputPath.relativePath()).startsWith("src/main/java/");
}
@@ -118,9 +118,9 @@ public class InputComponentStoreTest {
String mod2Key = "mod2";
tester.addFile(mod2Key, "src/main/groovy/Foo.groovy", "groovy");
- assertThat(tester.getLanguages(mod1Key)).containsExactly("java");
- assertThat(tester.getLanguages(mod2Key)).containsExactly("groovy");
- assertThat(tester.getLanguages()).containsExactlyInAnyOrder("java", "groovy");
+ assertThat(tester.languages(mod1Key)).containsExactly("java");
+ assertThat(tester.languages(mod2Key)).containsExactly("groovy");
+ assertThat(tester.languages()).containsExactlyInAnyOrder("java", "groovy");
}
@Test
@@ -135,6 +135,6 @@ public class InputComponentStoreTest {
assertThat(tester.filesByModule(mod1Key)).containsExactly(mod1File);
assertThat(tester.filesByModule(mod2Key)).containsExactly(mod2File);
- assertThat(tester.allFiles()).containsExactlyInAnyOrder(mod1File, mod2File);
+ assertThat(tester.inputFiles()).containsExactlyInAnyOrder(mod1File, mod2File);
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
index cb1b4793940..29064edd51b 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/ModuleInputComponentStoreTest.java
@@ -127,6 +127,8 @@ public class ModuleInputComponentStoreTest {
when(module.key()).thenReturn("foo");
ModuleInputComponentStore store = new ModuleInputComponentStore(module, inputComponentStore, strategy);
+ strategy.setGlobal(false);
+
store.inputFiles();
verify(inputComponentStore).filesByModule("foo");
@@ -135,7 +137,7 @@ public class ModuleInputComponentStoreTest {
verify(inputComponentStore).getFile(any(String.class), eq(relativePath));
store.languages();
- verify(inputComponentStore).getLanguages(any(String.class));
+ verify(inputComponentStore).languages(any(String.class));
}
@Test
@@ -147,13 +149,13 @@ public class ModuleInputComponentStoreTest {
strategy.setGlobal(true);
store.inputFiles();
- verify(inputComponentStore).allFiles();
+ verify(inputComponentStore).inputFiles();
String relativePath = "somepath";
store.inputFile(relativePath);
- verify(inputComponentStore).getFile(relativePath);
+ verify(inputComponentStore).inputFile(relativePath);
store.languages();
- verify(inputComponentStore).getLanguages();
+ verify(inputComponentStore).languages();
}
}