use of org.sonar.api.batch.sensor.error.AnalysisError in project sonarqube by SonarSource.
the class AnalysisErrorSensorTest method test.
@Test
public void test() throws IOException {
Path baseDir = temp.newFolder().toPath().toAbsolutePath();
createErrorFile(baseDir);
int[] offsets = { 10, 20, 30, 40 };
DefaultInputFile inputFile = new TestInputFileBuilder("foo", "src/foo.xoo").setLanguage("xoo").setOriginalLineOffsets(offsets).setModuleBaseDir(baseDir).setLines(4).build();
context = SensorContextTester.create(baseDir);
context.fileSystem().add(inputFile);
sensor.execute(context);
assertThat(context.allAnalysisErrors()).hasSize(1);
AnalysisError error = context.allAnalysisErrors().iterator().next();
assertThat(error.inputFile()).isEqualTo(inputFile);
assertThat(error.location()).isEqualTo(new DefaultTextPointer(1, 4));
assertThat(error.message()).isEqualTo("my error");
}
use of org.sonar.api.batch.sensor.error.AnalysisError 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));
}
Aggregations