Search in sources :

Example 36 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 37 with TestInputFileBuilder

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

the class ItCoverageSensorTest method testLineHitNoConditions.

@Test
public void testLineHitNoConditions() throws IOException {
    File coverage = new File(baseDir, "src/foo.xoo.itcoverage");
    FileUtils.write(coverage, "1:3\n\n#comment");
    InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setModuleBaseDir(baseDir.toPath()).setLanguage("xoo").setLines(10).build();
    context.fileSystem().add(inputFile);
    sensor.execute(context);
    assertThat(context.lineHits("foo:src/foo.xoo", 1)).isEqualTo(3);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 38 with TestInputFileBuilder

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

the class SymbolReferencesSensorTest method testExecution.

@Test
public void testExecution() throws IOException {
    File symbol = new File(baseDir, "src/foo.xoo.symbol");
    FileUtils.write(symbol, "1:4,7\n12:15,23:33\n\n#comment");
    InputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).build();
    fileSystem.add(inputFile);
    Symbolizable symbolizable = mock(Symbolizable.class);
    when(perspectives.as(Symbolizable.class, inputFile)).thenReturn(symbolizable);
    Symbolizable.SymbolTableBuilder symbolTableBuilder = mock(Symbolizable.SymbolTableBuilder.class);
    when(symbolizable.newSymbolTableBuilder()).thenReturn(symbolTableBuilder);
    Symbol symbol1 = mock(Symbol.class);
    when(symbolTableBuilder.newSymbol(1, 4)).thenReturn(symbol1);
    Symbol symbol2 = mock(Symbol.class);
    when(symbolTableBuilder.newSymbol(12, 15)).thenReturn(symbol2);
    sensor.execute(context);
    verify(symbolTableBuilder).newSymbol(1, 4);
    verify(symbolTableBuilder).newReference(symbol1, 7);
    verify(symbolTableBuilder).newSymbol(12, 15);
    verify(symbolTableBuilder).newReference(symbol2, 23, 33);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) Symbol(org.sonar.api.source.Symbol) InputFile(org.sonar.api.batch.fs.InputFile) File(java.io.File) Symbolizable(org.sonar.api.source.Symbolizable) InputFile(org.sonar.api.batch.fs.InputFile) Test(org.junit.Test)

Example 39 with TestInputFileBuilder

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

the class SyntaxHighlightingSensorTest method testNoExecutionIfNoSyntaxFile.

@Test
public void testNoExecutionIfNoSyntaxFile() {
    DefaultInputFile 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) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 40 with TestInputFileBuilder

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

the class SyntaxHighlightingSensorTest method testExecution.

@Test
public void testExecution() throws IOException {
    File symbol = new File(baseDir, "src/foo.xoo.highlighting");
    FileUtils.write(symbol, "1:4:k\n12:15:cppd\n\n#comment");
    DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setModuleBaseDir(baseDir.toPath()).initMetadata(" xoo\nazertyazer\nfoo").build();
    context.fileSystem().add(inputFile);
    Highlightable highlightable = mock(Highlightable.class);
    when(perspectives.as(Highlightable.class, inputFile)).thenReturn(highlightable);
    HighlightingBuilder builder = mock(Highlightable.HighlightingBuilder.class);
    when(highlightable.newHighlighting()).thenReturn(builder);
    sensor.execute(context);
    verify(builder).highlight(1, 4, "k");
    verify(builder).highlight(12, 15, "cppd");
    verify(builder).done();
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) HighlightingBuilder(org.sonar.api.source.Highlightable.HighlightingBuilder) Highlightable(org.sonar.api.source.Highlightable) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Aggregations

TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)87 Test (org.junit.Test)77 InputFile (org.sonar.api.batch.fs.InputFile)41 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)23 File (java.io.File)19 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)9 Before (org.junit.Before)7 DefaultInputDir (org.sonar.api.batch.fs.internal.DefaultInputDir)6 InputModuleHierarchy (org.sonar.api.batch.fs.internal.InputModuleHierarchy)5 BlameLine (org.sonar.api.batch.scm.BlameLine)5 AnalysisMode (org.sonar.api.batch.AnalysisMode)4 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)4 SensorContextTester (org.sonar.api.batch.sensor.internal.SensorContextTester)4 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)4 Issue (org.sonar.api.batch.sensor.issue.Issue)4 PathResolver (org.sonar.api.scan.filesystem.PathResolver)4 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)4 DefaultBlameOutput (org.sonar.scanner.scm.DefaultBlameOutput)4 DefaultTextPointer (org.sonar.api.batch.fs.internal.DefaultTextPointer)3 DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)3