Search in sources :

Example 41 with ScannerReportWriter

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

the class ChangedLinesPublisherTest method setUp.

@Before
public void setUp() {
    writer = new ScannerReportWriter(temp.getRoot());
    when(branchConfiguration.isPullRequest()).thenReturn(true);
    when(scmConfiguration.isDisabled()).thenReturn(false);
    when(scmConfiguration.provider()).thenReturn(provider);
    when(branchConfiguration.targetBranchName()).thenReturn(TARGET_BRANCH);
    when(project.getBaseDir()).thenReturn(BASE_DIR);
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Before(org.junit.Before)

Example 42 with ScannerReportWriter

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

the class MetadataPublisherTest method write_revision_id.

@Test
public void write_revision_id() throws Exception {
    String revisionId = "some-sha1";
    when(scmRevision.get()).thenReturn(Optional.of(revisionId));
    File outputDir = temp.newFolder();
    underTest.publish(new ScannerReportWriter(outputDir));
    ScannerReportReader reader = new ScannerReportReader(outputDir);
    ScannerReport.Metadata metadata = reader.readMetadata();
    assertThat(metadata.getScmRevisionId()).isEqualTo(revisionId);
}
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 43 with ScannerReportWriter

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

the class MetadataPublisherTest method write_not_analysed_file_counts.

@Test
public void write_not_analysed_file_counts() throws Exception {
    when(componentStore.getNotAnalysedFilesByLanguage()).thenReturn(ImmutableMap.of("c", 10, "cpp", 20));
    File outputDir = temp.newFolder();
    ScannerReportWriter writer = new ScannerReportWriter(outputDir);
    underTest.publish(writer);
    ScannerReportReader reader = new ScannerReportReader(outputDir);
    ScannerReport.Metadata metadata = reader.readMetadata();
    assertThat(metadata.getNotAnalyzedFilesByLanguageMap()).contains(entry("c", 10), entry("cpp", 20));
}
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 44 with ScannerReportWriter

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

the class CpdExecutorTest method setUp.

@Before
public void setUp() throws IOException {
    File outputDir = temp.newFolder();
    baseDir = temp.newFolder();
    when(publisher.getWriter()).thenReturn(new ScannerReportWriter(outputDir));
    DefaultInputProject project = TestInputFileBuilder.newDefaultInputProject("foo", baseDir);
    componentStore = new InputComponentStore(mock(BranchConfiguration.class), sonarRuntime);
    executor = new CpdExecutor(settings, index, publisher, componentStore, executorService);
    reader = new ScannerReportReader(outputDir);
    batchComponent1 = createComponent("src/Foo.php", 5);
    batchComponent2 = createComponent("src/Foo2.php", 5);
    batchComponent3 = createComponent("src/Foo3.php", 5);
}
Also used : ScannerReportReader(org.sonar.scanner.protocol.output.ScannerReportReader) DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Before(org.junit.Before)

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