use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class SurefireSensorTest method shouldNotFailIfReportsNotFound.
@Test
public void shouldNotFailIfReportsNotFound() {
MapSettings settings = new MapSettings();
settings.setProperty(SurefireUtils.SUREFIRE_REPORTS_PATH_PROPERTY, "unknown");
SurefireSensor surefireSensor = new SurefireSensor(mock(SurefireJavaParser.class), settings.asConfig(), fs, pathResolver);
surefireSensor.execute(mock(SensorContext.class));
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class SurefireSensorTest method before.
@Before
public void before() {
fs = new DefaultFileSystem(new File("src/test/resources"));
DefaultInputFile javaFile = new TestInputFileBuilder("", "src/org/foo/java").setLanguage("java").build();
fs.add(javaFile);
perspectives = mock(ResourcePerspectives.class);
javaResourceLocator = mock(JavaResourceLocator.class);
when(javaResourceLocator.findResourceByClassName(anyString())).thenAnswer(invocation -> resource((String) invocation.getArguments()[0]));
surefireSensor = new SurefireSensor(new SurefireJavaParser(perspectives, javaResourceLocator), new MapSettings().asConfig(), fs, pathResolver);
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class JavaTest method should_return_java_file_suffixes.
@Test
public void should_return_java_file_suffixes() {
MapSettings settings = new MapSettings();
Java language = new Java(settings.asConfig());
assertThat(language.getFileSuffixes()).containsOnly(".java", ".jav");
settings.setProperty(Java.FILE_SUFFIXES_KEY, "");
assertThat(language.getFileSuffixes()).containsOnly(".java", ".jav");
settings.setProperty(Java.FILE_SUFFIXES_KEY, ".bar, .foo");
assertThat(language.getFileSuffixes()).containsOnly(".bar", ".foo");
}
use of org.sonar.api.config.internal.MapSettings in project sonar-go by SonarSource.
the class GoCoverageReportTest method upload_reports.
@Test
void upload_reports() throws IOException {
Path baseDir = COVERAGE_DIR.toAbsolutePath();
SensorContextTester context = SensorContextTester.create(baseDir);
context.setSettings(new MapSettings());
context.settings().setProperty("sonar.go.coverage.reportPaths", "coverage.relative.out");
Path goFilePath = baseDir.resolve("cover.go");
String content = new String(Files.readAllBytes(goFilePath), UTF_8);
context.fileSystem().add(TestInputFileBuilder.create("moduleKey", baseDir.toFile(), goFilePath.toFile()).setLanguage("go").setType(InputFile.Type.MAIN).initMetadata(content).build());
GoContext goContext = new GoContext(File.separatorChar, COVERAGE_DIR.toString());
GoCoverageReport.saveCoverageReports(context, goContext);
String fileKey = "moduleKey:cover.go";
assertThat(context.lineHits(fileKey, 3)).isNull();
assertThat(context.lineHits(fileKey, 4)).isEqualTo(1);
assertThat(context.lineHits(fileKey, 5)).isEqualTo(2);
assertThat(context.conditions(fileKey, 5)).isNull();
assertThat(context.coveredConditions(fileKey, 5)).isNull();
assertThat(context.lineHits(fileKey, 6)).isEqualTo(0);
assertThat(context.lineHits(fileKey, 7)).isEqualTo(0);
assertThat(context.lineHits(fileKey, 8)).isNull();
}
Aggregations