Search in sources :

Example 21 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class AnalysisContextReportPublisherTest method shouldNotDumpEnvTwice.

@Test
public void shouldNotDumpEnvTwice() throws Exception {
    logTester.setLevel(LoggerLevel.DEBUG);
    ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
    Map<String, String> env = new HashMap<>();
    env.put(FOO, "BAR");
    env.put(BIZ, "BAZ");
    when(system2.envVariables()).thenReturn(env);
    publisher.init(writer);
    String content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
    assertThat(content).containsOnlyOnce(FOO);
    assertThat(content).containsOnlyOnce(BIZ);
    assertThat(content).containsSequence(BIZ, FOO);
    publisher.dumpModuleSettings(ProjectDefinition.create().setProperty("sonar.projectKey", "foo").setProperty("env." + FOO, "BAR"));
    content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
    assertThat(content).containsOnlyOnce(FOO);
    assertThat(content).containsOnlyOnce(BIZ);
    assertThat(content).doesNotContain("env." + FOO);
}
Also used : HashMap(java.util.HashMap) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Test(org.junit.Test)

Example 22 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class AnalysisContextReportPublisherTest method dumpServerSideModuleProps.

@Test
public void dumpServerSideModuleProps() throws Exception {
    logTester.setLevel(LoggerLevel.DEBUG);
    ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
    publisher.init(writer);
    when(projectRepos.moduleExists("foo")).thenReturn(true);
    when(projectRepos.settings("foo")).thenReturn(ImmutableMap.of(COM_FOO, "bar", SONAR_SKIP, "true"));
    publisher.dumpModuleSettings(ProjectDefinition.create().setProperty("sonar.projectKey", "foo"));
    String content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
    assertThat(content).doesNotContain(COM_FOO);
    assertThat(content).containsOnlyOnce(SONAR_SKIP);
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Test(org.junit.Test)

Example 23 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class ComponentsPublisherTest method setUp.

@Before
public void setUp() throws IOException {
    tree = new DefaultComponentTree();
    outputDir = temp.newFolder();
    writer = new ScannerReportWriter(outputDir);
}
Also used : DefaultComponentTree(org.sonar.scanner.scan.DefaultComponentTree) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Before(org.junit.Before)

Example 24 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class DefaultSensorStorageTest method prepare.

@Before
public void prepare() throws Exception {
    MetricFinder metricFinder = mock(MetricFinder.class);
    when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
    when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
    settings = new MapSettings();
    moduleIssues = mock(ModuleIssues.class);
    measureCache = mock(MeasureCache.class);
    CoverageExclusions coverageExclusions = mock(CoverageExclusions.class);
    when(coverageExclusions.isExcluded(any(InputFile.class))).thenReturn(false);
    ReportPublisher reportPublisher = mock(ReportPublisher.class);
    when(reportPublisher.getWriter()).thenReturn(new ScannerReportWriter(temp.newFolder()));
    underTest = new DefaultSensorStorage(metricFinder, moduleIssues, settings, coverageExclusions, reportPublisher, measureCache, mock(SonarCpdBlockIndex.class), contextPropertiesCache, new ScannerMetrics());
}
Also used : ReportPublisher(org.sonar.scanner.report.ReportPublisher) MapSettings(org.sonar.api.config.MapSettings) MeasureCache(org.sonar.scanner.scan.measure.MeasureCache) ModuleIssues(org.sonar.scanner.issue.ModuleIssues) MetricFinder(org.sonar.api.batch.measure.MetricFinder) ScannerMetrics(org.sonar.core.metric.ScannerMetrics) CoverageExclusions(org.sonar.scanner.sensor.coverage.CoverageExclusions) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) InputFile(org.sonar.api.batch.fs.InputFile) Before(org.junit.Before)

Aggregations

ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)24 Test (org.junit.Test)14 File (java.io.File)9 Before (org.junit.Before)7 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)6 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)5 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)4 PathResolver (org.sonar.api.scan.filesystem.PathResolver)3 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)3 Matchers.anyString (org.mockito.Matchers.anyString)2 InputFile (org.sonar.api.batch.fs.InputFile)2 TextRange (org.sonar.api.batch.fs.TextRange)2 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)2 MapSettings (org.sonar.api.config.MapSettings)2 ReportPublisher (org.sonar.scanner.report.ReportPublisher)2 MeasureCache (org.sonar.scanner.scan.measure.MeasureCache)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1