use of org.sonar.api.config.internal.MapSettings in project sonarlint-core by SonarSource.
the class SensorOptimizerTest method prepare.
@Before
public void prepare() throws Exception {
fs = new DefaultFileSystem(temp.newFolder().toPath());
settings = new MapSettings();
optimizer = new SensorOptimizer(fs, new ActiveRulesBuilder().build(), settings.asConfig());
}
use of org.sonar.api.config.internal.MapSettings in project sonarlint-core by SonarSource.
the class DefaultServerTest method coverageUnusedMethods.
@Test
public void coverageUnusedMethods() {
SonarRuntime runtime = mock(SonarRuntime.class);
when(runtime.getApiVersion()).thenReturn(Version.create(2, 2));
DefaultServer metadata = new DefaultServer(new MapSettings(), runtime);
assertThat(metadata.getStartedAt()).isNull();
assertThat(metadata.getRootDir()).isNull();
assertThat(metadata.getContextPath()).isNull();
assertThat(metadata.isSecured()).isFalse();
assertThat(metadata.isDev()).isFalse();
assertThat(metadata.getPublicRootUrl()).isNull();
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class JavaSquidSensorTest method testIssueCreation.
private void testIssueCreation(InputFile.Type onType, int expectedIssues) throws IOException {
MapSettings settings = new MapSettings();
NoSonarFilter noSonarFilter = mock(NoSonarFilter.class);
SensorContextTester context = createContext(onType).setRuntime(SonarRuntimeImpl.forSonarLint(Version.create(6, 7)));
DefaultFileSystem fs = context.fileSystem();
SonarComponents sonarComponents = createSonarComponentsMock(context);
DefaultJavaResourceLocator javaResourceLocator = new DefaultJavaResourceLocator(fs, new JavaClasspath(settings.asConfig(), fs));
PostAnalysisIssueFilter postAnalysisIssueFilter = new PostAnalysisIssueFilter(fs);
JavaSquidSensor jss = new JavaSquidSensor(sonarComponents, fs, javaResourceLocator, settings.asConfig(), noSonarFilter, postAnalysisIssueFilter);
jss.execute(context);
verify(noSonarFilter, times(1)).noSonarInFile(fs.inputFiles().iterator().next(), Sets.newHashSet(96));
verify(sonarComponents, times(expectedIssues)).reportIssue(any(AnalyzerMessage.class));
settings.setProperty(Java.SOURCE_VERSION, "wrongFormat");
jss.execute(context);
settings.setProperty(Java.SOURCE_VERSION, "1.7");
jss.execute(context);
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class SurefireUtilsTest method return_default_value_if_property_unset.
@Test
public void return_default_value_if_property_unset() throws Exception {
MapSettings settings = new MapSettings();
DefaultFileSystem fs = new DefaultFileSystem(new File("src/test/resources/org/sonar/plugins/surefire/api/SurefireUtilsTest"));
PathResolver pathResolver = new PathResolver();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
List<File> directories = SurefireUtils.getReportsDirectories(settings.asConfig(), fs, pathResolver);
assertThat(directories).hasSize(1);
File directory = directories.get(0);
assertThat(directory.getCanonicalPath()).endsWith("target" + File.separator + "surefire-reports");
assertThat(directory.exists()).isFalse();
assertThat(directory.isDirectory()).isFalse();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class SurefireUtilsTest method should_get_report_paths_from_property.
@Test
public void should_get_report_paths_from_property() {
MapSettings settings = new MapSettings();
settings.setProperty("sonar.junit.reportPaths", "target/surefire,submodule/target/surefire");
DefaultFileSystem fs = new DefaultFileSystem(new File("src/test/resources/org/sonar/plugins/surefire/api/SurefireUtilsTest/shouldGetReportsPathFromProperty"));
PathResolver pathResolver = new PathResolver();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
List<File> directories = SurefireUtils.getReportsDirectories(settings.asConfig(), fs, pathResolver);
assertThat(directories).hasSize(2);
File directory1 = directories.get(0);
assertThat(directory1.exists()).isTrue();
assertThat(directory1.isDirectory()).isTrue();
File directory2 = directories.get(1);
assertThat(directory2.exists()).isTrue();
assertThat(directory2.isDirectory()).isTrue();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
}
Aggregations