use of org.sonar.scanner.protocol.output.ScannerReportReader in project sonarqube by SonarSource.
the class MetadataPublisherTest method write_metadata.
@Test
public void write_metadata() throws Exception {
settings.setProperty(CoreProperties.CPD_CROSS_PROJECT, "true");
Date date = new Date();
when(qProfiles.findAll()).thenReturn(asList(new QProfile().setKey("q1").setName("Q1").setLanguage("java").setRulesUpdatedAt(date)));
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
underTest.publish(writer);
ScannerReportReader reader = new ScannerReportReader(outputDir);
ScannerReport.Metadata metadata = reader.readMetadata();
assertThat(metadata.getAnalysisDate()).isEqualTo(1234567L);
assertThat(metadata.getProjectKey()).isEqualTo("foo");
assertThat(metadata.getProjectKey()).isEqualTo("foo");
assertThat(metadata.getCrossProjectDuplicationActivated()).isTrue();
assertThat(metadata.getQprofilesPerLanguage()).containsOnly(entry("java", org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile.newBuilder().setKey("q1").setName("Q1").setLanguage("java").setRulesUpdatedAt(date.getTime()).build()));
}
use of org.sonar.scanner.protocol.output.ScannerReportReader in project sonarqube by SonarSource.
the class MetadataPublisherTest method write_project_branch.
@Test
public void write_project_branch() throws Exception {
settings.setProperty(CoreProperties.CPD_CROSS_PROJECT, "true");
settings.setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "myBranch");
projectDef.properties().put(CoreProperties.PROJECT_BRANCH_PROPERTY, "myBranch");
projectDef.setKey("foo");
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
underTest.publish(writer);
ScannerReportReader reader = new ScannerReportReader(outputDir);
ScannerReport.Metadata metadata = reader.readMetadata();
assertThat(metadata.getAnalysisDate()).isEqualTo(1234567L);
assertThat(metadata.getProjectKey()).isEqualTo("foo");
assertThat(metadata.getBranch()).isEqualTo("myBranch");
// Cross project duplication disabled on branches
assertThat(metadata.getCrossProjectDuplicationActivated()).isFalse();
}
use of org.sonar.scanner.protocol.output.ScannerReportReader in project sonarqube by SonarSource.
the class MetadataPublisherTest method write_project_organization.
@Test
public void write_project_organization() throws Exception {
settings.setProperty(CoreProperties.PROJECT_ORGANIZATION_PROPERTY, "SonarSource");
File outputDir = temp.newFolder();
ScannerReportWriter writer = new ScannerReportWriter(outputDir);
underTest.publish(writer);
ScannerReportReader reader = new ScannerReportReader(outputDir);
ScannerReport.Metadata metadata = reader.readMetadata();
assertThat(metadata.getOrganizationKey()).isEqualTo("SonarSource");
}
use of org.sonar.scanner.protocol.output.ScannerReportReader in project sonarqube by SonarSource.
the class ComponentsPublisher method publish.
@Override
public void publish(ScannerReportWriter writer) {
this.reader = new ScannerReportReader(writer.getFileStructure().root());
this.writer = writer;
recursiveWriteComponent((DefaultInputComponent) moduleHierarchy.root());
}
use of org.sonar.scanner.protocol.output.ScannerReportReader in project sonarqube by SonarSource.
the class TaskResult method scanTaskCompleted.
@Override
public void scanTaskCompleted(ProjectScanContainer container) {
LOG.info("Store analysis results in memory for later assertions in medium test");
for (TrackedIssue issue : container.getComponentByType(IssueCache.class).all()) {
issues.add(issue);
}
ReportPublisher reportPublisher = container.getComponentByType(ReportPublisher.class);
reader = new ScannerReportReader(reportPublisher.getReportDir());
if (!container.getComponentByType(AnalysisMode.class).isIssues()) {
Metadata readMetadata = getReportReader().readMetadata();
int rootComponentRef = readMetadata.getRootComponentRef();
storeReportComponents(rootComponentRef, null, readMetadata.getBranch());
}
storeFs(container);
}
Aggregations