use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class CpdExecutorTest method setUp.
@Before
public void setUp() throws IOException {
File outputDir = temp.newFolder();
baseDir = temp.newFolder();
settings = new MapSettings();
publisher = mock(ReportPublisher.class);
when(publisher.getWriter()).thenReturn(new ScannerReportWriter(outputDir));
index = new SonarCpdBlockIndex(publisher, settings);
componentStore = new InputComponentStore(new PathResolver());
executor = new CpdExecutor(settings, index, publisher, componentStore);
reader = new ScannerReportReader(outputDir);
componentStore.put(TestInputFileBuilder.newDefaultInputModule("foo", baseDir));
batchComponent1 = createComponent("src/Foo.php", 5);
batchComponent2 = createComponent("src/Foo2.php", 5);
batchComponent3 = createComponent("src/Foo3.php", 5);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class ProjectAnalysisInfoTest method testSimpleDate.
@Test
public void testSimpleDate() {
Settings settings = new MapSettings();
settings.appendProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2017-01-01");
settings.appendProperty(CoreProperties.PROJECT_VERSION_PROPERTY, "version");
System2 system = mock(System2.class);
ProjectAnalysisInfo info = new ProjectAnalysisInfo(settings, system);
info.start();
LocalDate date = LocalDate.of(2017, 1, 1);
assertThat(info.analysisDate()).isEqualTo(Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
assertThat(info.analysisVersion()).isEqualTo("version");
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class JavaCpdBlockIndexerTest method setUp.
@Before
public void setUp() throws IOException {
MockitoAnnotations.initMocks(this);
File baseDir = temp.newFolder();
DefaultFileSystem fs = new DefaultFileSystem(baseDir);
file = new TestInputFileBuilder("foo", "src/ManyStatements.java").setModuleBaseDir(baseDir.toPath()).setLanguage(JAVA).build();
fs.add(file);
File ioFile = file.file();
FileUtils.copyURLToFile(this.getClass().getResource("ManyStatements.java"), ioFile);
settings = new MapSettings();
engine = new JavaCpdBlockIndexer(fs, settings, index);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class GenericCoverageSensorTest method migrateOldProperties.
@Test
public void migrateOldProperties() {
Settings settings = new MapSettings(new PropertyDefinitions(GenericCoverageSensor.properties()));
settings.setProperty(GenericCoverageSensor.OLD_REPORT_PATH_PROPERTY_KEY, "old.xml");
settings.setProperty(GenericCoverageSensor.OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old1.xml,old2.xml");
settings.setProperty(GenericCoverageSensor.OLD_IT_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old3.xml,old4.xml,old.xml");
settings.setProperty(GenericCoverageSensor.OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old5.xml,old6.xml");
new GenericCoverageSensor(settings).execute();
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Property 'sonar.genericcoverage.reportPath' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.reportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.itReportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.overallReportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.");
assertThat(settings.getStringArray(GenericCoverageSensor.REPORT_PATHS_PROPERTY_KEY)).containsOnly("old.xml", "old1.xml", "old2.xml", "old3.xml", "old4.xml", "old5.xml", "old6.xml");
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class GenericTestExecutionSensorTest method logWhenDeprecatedPropsAreUsed.
@Test
public void logWhenDeprecatedPropsAreUsed() throws IOException {
File basedir = temp.newFolder();
File report = new File(basedir, "report.xml");
FileUtils.write(report, "<unitTest version=\"1\"><file path=\"A.java\"><testCase name=\"test1\" duration=\"500\"/></file></unitTest>");
SensorContextTester context = SensorContextTester.create(basedir);
Settings settings = new MapSettings(new PropertyDefinitions(GenericTestExecutionSensor.properties()));
settings.setProperty(GenericTestExecutionSensor.OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY, "report.xml");
context.setSettings(settings);
new GenericTestExecutionSensor(mock(TestPlanBuilder.class)).execute(context);
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Using 'unitTest' as root element of the report is deprecated. Please change to 'testExecutions'.", "Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.");
assertThat(logTester.logs(LoggerLevel.INFO)).contains("Imported test execution data for 0 files", "Test execution data ignored for 1 unknown files, including:\nA.java");
}
Aggregations