Search in sources :

Example 1 with DefaultFileSystem

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

the class DeprecatedCpdBlockIndexerSensorTest method setUp.

@Before
public void setUp() throws IOException {
    sonarEngine = new JavaCpdBlockIndexer(null, null, null);
    sonarBridgeEngine = new DefaultCpdBlockIndexer(new CpdMappings(), null, null, null);
    DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder().toPath());
    sensor = new DeprecatedCpdBlockIndexerSensor(sonarEngine, sonarBridgeEngine, fs);
}
Also used : DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) Before(org.junit.Before)

Example 2 with DefaultFileSystem

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

the class JSONReportTest method before.

@Before
public void before() throws Exception {
    moduleHierarchy = mock(InputModuleHierarchy.class);
    userRepository = mock(UserRepositoryLoader.class);
    File projectBaseDir = temp.newFolder();
    fs = new DefaultFileSystem(projectBaseDir.toPath());
    SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+02:00"));
    when(server.getVersion()).thenReturn("3.6");
    InputComponentStore inputComponentStore = new InputComponentStore(new PathResolver());
    DefaultComponentTree inputComponentTree = new DefaultComponentTree();
    DefaultInputModule rootModule = new DefaultInputModule(ProjectDefinition.create().setBaseDir(projectBaseDir).setKey("struts"), 1);
    inputComponentStore.put(rootModule);
    DefaultInputModule moduleA = new DefaultInputModule("struts-core");
    inputComponentTree.index(moduleA, rootModule);
    DefaultInputModule moduleB = new DefaultInputModule("struts-ui");
    inputComponentTree.index(moduleB, rootModule);
    DefaultInputDir inputDir = new DefaultInputDir("struts", "src/main/java/org/apache/struts", TestInputFileBuilder.nextBatchId()).setModuleBaseDir(projectBaseDir.toPath());
    DefaultInputFile inputFile = new TestInputFileBuilder("struts", "src/main/java/org/apache/struts/Action.java").setModuleBaseDir(projectBaseDir.toPath()).build();
    inputFile.setStatus(InputFile.Status.CHANGED);
    inputFile.setPublish(true);
    inputComponentStore.put(inputFile);
    inputComponentStore.put(inputDir);
    inputComponentTree.index(inputDir, rootModule);
    inputComponentTree.index(inputFile, inputDir);
    when(moduleHierarchy.children(rootModule)).thenReturn(Arrays.asList(moduleA, moduleB));
    when(moduleHierarchy.parent(moduleA)).thenReturn(rootModule);
    when(moduleHierarchy.parent(moduleB)).thenReturn(rootModule);
    when(moduleHierarchy.relativePath(moduleA)).thenReturn("core");
    when(moduleHierarchy.relativePath(moduleB)).thenReturn("ui");
    RulesBuilder builder = new RulesBuilder();
    builder.add(RuleKey.of("squid", "AvoidCycles")).setName("Avoid Cycles");
    rules = builder.build();
    jsonReport = new JSONReport(moduleHierarchy, settings, fs, server, rules, issueCache, rootModule, inputComponentStore, userRepository, inputComponentTree);
}
Also used : PathResolver(org.sonar.api.scan.filesystem.PathResolver) RulesBuilder(org.sonar.api.batch.rule.internal.RulesBuilder) TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputModuleHierarchy(org.sonar.api.batch.fs.internal.InputModuleHierarchy) UserRepositoryLoader(org.sonar.scanner.repository.user.UserRepositoryLoader) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) DefaultComponentTree(org.sonar.scanner.scan.DefaultComponentTree) DefaultInputModule(org.sonar.api.batch.fs.internal.DefaultInputModule) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) DefaultInputDir(org.sonar.api.batch.fs.internal.DefaultInputDir) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) Before(org.junit.Before)

Example 3 with DefaultFileSystem

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

the class SensorOptimizerTest method prepare.

@Before
public void prepare() throws Exception {
    fs = new DefaultFileSystem(temp.newFolder().toPath());
    settings = new MapSettings();
    optimizer = new SensorOptimizer(fs, new ActiveRulesBuilder().build(), settings);
}
Also used : ActiveRulesBuilder(org.sonar.api.batch.rule.internal.ActiveRulesBuilder) MapSettings(org.sonar.api.config.MapSettings) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) Before(org.junit.Before)

Example 4 with DefaultFileSystem

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

the class SymbolReferencesSensorTest method prepare.

@Before
public void prepare() throws IOException {
    baseDir = temp.newFolder();
    perspectives = mock(ResourcePerspectives.class);
    sensor = new SymbolReferencesSensor(perspectives);
    fileSystem = new DefaultFileSystem(baseDir.toPath());
    when(context.fileSystem()).thenReturn(fileSystem);
}
Also used : ResourcePerspectives(org.sonar.api.component.ResourcePerspectives) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) Before(org.junit.Before)

Example 5 with DefaultFileSystem

use of org.sonar.api.batch.fs.internal.DefaultFileSystem in project sonarlint-core by SonarSource.

the class SensorOptimizerTest method prepare.

@Before
public void prepare() throws Exception {
    fs = new DefaultFileSystem(temp.newFolder().toPath());
    settings = new MapSettings();
    optimizer = new SensorOptimizer(fs, new ActiveRulesBuilder().build(), settings.asConfig());
}
Also used : ActiveRulesBuilder(org.sonar.api.batch.rule.internal.ActiveRulesBuilder) MapSettings(org.sonar.api.config.internal.MapSettings) DefaultFileSystem(org.sonar.api.batch.fs.internal.DefaultFileSystem) Before(org.junit.Before)

Aggregations

DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)65 File (java.io.File)51 Test (org.junit.Test)40 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)40 InputFile (org.sonar.api.batch.fs.InputFile)33 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)24 Before (org.junit.Before)19 SonarComponents (org.sonar.java.SonarComponents)17 JavaCheck (org.sonar.plugins.java.api.JavaCheck)14 MapSettings (org.sonar.api.config.internal.MapSettings)13 AnalyzerMessage (org.sonar.java.AnalyzerMessage)11 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)10 PathResolver (org.sonar.api.scan.filesystem.PathResolver)7 BlameOutput (org.sonar.api.batch.scm.BlameCommand.BlameOutput)6 ActiveRulesBuilder (org.sonar.api.batch.rule.internal.ActiveRulesBuilder)5 NoSonarFilter (org.sonar.api.issue.NoSonarFilter)4 RuleKey (org.sonar.api.rule.RuleKey)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 BlameLine (org.sonar.api.batch.scm.BlameLine)3 MapSettings (org.sonar.api.config.MapSettings)3