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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations