diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-11-23 13:06:28 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-11-29 20:03:39 +0000 |
commit | d91ea92fe22cf1b6b52a8efba122daf8e7e58282 (patch) | |
tree | cd9123d893d5f67f66cf30be326f5d61320a9d55 /sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap | |
parent | 331d44eca2bc7e646d91bf8d7d8a18f2f93c872d (diff) | |
download | sonarqube-d91ea92fe22cf1b6b52a8efba122daf8e7e58282.tar.gz sonarqube-d91ea92fe22cf1b6b52a8efba122daf8e7e58282.zip |
SONAR-15686 Files provided are restricted when PR for selected sensors
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap')
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ModuleSensorExtensionDictionaryTest.java (renamed from sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ModuleSensorExtensionDictionnaryTest.java) | 43 | ||||
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionaryTest.java (renamed from sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionnaryTest.java) | 8 |
2 files changed, 28 insertions, 23 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ModuleSensorExtensionDictionnaryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ModuleSensorExtensionDictionaryTest.java index 61481a22cdc..a539b0b51d3 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ModuleSensorExtensionDictionnaryTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ModuleSensorExtensionDictionaryTest.java @@ -35,8 +35,10 @@ 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.scan.branch.BranchConfiguration; +import org.sonar.scanner.scan.filesystem.MutableFileSystem; import org.sonar.scanner.sensor.ModuleSensorContext; -import org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary; +import org.sonar.scanner.sensor.ModuleSensorExtensionDictionary; import org.sonar.scanner.sensor.ModuleSensorOptimizer; import org.sonar.scanner.sensor.ModuleSensorWrapper; @@ -46,20 +48,22 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class ModuleSensorExtensionDictionnaryTest { - private ModuleSensorOptimizer sensorOptimizer = mock(ModuleSensorOptimizer.class); +public class ModuleSensorExtensionDictionaryTest { + private final ModuleSensorOptimizer sensorOptimizer = mock(ModuleSensorOptimizer.class); + private final MutableFileSystem fileSystem = mock(MutableFileSystem.class); + private final BranchConfiguration branchConfiguration = mock(BranchConfiguration.class); @Before public void setUp() { when(sensorOptimizer.shouldExecute(any(DefaultSensorDescriptor.class))).thenReturn(true); } - private ModuleSensorExtensionDictionnary newSelector(Object... extensions) { + private ModuleSensorExtensionDictionary newSelector(Object... extensions) { ComponentContainer iocContainer = new ComponentContainer(); for (Object extension : extensions) { iocContainer.addSingleton(extension); } - return new ModuleSensorExtensionDictionnary(iocContainer, mock(ModuleSensorContext.class), sensorOptimizer); + return new ModuleSensorExtensionDictionary(iocContainer, mock(ModuleSensorContext.class), sensorOptimizer, fileSystem, branchConfiguration); } @Test @@ -67,7 +71,7 @@ public class ModuleSensorExtensionDictionnaryTest { final Sensor sensor1 = new FakeSensor(); final Sensor sensor2 = new FakeSensor(); - ModuleSensorExtensionDictionnary selector = newSelector(sensor1, sensor2); + ModuleSensorExtensionDictionary selector = newSelector(sensor1, sensor2); Collection<Sensor> sensors = selector.select(Sensor.class, true, extension -> extension.equals(sensor1)); assertThat(sensors).contains(sensor1); assertEquals(1, sensors.size()); @@ -79,7 +83,7 @@ public class ModuleSensorExtensionDictionnaryTest { Sensor sensor2 = new FakeSensor(); FieldDecorated.Decorator decorator = mock(FieldDecorated.Decorator.class); - ModuleSensorExtensionDictionnary selector = newSelector(sensor1, sensor2, decorator); + ModuleSensorExtensionDictionary selector = newSelector(sensor1, sensor2, decorator); Collection<Sensor> sensors = selector.select(Sensor.class, false, null); assertThat(sensors).containsOnly(sensor1, sensor2); @@ -100,7 +104,8 @@ public class ModuleSensorExtensionDictionnaryTest { ComponentContainer child = parent.createChild(); child.addSingleton(c); - ModuleSensorExtensionDictionnary dictionnary = new ModuleSensorExtensionDictionnary(child, mock(ModuleSensorContext.class), mock(ModuleSensorOptimizer.class)); + ModuleSensorExtensionDictionary dictionnary = new ModuleSensorExtensionDictionary(child, mock(ModuleSensorContext.class), mock(ModuleSensorOptimizer.class), + fileSystem, branchConfiguration); assertThat(dictionnary.select(Sensor.class, true, null)).containsOnly(a, b, c); } @@ -110,7 +115,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object b = new MethodDependentOf(a); Object c = new MethodDependentOf(b); - ModuleSensorExtensionDictionnary selector = newSelector(b, c, a); + ModuleSensorExtensionDictionary selector = newSelector(b, c, a); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions).hasSize(3); @@ -124,7 +129,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object a = new GeneratesSomething("foo"); Object b = new MethodDependentOf("foo"); - ModuleSensorExtensionDictionnary selector = newSelector(a, b); + ModuleSensorExtensionDictionary selector = newSelector(a, b); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions.size()).isEqualTo(2); @@ -145,7 +150,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object a = new GeneratesSomething("foo"); Object b = new MethodDependentOf(Arrays.asList("foo")); - ModuleSensorExtensionDictionnary selector = newSelector(a, b); + ModuleSensorExtensionDictionary selector = newSelector(a, b); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions).hasSize(2); @@ -166,7 +171,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object a = new GeneratesSomething("foo"); Object b = new MethodDependentOf(new String[] {"foo"}); - ModuleSensorExtensionDictionnary selector = newSelector(a, b); + ModuleSensorExtensionDictionary selector = newSelector(a, b); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions).hasSize(2); @@ -187,7 +192,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object a = new ClassDependedUpon(); Object b = new ClassDependsUpon(); - ModuleSensorExtensionDictionnary selector = newSelector(a, b); + ModuleSensorExtensionDictionary selector = newSelector(a, b); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions).hasSize(2); @@ -210,7 +215,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object b = new InterfaceDependsUpon() { }; - ModuleSensorExtensionDictionnary selector = newSelector(a, b); + ModuleSensorExtensionDictionary selector = newSelector(a, b); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions).hasSize(2); @@ -231,7 +236,7 @@ public class ModuleSensorExtensionDictionnaryTest { Object a = new SubClass("foo"); Object b = new MethodDependentOf("foo"); - ModuleSensorExtensionDictionnary selector = newSelector(b, a); + ModuleSensorExtensionDictionary selector = newSelector(b, a); List<Object> extensions = Lists.newArrayList(selector.select(Marker.class, true, null)); assertThat(extensions).hasSize(2); @@ -249,7 +254,7 @@ public class ModuleSensorExtensionDictionnaryTest { @Test(expected = IllegalStateException.class) public void annotatedMethodsCanNotBePrivate() { - ModuleSensorExtensionDictionnary selector = newSelector(); + ModuleSensorExtensionDictionary selector = newSelector(); Object wrong = new Object() { @DependsUpon private Object foo() { @@ -265,7 +270,7 @@ public class ModuleSensorExtensionDictionnaryTest { NormalSensor normal = new NormalSensor(); PostSensor post = new PostSensor(); - ModuleSensorExtensionDictionnary selector = newSelector(normal, post, pre); + ModuleSensorExtensionDictionary selector = newSelector(normal, post, pre); assertThat(selector.selectSensors(false)).extracting("wrappedSensor").containsExactly(pre, normal, post); } @@ -275,7 +280,7 @@ public class ModuleSensorExtensionDictionnaryTest { NormalSensor normal = new NormalSensor(); PostSensorSubclass post = new PostSensorSubclass(); - ModuleSensorExtensionDictionnary selector = newSelector(normal, post, pre); + ModuleSensorExtensionDictionary selector = newSelector(normal, post, pre); List extensions = Lists.newArrayList(selector.select(Sensor.class, true, null)); assertThat(extensions).containsExactly(pre, normal, post); @@ -285,7 +290,7 @@ public class ModuleSensorExtensionDictionnaryTest { public void selectSensors() { FakeSensor nonGlobalSensor = new FakeSensor(); FakeGlobalSensor globalSensor = new FakeGlobalSensor(); - ModuleSensorExtensionDictionnary selector = newSelector(nonGlobalSensor, globalSensor); + ModuleSensorExtensionDictionary selector = newSelector(nonGlobalSensor, globalSensor); // verify non-global sensor Collection<ModuleSensorWrapper> extensions = selector.selectSensors(false); 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/PostJobExtensionDictionaryTest.java index bfc29675ffa..3a016aa2acc 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionnaryTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PostJobExtensionDictionaryTest.java @@ -37,7 +37,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class PostJobExtensionDictionnaryTest { +public class PostJobExtensionDictionaryTest { private PostJobOptimizer postJobOptimizer = mock(PostJobOptimizer.class); @Before @@ -45,12 +45,12 @@ public class PostJobExtensionDictionnaryTest { when(postJobOptimizer.shouldExecute(any(DefaultPostJobDescriptor.class))).thenReturn(true); } - private PostJobExtensionDictionnary newSelector(Object... extensions) { + private PostJobExtensionDictionary newSelector(Object... extensions) { ComponentContainer iocContainer = new ComponentContainer(); for (Object extension : extensions) { iocContainer.addSingleton(extension); } - return new PostJobExtensionDictionnary(iocContainer, postJobOptimizer, mock(PostJobContext.class)); + return new PostJobExtensionDictionary(iocContainer, postJobOptimizer, mock(PostJobContext.class)); } @Test @@ -58,7 +58,7 @@ public class PostJobExtensionDictionnaryTest { PrePostJob pre = new PrePostJob(); NormalPostJob normal = new NormalPostJob(); - PostJobExtensionDictionnary selector = newSelector(normal, pre); + PostJobExtensionDictionary selector = newSelector(normal, pre); assertThat(selector.selectPostJobs()).extracting("wrappedPostJob").containsExactly(pre, normal); } |