use of org.sonar.scanner.sensor.DefaultSensorStorage in project sonarqube by SonarSource.
the class DefaultSymbolizableTest method should_update_cache_when_done.
@Test
public void should_update_cache_when_done() {
DefaultSensorStorage sensorStorage = mock(DefaultSensorStorage.class);
DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.php").initMetadata(Strings.repeat("azerty\n", 20)).build();
DefaultSymbolizable symbolPerspective = new DefaultSymbolizable(inputFile, sensorStorage, mock(AnalysisMode.class));
Symbolizable.SymbolTableBuilder symbolTableBuilder = symbolPerspective.newSymbolTableBuilder();
Symbol firstSymbol = symbolTableBuilder.newSymbol(4, 8);
symbolTableBuilder.newReference(firstSymbol, 12);
symbolTableBuilder.newReference(firstSymbol, 70);
Symbol otherSymbol = symbolTableBuilder.newSymbol(25, 33);
symbolTableBuilder.newReference(otherSymbol, 44);
symbolTableBuilder.newReference(otherSymbol, 60);
symbolTableBuilder.newReference(otherSymbol, 108);
Symbolizable.SymbolTable symbolTable = symbolTableBuilder.build();
symbolPerspective.setSymbolTable(symbolTable);
ArgumentCaptor<DefaultSymbolTable> argCaptor = ArgumentCaptor.forClass(DefaultSymbolTable.class);
verify(sensorStorage).store(argCaptor.capture());
// Map<Symbol, Set<TextRange>>
assertThat(argCaptor.getValue().getReferencesBySymbol().keySet()).hasSize(2);
}
Aggregations