Search in sources :

Example 6 with DefaultTextPointer

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

the class SensorContextTesterTest method testAnalysisErrors.

@Test
public void testAnalysisErrors() {
    assertThat(tester.allAnalysisErrors()).isEmpty();
    NewAnalysisError newAnalysisError = tester.newAnalysisError();
    InputFile file = new TestInputFileBuilder("foo", "src/Foo.java").build();
    newAnalysisError.onFile(file).message("error").at(new DefaultTextPointer(5, 2)).save();
    assertThat(tester.allAnalysisErrors()).hasSize(1);
    AnalysisError analysisError = tester.allAnalysisErrors().iterator().next();
    assertThat(analysisError.inputFile()).isEqualTo(file);
    assertThat(analysisError.message()).isEqualTo("error");
    assertThat(analysisError.location()).isEqualTo(new DefaultTextPointer(5, 2));
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) NewAnalysisError(org.sonar.api.batch.sensor.error.NewAnalysisError) AnalysisError(org.sonar.api.batch.sensor.error.AnalysisError) NewAnalysisError(org.sonar.api.batch.sensor.error.NewAnalysisError) DefaultTextPointer(org.sonar.api.batch.fs.internal.DefaultTextPointer) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 7 with DefaultTextPointer

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

the class DefaultAnalysisErrorTest method setUp.

@Before
public void setUp() {
    inputFile = new TestInputFileBuilder("module1", "src/File.java").build();
    textPointer = new DefaultTextPointer(5, 2);
    storage = Mockito.mock(SensorStorage.class);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultTextPointer(org.sonar.api.batch.fs.internal.DefaultTextPointer) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) Before(org.junit.Before)

Aggregations

DefaultTextPointer (org.sonar.api.batch.fs.internal.DefaultTextPointer)7 Test (org.junit.Test)4 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)4 InputFile (org.sonar.api.batch.fs.InputFile)2 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)2 DefaultTextRange (org.sonar.api.batch.fs.internal.DefaultTextRange)2 AnalysisError (org.sonar.api.batch.sensor.error.AnalysisError)2 File (java.io.File)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)1 Map (java.util.Map)1 Set (java.util.Set)1 CheckForNull (javax.annotation.CheckForNull)1 Before (org.junit.Before)1 TextRange (org.sonar.api.batch.fs.TextRange)1 NewAnalysisError (org.sonar.api.batch.sensor.error.NewAnalysisError)1 TypeOfText (org.sonar.api.batch.sensor.highlighting.TypeOfText)1 DefaultHighlighting (org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting)1 SyntaxHighlightingRule (org.sonar.api.batch.sensor.highlighting.internal.SyntaxHighlightingRule)1