use of org.sonar.scanner.sensor.ModuleSensorWrapper in project sonarqube by SonarSource.
the class ModuleSensorsExecutorTest method createModuleExecutor.
private ModuleSensorsExecutor createModuleExecutor(String sensorName) throws IOException {
Sensor sensor = new TestSensor(sensorName);
ModuleSensorWrapper sensorWrapper = new ModuleSensorWrapper(sensor, context, optimizer, fileSystem, branchConfiguration);
ModuleSensorExtensionDictionary selector = mock(ModuleSensorExtensionDictionary.class);
when(selector.selectSensors(false)).thenReturn(Collections.singleton(sensorWrapper));
when(selector.selectSensors(true)).thenReturn(Collections.singleton(sensorWrapper));
ProjectDefinition rootDef = ProjectDefinition.create().setKey("root").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder());
DefaultInputModule rootModule = TestInputFileBuilder.newDefaultInputModule(rootDef);
InputModuleHierarchy hierarchy = mock(InputModuleHierarchy.class);
when(hierarchy.isRoot(rootModule)).thenReturn(true);
return new ModuleSensorsExecutor(selector, rootModule, hierarchy, strategy, pluginRepo);
}
use of org.sonar.scanner.sensor.ModuleSensorWrapper in project sonarqube by SonarSource.
the class ModuleSensorExtensionDictionaryTest method selectSensors.
@Test
public void selectSensors() {
FakeSensor nonGlobalSensor = new FakeSensor();
FakeGlobalSensor globalSensor = new FakeGlobalSensor();
ModuleSensorExtensionDictionary selector = newSelector(Sensor.class, nonGlobalSensor, globalSensor);
// verify non-global sensor
Collection<ModuleSensorWrapper> extensions = selector.selectSensors(false);
assertThat(extensions).hasSize(1);
assertThat(extensions).extracting("wrappedSensor").containsExactly(nonGlobalSensor);
// verify global sensor
extensions = selector.selectSensors(true);
assertThat(extensions).extracting("wrappedSensor").containsExactly(globalSensor);
}
Aggregations