use of org.sonar.api.batch.sensor.error.NewAnalysisError 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));
}
use of org.sonar.api.batch.sensor.error.NewAnalysisError in project sonarqube by SonarSource.
the class DefaultAnalysisErrorTest method test_validation.
@Test
public void test_validation() {
try {
new DefaultAnalysisError(storage).onFile(null);
fail("Expected exception");
} catch (IllegalArgumentException e) {
// expected
}
NewAnalysisError error = new DefaultAnalysisError(storage).onFile(inputFile);
try {
error.onFile(inputFile);
fail("Expected exception");
} catch (IllegalStateException e) {
// expected
}
error = new DefaultAnalysisError(storage).at(textPointer);
try {
error.at(textPointer);
fail("Expected exception");
} catch (IllegalStateException e) {
// expected
}
try {
new DefaultAnalysisError(storage).save();
fail("Expected exception");
} catch (NullPointerException e) {
// expected
}
}
Aggregations