use of org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method should_save_highlighting.
@Test
public void should_save_highlighting() {
DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php").setContents("// comment").build();
DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(1, 0, 1, 1, TypeOfText.KEYWORD);
underTest.store(highlighting);
assertThat(reportWriter.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, file.scannerId())).isTrue();
}
use of org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method duplicateHighlighting.
@Test(expected = UnsupportedOperationException.class)
public void duplicateHighlighting() throws Exception {
InputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.java").setModuleBaseDir(temp.newFolder().toPath()).build();
DefaultHighlighting h = new DefaultHighlighting(null).onFile(inputFile);
underTest.store(h);
underTest.store(h);
}
use of org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting in project sonarqube by SonarSource.
the class InMemorySensorStorage method store.
@Override
public void store(NewHighlighting newHighlighting) {
DefaultHighlighting highlighting = (DefaultHighlighting) newHighlighting;
String fileKey = highlighting.inputFile().key();
// Emulate duplicate storage check
if (highlightingByComponent.containsKey(fileKey)) {
throw new UnsupportedOperationException("Trying to save highlighting twice for the same file is not supported: " + highlighting.inputFile());
}
highlightingByComponent.put(fileKey, highlighting);
}
Aggregations