Search in sources :

Example 56 with DefaultInputModule

use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.

the class SpringProjectScanContainer method scanRecursively.

private void scanRecursively(InputModuleHierarchy tree, DefaultInputModule module) {
    for (DefaultInputModule child : tree.children(module)) {
        scanRecursively(tree, child);
    }
    LOG.info("------------- Run sensors on module {}", module.definition().getName());
    scan(module);
}
Also used : DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule)

Example 57 with DefaultInputModule

use of org.sonar.api.batch.fs.internal.DefaultInputModule in project sonarqube by SonarSource.

the class ModuleSensorsExecutorTest method setUp.

@Before
public void setUp() throws IOException {
    when(perModuleSensor.isGlobal()).thenReturn(false);
    when(perModuleSensor.shouldExecute()).thenReturn(true);
    when(perModuleSensor.wrappedSensor()).thenReturn(mock(Sensor.class));
    when(globalSensor.isGlobal()).thenReturn(true);
    when(globalSensor.shouldExecute()).thenReturn(true);
    when(globalSensor.wrappedSensor()).thenReturn(mock(Sensor.class));
    ModuleSensorExtensionDictionary selector = mock(ModuleSensorExtensionDictionary.class);
    when(selector.selectSensors(false)).thenReturn(Collections.singleton(perModuleSensor));
    when(selector.selectSensors(true)).thenReturn(Collections.singleton(globalSensor));
    ProjectDefinition childDef = ProjectDefinition.create().setKey("sub").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder());
    ProjectDefinition rootDef = ProjectDefinition.create().setKey("root").setBaseDir(temp.newFolder()).setWorkDir(temp.newFolder());
    DefaultInputModule rootModule = TestInputFileBuilder.newDefaultInputModule(rootDef);
    DefaultInputModule subModule = TestInputFileBuilder.newDefaultInputModule(childDef);
    InputModuleHierarchy hierarchy = mock(InputModuleHierarchy.class);
    when(hierarchy.isRoot(rootModule)).thenReturn(true);
    rootModuleExecutor = new ModuleSensorsExecutor(selector, rootModule, hierarchy, strategy, pluginRepository);
    subModuleExecutor = new ModuleSensorsExecutor(selector, subModule, hierarchy, strategy, pluginRepository);
}
Also used : 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) Before(org.junit.Before)

Aggregations

DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)57 Test (org.junit.Test)34 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)17 File (java.io.File)9 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)9 ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)9 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)8 Path (java.nio.file.Path)6 InputFile (org.sonar.api.batch.fs.InputFile)6 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)6 InputModuleHierarchy (org.sonar.api.batch.fs.internal.InputModuleHierarchy)5 Before (org.junit.Before)4 InputComponent (org.sonar.api.batch.fs.InputComponent)4 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)4 DefaultMeasure (org.sonar.api.batch.sensor.measure.internal.DefaultMeasure)4 ProjectAnalysisInfo (org.sonar.scanner.ProjectAnalysisInfo)4 CheckForNull (javax.annotation.CheckForNull)3 InputDir (org.sonar.api.batch.fs.InputDir)3 DefaultInputComponent (org.sonar.api.batch.fs.internal.DefaultInputComponent)3 InputModuleHierarchy (org.sonar.scanner.fs.InputModuleHierarchy)3