Search in sources :

Example 1 with ModuleSensorWrapper

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);
}
Also used : ModuleSensorWrapper(org.sonar.scanner.sensor.ModuleSensorWrapper) InputModuleHierarchy(org.sonar.scanner.fs.InputModuleHierarchy) ModuleSensorExtensionDictionary(org.sonar.scanner.sensor.ModuleSensorExtensionDictionary) ModuleSensorsExecutor(org.sonar.scanner.sensor.ModuleSensorsExecutor) DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) Sensor(org.sonar.api.batch.sensor.Sensor) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition)

Example 2 with ModuleSensorWrapper

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);
}
Also used : ModuleSensorWrapper(org.sonar.scanner.sensor.ModuleSensorWrapper) ModuleSensorExtensionDictionary(org.sonar.scanner.sensor.ModuleSensorExtensionDictionary) Test(org.junit.Test)

Aggregations

ModuleSensorExtensionDictionary (org.sonar.scanner.sensor.ModuleSensorExtensionDictionary)2 ModuleSensorWrapper (org.sonar.scanner.sensor.ModuleSensorWrapper)2 Test (org.junit.Test)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)1 Sensor (org.sonar.api.batch.sensor.Sensor)1 InputModuleHierarchy (org.sonar.scanner.fs.InputModuleHierarchy)1 ModuleSensorsExecutor (org.sonar.scanner.sensor.ModuleSensorsExecutor)1