Search in sources :

Example 51 with TestInputFileBuilder

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

the class OverallCoverageSensorTest method testNoExecutionIfNoCoverageFile.

@Test
public void testNoExecutionIfNoCoverageFile() {
    InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
    context.fileSystem().add(inputFile);
    sensor.execute(context);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 52 with TestInputFileBuilder

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

the class MeasureSensorTest method testNoExecutionIfNoMeasureFile.

@Test
public void testNoExecutionIfNoMeasureFile() {
    InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").build();
    context.fileSystem().add(inputFile);
    sensor.execute(context);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 53 with TestInputFileBuilder

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

the class OneQuickFixPerLineSensorTest method testRule.

@Test
public void testRule() throws IOException {
    DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).initMetadata("a\nb\nc\nd\ne\nf\ng\nh\ni\n").build();
    SensorContextTester context = SensorContextTester.create(temp.newFolder());
    context.fileSystem().add(inputFile);
    sensor.execute(context);
    // One issue per line
    assertThat(context.allIssues()).hasSize(10);
    for (Issue issue : context.allIssues()) {
        assertThat(issue.isQuickFixAvailable()).isTrue();
    }
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) Issue(org.sonar.api.batch.sensor.issue.Issue) SensorContextTester(org.sonar.api.batch.sensor.internal.SensorContextTester) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 54 with TestInputFileBuilder

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

the class SignificantCodeSensorTest method prepare.

@Before
public void prepare() throws IOException {
    baseDir = temp.newFolder();
    sensor = new SignificantCodeSensor();
    context = SensorContextTester.create(baseDir);
    inputFile = new TestInputFileBuilder("foo", baseDir, new File(baseDir, "src/foo.xoo")).setLanguage("xoo").setContents("some lines\nof code\nyet another line").build();
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) Before(org.junit.Before)

Example 55 with TestInputFileBuilder

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

the class JavaCpdBlockIndexerSensorTest method prepare.

@Before
public void prepare() throws IOException {
    MockitoAnnotations.initMocks(this);
    File baseDir = temp.newFolder();
    context = SensorContextTester.create(baseDir);
    file = new TestInputFileBuilder("foo", "src/ManyStatements.java").setModuleBaseDir(baseDir.toPath()).setCharset(StandardCharsets.UTF_8).setLanguage("java").build();
    context.fileSystem().add(file);
    File ioFile = file.file();
    FileUtils.copyURLToFile(this.getClass().getResource("ManyStatements.java"), ioFile);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Before(org.junit.Before)

Aggregations

TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)199 Test (org.junit.Test)163 File (java.io.File)89 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)88 InputFile (org.sonar.api.batch.fs.InputFile)87 DefaultFileSystem (org.sonar.api.batch.fs.internal.DefaultFileSystem)41 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)23 Before (org.junit.Before)22 BlameOutput (org.sonar.api.batch.scm.BlameCommand.BlameOutput)16 SonarComponents (org.sonar.java.SonarComponents)13 JavaCheck (org.sonar.plugins.java.api.JavaCheck)13 BlameLine (org.sonar.api.batch.scm.BlameLine)12 DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)9 Path (java.nio.file.Path)8 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)8 AnalyzerMessage (org.sonar.java.AnalyzerMessage)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 IOException (java.io.IOException)6 ZipFile (java.util.zip.ZipFile)6 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)6