Search in sources :

Example 26 with ScannerReportWriter

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

the class AnalysisWarningsPublisherTest method publish_warnings.

@Test
public void publish_warnings() throws IOException {
    File outputDir = temp.newFolder();
    ScannerReportWriter writer = new ScannerReportWriter(outputDir);
    String warning1 = "warning 1";
    String warning2 = "warning 2";
    analysisWarnings.addUnique(warning1);
    analysisWarnings.addUnique(warning1);
    analysisWarnings.addUnique(warning2);
    underTest.publish(writer);
    ScannerReportReader reader = new ScannerReportReader(outputDir);
    List<ScannerReport.AnalysisWarning> warnings = Lists.newArrayList(reader.readAnalysisWarnings());
    assertThat(warnings).extracting(ScannerReport.AnalysisWarning::getText).containsExactly(warning1, warning2);
}
Also used : ScannerReportReader(org.sonar.scanner.protocol.output.ScannerReportReader) ScannerReport(org.sonar.scanner.protocol.output.ScannerReport) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) File(java.io.File) Test(org.junit.Test)

Example 27 with ScannerReportWriter

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

the class BatchReportReaderImplTest method setUp.

@Before
public void setUp() {
    BatchReportDirectoryHolder holder = new ImmutableBatchReportDirectoryHolder(tempFolder.newDir());
    underTest = new BatchReportReaderImpl(holder);
    writer = new ScannerReportWriter(holder.getDirectory());
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Before(org.junit.Before)

Example 28 with ScannerReportWriter

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

the class ReportIteratorTest method setUp.

@Before
public void setUp() throws Exception {
    File dir = temp.newFolder();
    ScannerReportWriter writer = new ScannerReportWriter(dir);
    writer.writeComponentCoverage(1, newArrayList(ScannerReport.LineCoverage.newBuilder().setLine(1).build()));
    file = new FileStructure(dir).fileFor(FileStructure.Domain.COVERAGES, 1);
}
Also used : FileStructure(org.sonar.scanner.protocol.output.FileStructure) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) File(java.io.File) Before(org.junit.Before)

Example 29 with ScannerReportWriter

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

the class ReportPublisher method start.

@Override
public void start() {
    reportDir = new File(projectReactor.getRoot().getWorkDir(), "batch-report");
    writer = new ScannerReportWriter(reportDir);
    contextPublisher.init(writer);
    if (!analysisMode.isIssues() && !analysisMode.isMediumTest()) {
        String publicUrl = server.getPublicRootUrl();
        if (HttpUrl.parse(publicUrl) == null) {
            throw MessageException.of("Failed to parse public URL set in SonarQube server: " + publicUrl);
        }
    }
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) File(java.io.File)

Example 30 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)

Aggregations

ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)44 Test (org.junit.Test)25 File (java.io.File)21 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)16 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)14 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)11 Before (org.junit.Before)10 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)8 TextRange (org.sonar.api.batch.fs.TextRange)5 BranchConfiguration (org.sonar.scanner.scan.branch.BranchConfiguration)5 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)5 DefaultInputProject (org.sonar.api.batch.fs.internal.DefaultInputProject)4 InputFile (org.sonar.api.batch.fs.InputFile)3 DefaultMeasure (org.sonar.api.batch.sensor.measure.internal.DefaultMeasure)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Path (java.nio.file.Path)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 StreamSupport (java.util.stream.StreamSupport)2