Search in sources :

Example 1 with DefaultHighlightable

use of org.sonar.scanner.source.DefaultHighlightable in project sonarqube by SonarSource.

the class DefaultHighlightableTest method should_store_highlighting_rules.

@Test
public void should_store_highlighting_rules() {
    SensorStorage sensorStorage = mock(SensorStorage.class);
    DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.php").initMetadata("azerty\nbla bla").build();
    DefaultHighlightable highlightablePerspective = new DefaultHighlightable(inputFile, sensorStorage, mock(AnalysisMode.class));
    highlightablePerspective.newHighlighting().highlight(0, 6, "k").highlight(7, 10, "cppd").done();
    ArgumentCaptor<DefaultHighlighting> argCaptor = ArgumentCaptor.forClass(DefaultHighlighting.class);
    verify(sensorStorage).store(argCaptor.capture());
    assertThat(argCaptor.getValue().getSyntaxHighlightingRuleSet()).hasSize(2);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) DefaultHighlighting(org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting) AnalysisMode(org.sonar.api.batch.AnalysisMode) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) DefaultHighlightable(org.sonar.scanner.source.DefaultHighlightable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AnalysisMode (org.sonar.api.batch.AnalysisMode)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)1 DefaultHighlighting (org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting)1 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)1 DefaultHighlightable (org.sonar.scanner.source.DefaultHighlightable)1