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);
}
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);
}
}
}
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();
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.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class ActiveRulesPublisherTest method write.
@Test
public void write() throws Exception {
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
NewActiveRule ar = new ActiveRulesBuilder().create(RuleKey.of("java", "S001")).setSeverity("BLOCKER").setParam("p1", "v1");
ActiveRules activeRules = new DefaultActiveRules(Arrays.asList(ar));
ActiveRulesPublisher underTest = new ActiveRulesPublisher(activeRules);
underTest.publish(writer);
ScannerReportReader reader = new ScannerReportReader(outputDir);
try (CloseableIterator<ScannerReport.ActiveRule> readIt = reader.readActiveRules()) {
ScannerReport.ActiveRule reportAr = readIt.next();
assertThat(reportAr.getRuleRepository()).isEqualTo("java");
assertThat(reportAr.getRuleKey()).isEqualTo("S001");
assertThat(reportAr.getSeverity()).isEqualTo(Constants.Severity.BLOCKER);
assertThat(reportAr.getParamsByKey()).hasSize(1);
assertThat(reportAr.getParamsByKey().entrySet().iterator().next().getKey()).isEqualTo("p1");
assertThat(reportAr.getParamsByKey().entrySet().iterator().next().getValue()).isEqualTo("v1");
assertThat(readIt.hasNext()).isFalse();
}
}
use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.
the class AnalysisContextReportPublisherTest method shouldOnlyDumpPluginsByDefault.
@Test
public void shouldOnlyDumpPluginsByDefault() throws Exception {
when(pluginRepo.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("xoo").setName("Xoo").setVersion(Version.create("1.0"))));
ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
publisher.init(writer);
assertThat(writer.getFileStructure().analysisLog()).exists();
assertThat(FileUtils.readFileToString(writer.getFileStructure().analysisLog())).contains("Xoo 1.0 (xoo)");
verifyZeroInteractions(system2);
}
Aggregations