diff options
Diffstat (limited to 'server')
61 files changed, 511 insertions, 510 deletions
diff --git a/server/sonar-server-benchmarks/pom.xml b/server/sonar-server-benchmarks/pom.xml index 7fbeac8dcd8..087d3b832e6 100644 --- a/server/sonar-server-benchmarks/pom.xml +++ b/server/sonar-server-benchmarks/pom.xml @@ -60,6 +60,11 @@ <artifactId>dbunit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + <scope>provided</scope> + </dependency> </dependencies> <build> diff --git a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java index e36f1033a2c..c5d96e80a30 100644 --- a/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java +++ b/server/sonar-server-benchmarks/src/test/java/org/sonar/server/benchmark/PersistFileSourcesStepTest.java @@ -31,12 +31,12 @@ import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReportWriter; import org.sonar.core.util.Uuids; import org.sonar.db.DbClient; import org.sonar.db.DbTester; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.scanner.protocol.output.ScannerReportWriter; import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl; import org.sonar.server.computation.batch.BatchReportReaderImpl; @@ -88,14 +88,14 @@ public class PersistFileSourcesStepTest { long start = System.currentTimeMillis(); - BatchReportDirectoryHolderImpl batchReportDirectoryHolder = new BatchReportDirectoryHolderImpl(); - batchReportDirectoryHolder.setDirectory(reportDir); - org.sonar.server.computation.batch.BatchReportReader batchReportReader = new BatchReportReaderImpl(batchReportDirectoryHolder); + BatchReportDirectoryHolderImpl ScannerReportDirectoryHolder = new BatchReportDirectoryHolderImpl(); + ScannerReportDirectoryHolder.setDirectory(reportDir); + org.sonar.server.computation.batch.BatchReportReader ScannerReportReader = new BatchReportReaderImpl(ScannerReportDirectoryHolder); analysisMetadataHolder.setBaseProjectSnapshot(null); - SourceLinesRepositoryImpl sourceLinesRepository = new SourceLinesRepositoryImpl(batchReportReader); + SourceLinesRepositoryImpl sourceLinesRepository = new SourceLinesRepositoryImpl(ScannerReportReader); SourceHashRepositoryImpl sourceHashRepository = new SourceHashRepositoryImpl(sourceLinesRepository); - ScmInfoRepositoryImpl scmInfoRepository = new ScmInfoRepositoryImpl(batchReportReader, analysisMetadataHolder, dbClient, sourceHashRepository); - PersistFileSourcesStep step = new PersistFileSourcesStep(dbClient, System2.INSTANCE, treeRootHolder, batchReportReader, sourceLinesRepository, scmInfoRepository, + ScmInfoRepositoryImpl scmInfoRepository = new ScmInfoRepositoryImpl(ScannerReportReader, analysisMetadataHolder, dbClient, sourceHashRepository); + PersistFileSourcesStep step = new PersistFileSourcesStep(dbClient, System2.INSTANCE, treeRootHolder, ScannerReportReader, sourceLinesRepository, scmInfoRepository, duplicationRepository); step.execute(); @@ -112,11 +112,11 @@ public class PersistFileSourcesStepTest { LOGGER.info("Create report"); File reportDir = temp.newFolder(); - BatchReportWriter writer = new BatchReportWriter(reportDir); - writer.writeMetadata(BatchReport.Metadata.newBuilder() + ScannerReportWriter writer = new ScannerReportWriter(reportDir); + writer.writeMetadata(ScannerReport.Metadata.newBuilder() .setRootComponentRef(1) .build()); - BatchReport.Component.Builder project = BatchReport.Component.newBuilder() + ScannerReport.Component.Builder project = ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT); @@ -140,7 +140,7 @@ public class PersistFileSourcesStepTest { return reportDir; } - private Component generateFileReport(BatchReportWriter writer, int fileRef) throws IOException { + private Component generateFileReport(ScannerReportWriter writer, int fileRef) throws IOException { LineData lineData = new LineData(); for (int line = 1; line <= NUMBER_OF_LINES; line++) { lineData.generateLineData(line); @@ -148,11 +148,9 @@ public class PersistFileSourcesStepTest { fileRef, new Duplication( new TextBlock(line, line), - Arrays.<Duplicate>asList(new InnerDuplicate(new TextBlock(line + 1, line + 1))) - ) - ); + Arrays.<Duplicate>asList(new InnerDuplicate(new TextBlock(line + 1, line + 1))))); } - writer.writeComponent(BatchReport.Component.newBuilder() + writer.writeComponent(ScannerReport.Component.newBuilder() .setRef(fileRef) .setType(Constants.ComponentType.FILE) .setLines(NUMBER_OF_LINES) @@ -169,22 +167,22 @@ public class PersistFileSourcesStepTest { private static class LineData { List<String> lines = new ArrayList<>(); - BatchReport.Changesets.Builder changesetsBuilder = BatchReport.Changesets.newBuilder(); - List<BatchReport.Coverage> coverages = new ArrayList<>(); - List<BatchReport.SyntaxHighlighting> highlightings = new ArrayList<>(); - List<BatchReport.Symbol> symbols = new ArrayList<>(); + ScannerReport.Changesets.Builder changesetsBuilder = ScannerReport.Changesets.newBuilder(); + List<ScannerReport.Coverage> coverages = new ArrayList<>(); + List<ScannerReport.SyntaxHighlighting> highlightings = new ArrayList<>(); + List<ScannerReport.Symbol> symbols = new ArrayList<>(); void generateLineData(int line) { lines.add("line-" + line); - changesetsBuilder.addChangeset(BatchReport.Changesets.Changeset.newBuilder() + changesetsBuilder.addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("author-" + line) .setDate(123456789L) .setRevision("rev-" + line) .build()) .addChangesetIndexByLine(line - 1); - coverages.add(BatchReport.Coverage.newBuilder() + coverages.add(ScannerReport.Coverage.newBuilder() .setLine(line) .setConditions(10) .setUtHits(true) @@ -194,19 +192,19 @@ public class PersistFileSourcesStepTest { .setOverallCoveredConditions(4) .build()); - highlightings.add(BatchReport.SyntaxHighlighting.newBuilder() - .setRange(BatchReport.TextRange.newBuilder() + highlightings.add(ScannerReport.SyntaxHighlighting.newBuilder() + .setRange(ScannerReport.TextRange.newBuilder() .setStartLine(line).setEndLine(line) .setStartOffset(1).setEndOffset(3) .build()) .setType(Constants.HighlightingType.ANNOTATION) .build()); - symbols.add(BatchReport.Symbol.newBuilder() - .setDeclaration(BatchReport.TextRange.newBuilder() + symbols.add(ScannerReport.Symbol.newBuilder() + .setDeclaration(ScannerReport.TextRange.newBuilder() .setStartLine(line).setEndLine(line).setStartOffset(2).setEndOffset(4) .build()) - .addReference(BatchReport.TextRange.newBuilder() + .addReference(ScannerReport.TextRange.newBuilder() .setStartLine(line + 1).setEndLine(line + 1).setStartOffset(1).setEndOffset(3) .build()) .build()); diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index 03ab69e8487..afa1b8f5c17 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -69,7 +69,7 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>sonar-batch-protocol</artifactId> + <artifactId>sonar-scanner-protocol</artifactId> </dependency> <dependency> <groupId>${project.groupId}</groupId> diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalAction.java index 863edf332fe..d0a189510d5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/GlobalAction.java @@ -23,13 +23,13 @@ import org.apache.commons.io.IOUtils; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.batch.protocol.input.GlobalRepositories; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; import org.sonar.db.metric.MetricDto; import org.sonar.db.property.PropertiesDao; import org.sonar.db.property.PropertyDto; +import org.sonar.scanner.protocol.input.GlobalRepositories; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.user.UserSession; import org.sonarqube.ws.MediaTypes; @@ -82,7 +82,7 @@ public class GlobalAction implements BatchWsAction { private void addMetrics(GlobalRepositories ref, DbSession session) { for (MetricDto metric : dbClient.metricDao().selectEnabled(session)) { ref.addMetric( - new org.sonar.batch.protocol.input.Metric(metric.getId(), metric.getKey(), + new org.sonar.scanner.protocol.input.Metric(metric.getId(), metric.getKey(), metric.getValueType(), metric.getDescription(), metric.getDirection(), diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java index b30364e719e..4573ded8dde 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java @@ -28,11 +28,11 @@ import org.sonar.api.resources.Scopes; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.batch.protocol.input.BatchInput; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; import org.sonar.db.component.ComponentDto; +import org.sonar.scanner.protocol.input.ScannerInput; import org.sonar.server.component.ComponentFinder; import org.sonar.server.issue.index.IssueDoc; import org.sonar.server.issue.index.IssueIndex; @@ -86,7 +86,7 @@ public class IssuesAction implements BatchWsAction { ComponentDto component = componentFinder.getByKey(session, componentKey); Map<String, String> keysByUUid = keysByUUid(session, component); - BatchInput.ServerIssue.Builder issueBuilder = BatchInput.ServerIssue.newBuilder(); + ScannerInput.ServerIssue.Builder issueBuilder = ScannerInput.ServerIssue.newBuilder(); for (Iterator<IssueDoc> issueDocIterator = issueIndex.selectIssuesForBatch(component); issueDocIterator.hasNext();) { handleIssue(issueDocIterator.next(), issueBuilder, keysByUUid, response.stream().output()); } @@ -95,7 +95,7 @@ public class IssuesAction implements BatchWsAction { } } - private static void handleIssue(IssueDoc issue, BatchInput.ServerIssue.Builder issueBuilder, Map<String, String> keysByUUid, OutputStream out) { + private static void handleIssue(IssueDoc issue, ScannerInput.ServerIssue.Builder issueBuilder, Map<String, String> keysByUUid, OutputStream out) { issueBuilder.setKey(issue.key()); issueBuilder.setModuleKey(keysByUUid.get(issue.moduleUuid())); String path = issue.filePath(); @@ -120,7 +120,7 @@ public class IssuesAction implements BatchWsAction { if (message != null) { issueBuilder.setMsg(message); } - issueBuilder.setSeverity(org.sonar.batch.protocol.Constants.Severity.valueOf(issue.severity())); + issueBuilder.setSeverity(org.sonar.scanner.protocol.Constants.Severity.valueOf(issue.severity())); issueBuilder.setManualSeverity(issue.isManualSeverity()); issueBuilder.setStatus(issue.status()); String resolution = issue.resolution(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectAction.java index 256c606cd03..d6917cccc34 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectAction.java @@ -25,8 +25,8 @@ import java.util.Map; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.batch.protocol.input.FileData; -import org.sonar.batch.protocol.input.ProjectRepositories; +import org.sonar.scanner.protocol.input.FileData; +import org.sonar.scanner.protocol.input.ProjectRepositories; import org.sonarqube.ws.WsBatch.WsProjectResponse; import org.sonarqube.ws.WsBatch.WsProjectResponse.FileData.Builder; diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectDataLoader.java b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectDataLoader.java index 5bf3879210d..7228cdb4aa1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectDataLoader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/ProjectDataLoader.java @@ -27,14 +27,14 @@ import java.util.Date; import java.util.List; import java.util.Map; import org.sonar.api.server.ServerSide; -import org.sonar.batch.protocol.input.FileData; -import org.sonar.batch.protocol.input.ProjectRepositories; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.FilePathWithHashDto; import org.sonar.db.property.PropertyDto; +import org.sonar.scanner.protocol.input.FileData; +import org.sonar.scanner.protocol.input.ProjectRepositories; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.user.UserSession; diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/UsersAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/UsersAction.java index fea1f994fcb..e3fd78766c7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/batch/UsersAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/batch/UsersAction.java @@ -26,7 +26,7 @@ import java.util.List; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.batch.protocol.input.BatchInput; +import org.sonar.scanner.protocol.input.ScannerInput; import org.sonar.server.user.UserSession; import org.sonar.server.user.index.UserDoc; import org.sonar.server.user.index.UserIndex; @@ -66,7 +66,7 @@ public class UsersAction implements BatchWsAction { List<String> logins = request.mandatoryParamAsStrings(PARAM_LOGINS); response.stream().setMediaType(MediaTypes.PROTOBUF); - BatchInput.User.Builder userBuilder = BatchInput.User.newBuilder(); + ScannerInput.User.Builder userBuilder = ScannerInput.User.newBuilder(); OutputStream output = response.stream().output(); try { for (Iterator<UserDoc> userDocIterator = userIndex.selectUsersForBatch(logins); userDocIterator.hasNext();) { @@ -77,7 +77,7 @@ public class UsersAction implements BatchWsAction { } } - private static void handleUser(UserDoc user, BatchInput.User.Builder userBuilder, OutputStream out) { + private static void handleUser(UserDoc user, ScannerInput.User.Builder userBuilder, OutputStream out) { userBuilder .clear() .setLogin(user.login()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java index 46ea7f38fa5..2941e9fc5d9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReader.java @@ -21,41 +21,41 @@ package org.sonar.server.computation.batch; import com.google.common.base.Optional; import javax.annotation.CheckForNull; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.ScannerReport; public interface BatchReportReader { - BatchReport.Metadata readMetadata(); + ScannerReport.Metadata readMetadata(); CloseableIterator<String> readScannerLogs(); - CloseableIterator<BatchReport.ActiveRule> readActiveRules(); + CloseableIterator<ScannerReport.ActiveRule> readActiveRules(); - CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef); + CloseableIterator<ScannerReport.Measure> readComponentMeasures(int componentRef); @CheckForNull - BatchReport.Changesets readChangesets(int componentRef); + ScannerReport.Changesets readChangesets(int componentRef); - BatchReport.Component readComponent(int componentRef); + ScannerReport.Component readComponent(int componentRef); - CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef); + CloseableIterator<ScannerReport.Issue> readComponentIssues(int componentRef); - CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef); + CloseableIterator<ScannerReport.Duplication> readComponentDuplications(int componentRef); - CloseableIterator<BatchReport.CpdTextBlock> readCpdTextBlocks(int componentRef); + CloseableIterator<ScannerReport.CpdTextBlock> readCpdTextBlocks(int componentRef); - CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef); + CloseableIterator<ScannerReport.Symbol> readComponentSymbols(int componentRef); - CloseableIterator<BatchReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef); + CloseableIterator<ScannerReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef); - CloseableIterator<BatchReport.Coverage> readComponentCoverage(int fileRef); + CloseableIterator<ScannerReport.Coverage> readComponentCoverage(int fileRef); /** * Reads file source line by line. Return an absent optional if the file doest not exist */ Optional<CloseableIterator<String>> readFileSource(int fileRef); - CloseableIterator<BatchReport.Test> readTests(int testFileRef); + CloseableIterator<ScannerReport.Test> readTests(int testFileRef); - CloseableIterator<BatchReport.CoverageDetail> readCoverageDetails(int testFileRef); + CloseableIterator<ScannerReport.CoverageDetail> readCoverageDetails(int testFileRef); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java index 980d22d3259..c1ae4b7f048 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/batch/BatchReportReaderImpl.java @@ -33,21 +33,21 @@ import javax.annotation.CheckForNull; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.io.LineIterator; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; import org.sonar.core.util.LineReaderIterator; +import org.sonar.scanner.protocol.output.ScannerReport; public class BatchReportReaderImpl implements BatchReportReader { - private final org.sonar.batch.protocol.output.BatchReportReader delegate; + private final org.sonar.scanner.protocol.output.ScannerReportReader delegate; // caching of metadata which are read often - private BatchReport.Metadata metadata; + private ScannerReport.Metadata metadata; public BatchReportReaderImpl(BatchReportDirectoryHolder batchReportDirectoryHolder) { - this.delegate = new org.sonar.batch.protocol.output.BatchReportReader(batchReportDirectoryHolder.getDirectory()); + this.delegate = new org.sonar.scanner.protocol.output.ScannerReportReader(batchReportDirectoryHolder.getDirectory()); } @Override - public BatchReport.Metadata readMetadata() { + public ScannerReport.Metadata readMetadata() { if (this.metadata == null) { this.metadata = delegate.readMetadata(); } @@ -69,53 +69,53 @@ public class BatchReportReaderImpl implements BatchReportReader { } @Override - public CloseableIterator<BatchReport.ActiveRule> readActiveRules() { + public CloseableIterator<ScannerReport.ActiveRule> readActiveRules() { return delegate.readActiveRules(); } @Override - public CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef) { + public CloseableIterator<ScannerReport.Measure> readComponentMeasures(int componentRef) { return delegate.readComponentMeasures(componentRef); } @Override @CheckForNull - public BatchReport.Changesets readChangesets(int componentRef) { + public ScannerReport.Changesets readChangesets(int componentRef) { return delegate.readChangesets(componentRef); } @Override - public BatchReport.Component readComponent(int componentRef) { + public ScannerReport.Component readComponent(int componentRef) { return delegate.readComponent(componentRef); } @Override - public CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef) { + public CloseableIterator<ScannerReport.Issue> readComponentIssues(int componentRef) { return delegate.readComponentIssues(componentRef); } @Override - public CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef) { + public CloseableIterator<ScannerReport.Duplication> readComponentDuplications(int componentRef) { return delegate.readComponentDuplications(componentRef); } @Override - public CloseableIterator<BatchReport.CpdTextBlock> readCpdTextBlocks(int componentRef) { + public CloseableIterator<ScannerReport.CpdTextBlock> readCpdTextBlocks(int componentRef) { return delegate.readCpdTextBlocks(componentRef); } @Override - public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) { + public CloseableIterator<ScannerReport.Symbol> readComponentSymbols(int componentRef) { return delegate.readComponentSymbols(componentRef); } @Override - public CloseableIterator<BatchReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef) { + public CloseableIterator<ScannerReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef) { return delegate.readComponentSyntaxHighlighting(fileRef); } @Override - public CloseableIterator<BatchReport.Coverage> readComponentCoverage(int fileRef) { + public CloseableIterator<ScannerReport.Coverage> readComponentCoverage(int fileRef) { return delegate.readComponentCoverage(fileRef); } @@ -163,14 +163,14 @@ public class BatchReportReaderImpl implements BatchReportReader { } @Override - public CloseableIterator<BatchReport.Test> readTests(int testFileRef) { + public CloseableIterator<ScannerReport.Test> readTests(int testFileRef) { File file = delegate.readTests(testFileRef); if (file == null) { return CloseableIterator.emptyCloseableIterator(); } try { - return new ParserCloseableIterator<>(BatchReport.Test.parser(), FileUtils.openInputStream(file)); + return new ParserCloseableIterator<>(ScannerReport.Test.parser(), FileUtils.openInputStream(file)); } catch (IOException e) { Throwables.propagate(e); // actually never reached @@ -179,14 +179,14 @@ public class BatchReportReaderImpl implements BatchReportReader { } @Override - public CloseableIterator<BatchReport.CoverageDetail> readCoverageDetails(int testFileRef) { + public CloseableIterator<ScannerReport.CoverageDetail> readCoverageDetails(int testFileRef) { File file = delegate.readCoverageDetails(testFileRef); if (file == null) { return CloseableIterator.emptyCloseableIterator(); } try { - return new ParserCloseableIterator<>(BatchReport.CoverageDetail.parser(), FileUtils.openInputStream(file)); + return new ParserCloseableIterator<>(ScannerReport.CoverageDetail.parser(), FileUtils.openInputStream(file)); } catch (IOException e) { Throwables.propagate(e); // actually never reached diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentImpl.java index bc93b14cd3c..c1c48346a98 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/ComponentImpl.java @@ -26,8 +26,8 @@ import java.util.List; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; @@ -107,7 +107,7 @@ public class ComponentImpl implements Component { throw new IllegalStateException("Only component of type PROJECT_VIEW have a FileAttributes object"); } - public static Builder builder(BatchReport.Component component) { + public static Builder builder(ScannerReport.Component component) { return new Builder(component); } @@ -122,7 +122,7 @@ public class ComponentImpl implements Component { private FileAttributes fileAttributes; private final List<Component> children = new ArrayList<>(); - private Builder(BatchReport.Component component) { + private Builder(ScannerReport.Component component) { checkNotNull(component); this.type = convertType(component.getType()); this.name = checkNotNull(component.getName()); @@ -155,7 +155,7 @@ public class ComponentImpl implements Component { return new ComponentImpl(this); } - private static ReportAttributes createBatchAttributes(BatchReport.Component component) { + private static ReportAttributes createBatchAttributes(ScannerReport.Component component) { return ReportAttributes.newBuilder(component.getRef()) .setVersion(component.hasVersion() ? component.getVersion() : null) .setPath(component.hasPath() ? component.getPath() : null) @@ -163,7 +163,7 @@ public class ComponentImpl implements Component { } @CheckForNull - private static FileAttributes createFileAttributes(BatchReport.Component component) { + private static FileAttributes createFileAttributes(ScannerReport.Component component) { if (component.getType() != Constants.ComponentType.FILE) { return null; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolder.java index 777ea980df7..441c1507b47 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/TreeRootHolder.java @@ -21,7 +21,7 @@ package org.sonar.server.computation.component; public interface TreeRootHolder { /** - * The root of the tree of Component representing the component in the current BatchReport. + * The root of the tree of Component representing the component in the current ScannerReport. * * @throws IllegalStateException if the holder is empty (ie. there is no root yet) */ diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java index 4af4e673a9c..63aa189e73d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java @@ -25,7 +25,6 @@ import java.util.List; import org.sonar.api.issue.Issue; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.log.Loggers; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.tracking.Input; import org.sonar.core.issue.tracking.LazyInput; @@ -33,6 +32,7 @@ import org.sonar.core.issue.tracking.LineHashSequence; import org.sonar.core.util.CloseableIterator; import org.sonar.db.protobuf.DbCommons; import org.sonar.db.protobuf.DbIssues; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.TreeRootHolder; @@ -86,11 +86,11 @@ public class TrackerRawInputFactory { for (DefaultIssue commonRuleIssue : commonRuleEngine.process(component)) { result.add(init(commonRuleIssue)); } - try (CloseableIterator<BatchReport.Issue> reportIssues = reportReader.readComponentIssues(component.getReportAttributes().getRef())) { + try (CloseableIterator<ScannerReport.Issue> reportIssues = reportReader.readComponentIssues(component.getReportAttributes().getRef())) { // optimization - do not load line hashes if there are no issues -> getLineHashSequence() is executed // as late as possible while (reportIssues.hasNext()) { - BatchReport.Issue reportIssue = reportIssues.next(); + ScannerReport.Issue reportIssue = reportIssues.next(); if (isIssueOnUnsupportedCommonRule(reportIssue)) { DefaultIssue issue = toIssue(getLineHashSequence(), reportIssue); result.add(issue); @@ -103,13 +103,13 @@ public class TrackerRawInputFactory { return result; } - private boolean isIssueOnUnsupportedCommonRule(BatchReport.Issue issue) { + private boolean isIssueOnUnsupportedCommonRule(ScannerReport.Issue issue) { // issues on batch common rules are ignored. This feature // is natively supported by compute engine since 5.2. return !issue.getRuleRepository().startsWith(CommonRuleKeys.REPOSITORY_PREFIX); } - private DefaultIssue toIssue(LineHashSequence lineHashSeq, BatchReport.Issue reportIssue) { + private DefaultIssue toIssue(LineHashSequence lineHashSeq, ScannerReport.Issue reportIssue) { DefaultIssue issue = new DefaultIssue(); init(issue); issue.setRuleKey(RuleKey.of(reportIssue.getRuleRepository(), reportIssue.getRuleKey())); @@ -132,10 +132,10 @@ public class TrackerRawInputFactory { if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange())); } - for (BatchReport.Flow flow : reportIssue.getFlowList()) { + for (ScannerReport.Flow flow : reportIssue.getFlowList()) { if (flow.getLocationCount() > 0) { DbIssues.Flow.Builder dbFlowBuilder = DbIssues.Flow.newBuilder(); - for (BatchReport.IssueLocation location : flow.getLocationList()) { + for (ScannerReport.IssueLocation location : flow.getLocationList()) { dbFlowBuilder.addLocation(convertLocation(location)); } dbLocationsBuilder.addFlow(dbFlowBuilder); @@ -155,7 +155,7 @@ public class TrackerRawInputFactory { return issue; } - private DbIssues.Location convertLocation(BatchReport.IssueLocation source) { + private DbIssues.Location convertLocation(ScannerReport.IssueLocation source) { DbIssues.Location.Builder target = DbIssues.Location.newBuilder(); if (source.hasComponentRef() && source.getComponentRef() != component.getReportAttributes().getRef()) { target.setComponentId(treeRootHolder.getComponentByRef(source.getComponentRef()).getUuid()); @@ -164,14 +164,14 @@ public class TrackerRawInputFactory { target.setMsg(source.getMsg()); } if (source.hasTextRange()) { - BatchReport.TextRange sourceRange = source.getTextRange(); + ScannerReport.TextRange sourceRange = source.getTextRange(); DbCommons.TextRange.Builder targetRange = convertTextRange(sourceRange); target.setTextRange(targetRange); } return target.build(); } - private DbCommons.TextRange.Builder convertTextRange(BatchReport.TextRange sourceRange) { + private DbCommons.TextRange.Builder convertTextRange(ScannerReport.TextRange sourceRange) { DbCommons.TextRange.Builder targetRange = DbCommons.TextRange.newBuilder(); if (sourceRange.hasStartLine()) { targetRange.setStartLine(sourceRange.getStartLine()); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java index bc5f97e4a35..21797b3b16f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchMeasureToMeasure.java @@ -22,14 +22,14 @@ package org.sonar.server.computation.measure; import com.google.common.base.Optional; import java.util.Objects; import javax.annotation.Nullable; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.metric.Metric; import static com.google.common.base.Optional.of; public class BatchMeasureToMeasure { - public Optional<Measure> toMeasure(@Nullable BatchReport.Measure batchMeasure, Metric metric) { + public Optional<Measure> toMeasure(@Nullable ScannerReport.Measure batchMeasure, Metric metric) { Objects.requireNonNull(metric); if (batchMeasure == null) { return Optional.absent(); @@ -57,21 +57,21 @@ public class BatchMeasureToMeasure { } } - private static Optional<Measure> toIntegerMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) { + private static Optional<Measure> toIntegerMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure, @Nullable String data) { if (!batchMeasure.hasIntValue()) { return toNoValueMeasure(builder, batchMeasure); } return of(builder.create(batchMeasure.getIntValue(), data)); } - private static Optional<Measure> toLongMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) { + private static Optional<Measure> toLongMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure, @Nullable String data) { if (!batchMeasure.hasLongValue()) { return toNoValueMeasure(builder, batchMeasure); } return of(builder.create(batchMeasure.getLongValue(), data)); } - private static Optional<Measure> toDoubleMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) { + private static Optional<Measure> toDoubleMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure, @Nullable String data) { if (!batchMeasure.hasDoubleValue()) { return toNoValueMeasure(builder, batchMeasure); } @@ -81,21 +81,21 @@ public class BatchMeasureToMeasure { data)); } - private static Optional<Measure> toBooleanMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure, @Nullable String data) { + private static Optional<Measure> toBooleanMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure, @Nullable String data) { if (!batchMeasure.hasBooleanValue()) { return toNoValueMeasure(builder, batchMeasure); } return of(builder.create(batchMeasure.getBooleanValue(), data)); } - private static Optional<Measure> toStringMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) { + private static Optional<Measure> toStringMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) { if (!batchMeasure.hasStringValue()) { return toNoValueMeasure(builder, batchMeasure); } return of(builder.create(batchMeasure.getStringValue())); } - private static Optional<Measure> toLevelMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) { + private static Optional<Measure> toLevelMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) { if (!batchMeasure.hasStringValue()) { return toNoValueMeasure(builder, batchMeasure); } @@ -106,7 +106,7 @@ public class BatchMeasureToMeasure { return of(builder.create(level.get())); } - private static Optional<Measure> toNoValueMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) { + private static Optional<Measure> toNoValueMeasure(Measure.NewMeasureBuilder builder, ScannerReport.Measure batchMeasure) { return of(builder.createNoValue()); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java index d9facc5fd67..b8fa44ec45b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MeasureRepositoryImpl.java @@ -23,11 +23,11 @@ import com.google.common.base.Optional; import com.google.common.collect.SetMultimap; import java.util.HashSet; import java.util.Set; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.measure.MeasureDto; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.measure.MapBasedRawMeasureRepository.OverridePolicy; @@ -113,9 +113,9 @@ public class MeasureRepositoryImpl implements MeasureRepository { return; } - try (CloseableIterator<BatchReport.Measure> readIt = reportReader.readComponentMeasures(component.getReportAttributes().getRef())) { + try (CloseableIterator<ScannerReport.Measure> readIt = reportReader.readComponentMeasures(component.getReportAttributes().getRef())) { while (readIt.hasNext()) { - BatchReport.Measure batchMeasure = readIt.next(); + ScannerReport.Measure batchMeasure = readIt.next(); String metricKey = batchMeasure.getMetricKey(); if (reportMetricValidator.validate(metricKey)) { Metric metric = metricRepository.getByKey(metricKey); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ReportScmInfo.java b/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ReportScmInfo.java index 08f31fcb309..c60ceb94473 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ReportScmInfo.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ReportScmInfo.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.NoSuchElementException; import javax.annotation.Nonnull; import javax.annotation.concurrent.Immutable; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -40,12 +40,12 @@ import static java.util.Objects.requireNonNull; class ReportScmInfo implements ScmInfo { private final ScmInfo delegate; - ReportScmInfo(BatchReport.Changesets changesets) { + ReportScmInfo(ScannerReport.Changesets changesets) { requireNonNull(changesets); this.delegate = convertToScmInfo(changesets); } - private static ScmInfo convertToScmInfo(BatchReport.Changesets changesets) { + private static ScmInfo convertToScmInfo(ScannerReport.Changesets changesets) { return new ScmInfoImpl( from(new IntRangeIterable(changesets.getChangesetIndexByLineCount())) .transform(new LineIndexToChangeset(changesets))); @@ -72,11 +72,11 @@ class ReportScmInfo implements ScmInfo { } private static class LineIndexToChangeset implements Function<Integer, Changeset> { - private final BatchReport.Changesets changesets; + private final ScannerReport.Changesets changesets; private final Map<Integer, Changeset> changesetCache; private final Changeset.Builder builder = Changeset.newChangesetBuilder(); - public LineIndexToChangeset(BatchReport.Changesets changesets) { + public LineIndexToChangeset(ScannerReport.Changesets changesets) { this.changesets = changesets; changesetCache = new HashMap<>(changesets.getChangesetCount()); } @@ -94,7 +94,7 @@ class ReportScmInfo implements ScmInfo { return res; } - private Changeset convert(BatchReport.Changesets.Changeset changeset, int line) { + private Changeset convert(ScannerReport.Changesets.Changeset changeset, int line) { checkState(changeset.hasRevision(), "Changeset on line %s must have a revision", line); checkState(changeset.hasDate(), "Changeset on line %s must have a date", line); return builder diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ScmInfoRepositoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ScmInfoRepositoryImpl.java index 71db54efc32..f8a8e4a7480 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ScmInfoRepositoryImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/scm/ScmInfoRepositoryImpl.java @@ -24,10 +24,10 @@ import java.util.HashMap; import java.util.Map; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.source.FileSourceDto; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.AnalysisMetadataHolder; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; @@ -81,7 +81,7 @@ public class ScmInfoRepositoryImpl implements ScmInfoRepository { } private ScmInfo getScmInfoForComponent(Component component) { - BatchReport.Changesets changesets = batchReportReader.readChangesets(component.getReportAttributes().getRef()); + ScannerReport.Changesets changesets = batchReportReader.readChangesets(component.getReportAttributes().getRef()); if (changesets == null) { return getScmInfoFromDb(component); } @@ -106,7 +106,7 @@ public class ScmInfoRepositoryImpl implements ScmInfoRepository { } } - private static ScmInfo getScmInfoFromReport(Component file, BatchReport.Changesets changesets) { + private static ScmInfo getScmInfoFromReport(Component file, ScannerReport.Changesets changesets) { LOGGER.trace("Reading SCM info from report for file '{}'", file.getKey()); return new ReportScmInfo(changesets); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/CoverageLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/CoverageLineReader.java index aa1f6139f00..6a9ac03b364 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/CoverageLineReader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/CoverageLineReader.java @@ -21,21 +21,21 @@ package org.sonar.server.computation.source; import java.util.Iterator; import javax.annotation.CheckForNull; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.protobuf.DbFileSources; +import org.sonar.scanner.protocol.output.ScannerReport; public class CoverageLineReader implements LineReader { - private final Iterator<BatchReport.Coverage> coverageIterator; - private BatchReport.Coverage coverage; + private final Iterator<ScannerReport.Coverage> coverageIterator; + private ScannerReport.Coverage coverage; - public CoverageLineReader(Iterator<BatchReport.Coverage> coverageIterator) { + public CoverageLineReader(Iterator<ScannerReport.Coverage> coverageIterator) { this.coverageIterator = coverageIterator; } @Override public void read(DbFileSources.Line.Builder lineBuilder) { - BatchReport.Coverage reportCoverage = getNextLineCoverageIfMatchLine(lineBuilder.getLine()); + ScannerReport.Coverage reportCoverage = getNextLineCoverageIfMatchLine(lineBuilder.getLine()); if (reportCoverage != null) { processUnitTest(lineBuilder, reportCoverage); processIntegrationTest(lineBuilder, reportCoverage); @@ -44,7 +44,7 @@ public class CoverageLineReader implements LineReader { } } - private static void processUnitTest(DbFileSources.Line.Builder lineBuilder, BatchReport.Coverage reportCoverage) { + private static void processUnitTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.Coverage reportCoverage) { if (reportCoverage.hasUtHits()) { lineBuilder.setUtLineHits(reportCoverage.getUtHits() ? 1 : 0); } @@ -54,7 +54,7 @@ public class CoverageLineReader implements LineReader { } } - private static void processIntegrationTest(DbFileSources.Line.Builder lineBuilder, BatchReport.Coverage reportCoverage) { + private static void processIntegrationTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.Coverage reportCoverage) { if (reportCoverage.hasItHits()) { lineBuilder.setItLineHits(reportCoverage.getItHits() ? 1 : 0); } @@ -64,7 +64,7 @@ public class CoverageLineReader implements LineReader { } } - private static void processOverallTest(DbFileSources.Line.Builder lineBuilder, BatchReport.Coverage reportCoverage) { + private static void processOverallTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.Coverage reportCoverage) { if (reportCoverage.hasUtHits() || reportCoverage.hasItHits()) { lineBuilder.setOverallLineHits((reportCoverage.getUtHits() || reportCoverage.getItHits()) ? 1 : 0); } @@ -75,7 +75,7 @@ public class CoverageLineReader implements LineReader { } @CheckForNull - private BatchReport.Coverage getNextLineCoverageIfMatchLine(int line) { + private ScannerReport.Coverage getNextLineCoverageIfMatchLine(int line) { // Get next element (if exists) if (coverage == null && coverageIterator.hasNext()) { coverage = coverageIterator.next(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/HighlightingLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/HighlightingLineReader.java index 95c5a4f5c18..ac8e167336c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/HighlightingLineReader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/HighlightingLineReader.java @@ -26,9 +26,9 @@ import java.util.Map; import javax.annotation.CheckForNull; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.protobuf.DbFileSources; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.source.RangeOffsetConverter.RangeOffsetConverterException; @@ -56,13 +56,13 @@ public class HighlightingLineReader implements LineReader { .build(); private final Component file; - private final Iterator<BatchReport.SyntaxHighlighting> lineHighlightingIterator; + private final Iterator<ScannerReport.SyntaxHighlighting> lineHighlightingIterator; private final RangeOffsetConverter rangeOffsetConverter; - private final List<BatchReport.SyntaxHighlighting> highlightingList; + private final List<ScannerReport.SyntaxHighlighting> highlightingList; - private BatchReport.SyntaxHighlighting currentItem; + private ScannerReport.SyntaxHighlighting currentItem; - public HighlightingLineReader(Component file, Iterator<BatchReport.SyntaxHighlighting> lineHighlightingIterator, RangeOffsetConverter rangeOffsetConverter) { + public HighlightingLineReader(Component file, Iterator<ScannerReport.SyntaxHighlighting> lineHighlightingIterator, RangeOffsetConverter rangeOffsetConverter) { this.file = file; this.lineHighlightingIterator = lineHighlightingIterator; this.rangeOffsetConverter = rangeOffsetConverter; @@ -87,7 +87,7 @@ public class HighlightingLineReader implements LineReader { StringBuilder highlighting = new StringBuilder(); incrementHighlightingListMatchingLine(line); - for (Iterator<BatchReport.SyntaxHighlighting> syntaxHighlightingIterator = highlightingList.iterator(); syntaxHighlightingIterator.hasNext();) { + for (Iterator<ScannerReport.SyntaxHighlighting> syntaxHighlightingIterator = highlightingList.iterator(); syntaxHighlightingIterator.hasNext();) { processHighlighting(syntaxHighlightingIterator, highlighting, lineBuilder); } if (highlighting.length() > 0) { @@ -95,11 +95,11 @@ public class HighlightingLineReader implements LineReader { } } - private void processHighlighting(Iterator<BatchReport.SyntaxHighlighting> syntaxHighlightingIterator, StringBuilder highlighting, + private void processHighlighting(Iterator<ScannerReport.SyntaxHighlighting> syntaxHighlightingIterator, StringBuilder highlighting, DbFileSources.Line.Builder lineBuilder) { - BatchReport.SyntaxHighlighting syntaxHighlighting = syntaxHighlightingIterator.next(); + ScannerReport.SyntaxHighlighting syntaxHighlighting = syntaxHighlightingIterator.next(); int line = lineBuilder.getLine(); - BatchReport.TextRange range = syntaxHighlighting.getRange(); + ScannerReport.TextRange range = syntaxHighlighting.getRange(); if (range.getStartLine() <= line) { String offsets = rangeOffsetConverter.offsetToString(syntaxHighlighting.getRange(), line, lineBuilder.getSource().length()); if (offsets.isEmpty()) { @@ -128,7 +128,7 @@ public class HighlightingLineReader implements LineReader { } private void incrementHighlightingListMatchingLine(int line) { - BatchReport.SyntaxHighlighting syntaxHighlighting = getNextHighlightingMatchingLine(line); + ScannerReport.SyntaxHighlighting syntaxHighlighting = getNextHighlightingMatchingLine(line); while (syntaxHighlighting != null) { highlightingList.add(syntaxHighlighting); this.currentItem = null; @@ -137,7 +137,7 @@ public class HighlightingLineReader implements LineReader { } @CheckForNull - private BatchReport.SyntaxHighlighting getNextHighlightingMatchingLine(int line) { + private ScannerReport.SyntaxHighlighting getNextHighlightingMatchingLine(int line) { // Get next element (if exists) if (currentItem == null && lineHighlightingIterator.hasNext()) { currentItem = lineHighlightingIterator.next(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/RangeOffsetConverter.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/RangeOffsetConverter.java index 2cf207abf87..b029fe8254f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/RangeOffsetConverter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/RangeOffsetConverter.java @@ -19,7 +19,7 @@ */ package org.sonar.server.computation.source; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import static java.lang.String.format; @@ -28,7 +28,7 @@ public class RangeOffsetConverter { static final String OFFSET_SEPARATOR = ","; static final String SYMBOLS_SEPARATOR = ";"; - public String offsetToString(BatchReport.TextRange range, int lineIndex, int lineLength) { + public String offsetToString(ScannerReport.TextRange range, int lineIndex, int lineLength) { StringBuilder element = new StringBuilder(); validateOffsetOrder(range, lineIndex); @@ -46,17 +46,17 @@ public class RangeOffsetConverter { return element.toString(); } - private static void validateOffsetOrder(BatchReport.TextRange range, int line) { + private static void validateOffsetOrder(ScannerReport.TextRange range, int line) { checkExpression(range.getStartLine() != range.getEndLine() || range.getStartOffset() <= range.getEndOffset(), "End offset %s cannot be defined before start offset %s on line %s", range.getEndOffset(), range.getStartOffset(), line); } - private static void validateStartOffsetNotGreaterThanLineLength(BatchReport.TextRange range, int lineLength, int line) { + private static void validateStartOffsetNotGreaterThanLineLength(ScannerReport.TextRange range, int lineLength, int line) { checkExpression(range.getStartLine() != line || range.getStartOffset() <= lineLength, "Start offset %s is defined outside the length (%s) of the line %s", range.getStartOffset(), lineLength, line); } - private static void validateEndOffsetNotGreaterThanLineLength(BatchReport.TextRange range, int lineLength, int line) { + private static void validateEndOffsetNotGreaterThanLineLength(ScannerReport.TextRange range, int lineLength, int line) { checkExpression(range.getEndLine() != line || range.getEndOffset() <= lineLength, "End offset %s is defined outside the length (%s) of the line %s", range.getEndOffset(), lineLength, line); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/SourceLinesRepository.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/SourceLinesRepository.java index 6b41539cc3a..b7f621e902c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/SourceLinesRepository.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/SourceLinesRepository.java @@ -29,7 +29,7 @@ public interface SourceLinesRepository { * <p> * The returned {@link CloseableIterator} will wrap the {@link CloseableIterator} returned by * {@link org.sonar.server.computation.batch.BatchReportReader#readFileSource(int)} but enforces that the number - * of lines specified by {@link org.sonar.batch.protocol.output.BatchReport.Component#getLines()} is respected, adding + * of lines specified by {@link org.sonar.batch.protocol.output.ScannerReport.Component#getLines()} is respected, adding * an extra empty last line if required. * </p> * diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java b/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java index 8d519a863ab..c8636dbc82e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/source/SymbolsLineReader.java @@ -31,8 +31,8 @@ import java.util.List; import java.util.Map; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.protobuf.DbFileSources; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.component.Component; import static java.lang.String.format; @@ -45,15 +45,15 @@ public class SymbolsLineReader implements LineReader { private final Component file; private final RangeOffsetConverter rangeOffsetConverter; - private final Map<BatchReport.Symbol, Integer> idsBySymbol; - private final SetMultimap<Integer, BatchReport.Symbol> symbolsPerLine; + private final Map<ScannerReport.Symbol, Integer> idsBySymbol; + private final SetMultimap<Integer, ScannerReport.Symbol> symbolsPerLine; private boolean areSymbolsValid = true; - public SymbolsLineReader(Component file, Iterator<BatchReport.Symbol> symbolIterator, RangeOffsetConverter rangeOffsetConverter) { + public SymbolsLineReader(Component file, Iterator<ScannerReport.Symbol> symbolIterator, RangeOffsetConverter rangeOffsetConverter) { this.file = file; this.rangeOffsetConverter = rangeOffsetConverter; - List<BatchReport.Symbol> symbols = Lists.newArrayList(symbolIterator); + List<ScannerReport.Symbol> symbols = Lists.newArrayList(symbolIterator); // Sort symbols to have deterministic id generation Collections.sort(symbols, SymbolsComparator.INSTANCE); @@ -77,17 +77,17 @@ public class SymbolsLineReader implements LineReader { private void processSymbols(DbFileSources.Line.Builder lineBuilder) { int line = lineBuilder.getLine(); - List<BatchReport.Symbol> lineSymbols = new ArrayList<>(this.symbolsPerLine.get(line)); + List<ScannerReport.Symbol> lineSymbols = new ArrayList<>(this.symbolsPerLine.get(line)); // Sort symbols to have deterministic results and avoid false variation that would lead to an unnecessary update of the source files // data Collections.sort(lineSymbols, SymbolsComparator.INSTANCE); StringBuilder symbolString = new StringBuilder(); - for (BatchReport.Symbol lineSymbol : lineSymbols) { + for (ScannerReport.Symbol lineSymbol : lineSymbols) { int symbolId = idsBySymbol.get(lineSymbol); appendSymbol(symbolString, lineSymbol.getDeclaration(), line, symbolId, lineBuilder.getSource()); - for (BatchReport.TextRange range : lineSymbol.getReferenceList()) { + for (ScannerReport.TextRange range : lineSymbol.getReferenceList()) { appendSymbol(symbolString, range, line, symbolId, lineBuilder.getSource()); } } @@ -96,7 +96,7 @@ public class SymbolsLineReader implements LineReader { } } - private void appendSymbol(StringBuilder lineSymbol, BatchReport.TextRange range, int line, int symbolId, String sourceLine) { + private void appendSymbol(StringBuilder lineSymbol, ScannerReport.TextRange range, int line, int symbolId, String sourceLine) { if (matchLine(range, line)) { String offsets = rangeOffsetConverter.offsetToString(range, line, sourceLine.length()); if (!offsets.isEmpty()) { @@ -110,42 +110,42 @@ public class SymbolsLineReader implements LineReader { } } - private static boolean matchLine(BatchReport.TextRange range, int line) { + private static boolean matchLine(ScannerReport.TextRange range, int line) { return range.getStartLine() <= line && range.getEndLine() >= line; } - private static Map<BatchReport.Symbol, Integer> createIdsBySymbolMap(List<BatchReport.Symbol> symbols) { - Map<BatchReport.Symbol, Integer> map = new HashMap<>(symbols.size()); + private static Map<ScannerReport.Symbol, Integer> createIdsBySymbolMap(List<ScannerReport.Symbol> symbols) { + Map<ScannerReport.Symbol, Integer> map = new HashMap<>(symbols.size()); int symbolId = 1; - for (BatchReport.Symbol symbol : symbols) { + for (ScannerReport.Symbol symbol : symbols) { map.put(symbol, symbolId); symbolId++; } return map; } - private static SetMultimap<Integer, BatchReport.Symbol> buildSymbolsPerLine(List<BatchReport.Symbol> symbols) { - SetMultimap<Integer, BatchReport.Symbol> res = HashMultimap.create(); - for (BatchReport.Symbol symbol : symbols) { + private static SetMultimap<Integer, ScannerReport.Symbol> buildSymbolsPerLine(List<ScannerReport.Symbol> symbols) { + SetMultimap<Integer, ScannerReport.Symbol> res = HashMultimap.create(); + for (ScannerReport.Symbol symbol : symbols) { putForTextRange(res, symbol, symbol.getDeclaration()); - for (BatchReport.TextRange textRange : symbol.getReferenceList()) { + for (ScannerReport.TextRange textRange : symbol.getReferenceList()) { putForTextRange(res, symbol, textRange); } } return res; } - private static void putForTextRange(SetMultimap<Integer, BatchReport.Symbol> res, BatchReport.Symbol symbol, BatchReport.TextRange declaration) { + private static void putForTextRange(SetMultimap<Integer, ScannerReport.Symbol> res, ScannerReport.Symbol symbol, ScannerReport.TextRange declaration) { for (int i = declaration.getStartLine(); i <= declaration.getEndLine(); i++) { res.put(i, symbol); } } - private enum SymbolsComparator implements Comparator<BatchReport.Symbol> { + private enum SymbolsComparator implements Comparator<ScannerReport.Symbol> { INSTANCE; @Override - public int compare(BatchReport.Symbol o1, BatchReport.Symbol o2) { + public int compare(ScannerReport.Symbol o1, ScannerReport.Symbol o2) { if (o1.getDeclaration().getStartLine() == o2.getDeclaration().getStartLine()) { return Integer.compare(o1.getDeclaration().getStartOffset(), o2.getDeclaration().getStartOffset()); } else { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java index 9342d7519b8..c5281b479c4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/BuildComponentTreeStep.java @@ -24,12 +24,12 @@ import com.google.common.collect.Iterables; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.component.ComponentKeys; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.SnapshotDto; import org.sonar.db.component.SnapshotQuery; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolder; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; @@ -61,7 +61,7 @@ public class BuildComponentTreeStep implements ComputationStep { @Override public void execute() { String branch = analysisMetadataHolder.getBranch(); - BatchReport.Component reportProject = reportReader.readComponent(analysisMetadataHolder.getRootComponentRef()); + ScannerReport.Component reportProject = reportReader.readComponent(analysisMetadataHolder.getRootComponentRef()); UuidFactory uuidFactory = new UuidFactory(dbClient, moduleKey(reportProject, branch)); Component project = new ComponentRootBuilder(reportProject, uuidFactory, branch).build(); treeRootHolder.setRoot(project); @@ -92,14 +92,14 @@ public class BuildComponentTreeStep implements ComputationStep { private class ComponentRootBuilder { - private final BatchReport.Component reportProject; + private final ScannerReport.Component reportProject; private final UuidFactory uuidFactory; @CheckForNull private final String branch; - public ComponentRootBuilder(BatchReport.Component reportProject, UuidFactory uuidFactory, @Nullable String branch) { + public ComponentRootBuilder(ScannerReport.Component reportProject, UuidFactory uuidFactory, @Nullable String branch) { this.reportProject = reportProject; this.uuidFactory = uuidFactory; this.branch = branch; @@ -109,7 +109,7 @@ public class BuildComponentTreeStep implements ComputationStep { return buildComponent(reportProject, moduleKey(reportProject, branch)); } - private ComponentImpl buildComponent(BatchReport.Component reportComponent, String latestModuleKey) { + private ComponentImpl buildComponent(ScannerReport.Component reportComponent, String latestModuleKey) { switch (reportComponent.getType()) { case PROJECT: case MODULE: @@ -123,7 +123,7 @@ public class BuildComponentTreeStep implements ComputationStep { } } - private ComponentImpl buildComponent(BatchReport.Component reportComponent, String componentKey, String latestModuleKey) { + private ComponentImpl buildComponent(ScannerReport.Component reportComponent, String componentKey, String latestModuleKey) { return builder(reportComponent) .addChildren(toArray(buildChildren(reportComponent, latestModuleKey), Component.class)) .setKey(componentKey) @@ -131,7 +131,7 @@ public class BuildComponentTreeStep implements ComputationStep { .build(); } - private Iterable<Component> buildChildren(BatchReport.Component component, final String latestModuleKey) { + private Iterable<Component> buildChildren(ScannerReport.Component component, final String latestModuleKey) { return Iterables.transform( component.getChildRefList(), new Function<Integer, Component>() { @@ -144,7 +144,7 @@ public class BuildComponentTreeStep implements ComputationStep { } } - private static String moduleKey(BatchReport.Component reportComponent, @Nullable String branch) { + private static String moduleKey(ScannerReport.Component reportComponent, @Nullable String branch) { return ComponentKeys.createKey(reportComponent.getKey(), branch); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java index 023c3b95e91..addd61f5fab 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStep.java @@ -25,12 +25,12 @@ import java.util.List; import javax.annotation.Nonnull; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.batch.protocol.output.BatchReport.CpdTextBlock; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.duplication.DuplicationUnitDto; import org.sonar.duplications.block.Block; import org.sonar.duplications.block.ByteArray; +import org.sonar.scanner.protocol.output.ScannerReport.CpdTextBlock; import org.sonar.server.computation.analysis.AnalysisMetadataHolder; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStep.java index a6fd90125e5..1826ff7a3eb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStep.java @@ -21,8 +21,8 @@ package org.sonar.server.computation.step; import com.google.common.base.Function; import javax.annotation.Nonnull; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.CrawlerDepthLimit; @@ -66,7 +66,7 @@ public class LoadDuplicationsFromReportStep implements ComputationStep { new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) { @Override public void visitFile(Component file) { - CloseableIterator<BatchReport.Duplication> duplications = batchReportReader.readComponentDuplications(file.getReportAttributes().getRef()); + CloseableIterator<ScannerReport.Duplication> duplications = batchReportReader.readComponentDuplications(file.getReportAttributes().getRef()); try { int idGenerator = 1; while (duplications.hasNext()) { @@ -80,7 +80,7 @@ public class LoadDuplicationsFromReportStep implements ComputationStep { }).visit(treeRootHolder.getRoot()); } - private void loadDuplications(Component file, BatchReport.Duplication duplication, int id) { + private void loadDuplications(Component file, ScannerReport.Duplication duplication, int id) { duplicationRepository.add(file, new Duplication( convert(duplication.getOriginPosition(), id), @@ -89,15 +89,15 @@ public class LoadDuplicationsFromReportStep implements ComputationStep { )); } - private static TextBlock convert(BatchReport.TextRange textRange) { + private static TextBlock convert(ScannerReport.TextRange textRange) { return new TextBlock(textRange.getStartLine(), textRange.getEndLine()); } - private static DetailedTextBlock convert(BatchReport.TextRange textRange, int id) { + private static DetailedTextBlock convert(ScannerReport.TextRange textRange, int id) { return new DetailedTextBlock(id, textRange.getStartLine(), textRange.getEndLine()); } - private class BatchDuplicateToCeDuplicate implements Function<BatchReport.Duplicate, Duplicate> { + private class BatchDuplicateToCeDuplicate implements Function<ScannerReport.Duplicate, Duplicate> { private final Component file; private BatchDuplicateToCeDuplicate(Component file) { @@ -106,7 +106,7 @@ public class LoadDuplicationsFromReportStep implements ComputationStep { @Override @Nonnull - public Duplicate apply(@Nonnull BatchReport.Duplicate input) { + public Duplicate apply(@Nonnull ScannerReport.Duplicate input) { if (input.hasOtherFileRef()) { checkArgument(input.getOtherFileRef() != file.getReportAttributes().getRef(), "file and otherFile references can not be the same"); return new InProjectDuplicate( diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadQualityProfilesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadQualityProfilesStep.java index dc18f23601c..1f93bba907b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadQualityProfilesStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadQualityProfilesStep.java @@ -28,8 +28,8 @@ import java.util.Map; import javax.annotation.Nonnull; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.RuleStatus; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.issue.Rule; import org.sonar.server.computation.issue.RuleRepository; @@ -53,9 +53,9 @@ public class LoadQualityProfilesStep implements ComputationStep { @Override public void execute() { List<ActiveRule> activeRules = new ArrayList<>(); - try (CloseableIterator<BatchReport.ActiveRule> batchActiveRules = batchReportReader.readActiveRules()) { + try (CloseableIterator<ScannerReport.ActiveRule> batchActiveRules = batchReportReader.readActiveRules()) { while (batchActiveRules.hasNext()) { - BatchReport.ActiveRule batchActiveRule = batchActiveRules.next(); + ScannerReport.ActiveRule batchActiveRule = batchActiveRules.next(); activeRules.add(convert(batchActiveRule)); } } @@ -77,10 +77,10 @@ public class LoadQualityProfilesStep implements ComputationStep { return "Load quality profiles"; } - private static ActiveRule convert(BatchReport.ActiveRule input) { + private static ActiveRule convert(ScannerReport.ActiveRule input) { RuleKey key = RuleKey.of(input.getRuleRepository(), input.getRuleKey()); Map<String, String> params = new HashMap<>(); - for (BatchReport.ActiveRule.ActiveRuleParam inputParam : input.getParamList()) { + for (ScannerReport.ActiveRule.ActiveRuleParam inputParam : input.getParamList()) { params.put(inputParam.getKey(), inputParam.getValue()); } return new ActiveRule(key, input.getSeverity().name(), params); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStep.java index 726c28cb9d3..53b7d7e106d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStep.java @@ -20,7 +20,7 @@ package org.sonar.server.computation.step; import org.sonar.api.utils.MessageException; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolder; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.queue.CeTask; @@ -44,7 +44,7 @@ public class LoadReportAnalysisMetadataHolderStep implements ComputationStep { @Override public void execute() { - BatchReport.Metadata reportMetadata = reportReader.readMetadata(); + ScannerReport.Metadata reportMetadata = reportReader.readMetadata(); checkProjectKeyConsistency(reportMetadata); @@ -54,7 +54,7 @@ public class LoadReportAnalysisMetadataHolderStep implements ComputationStep { mutableAnalysisMetadataHolder.setCrossProjectDuplicationEnabled(reportMetadata.hasCrossProjectDuplicationActivated() && reportMetadata.getCrossProjectDuplicationActivated()); } - private void checkProjectKeyConsistency(BatchReport.Metadata reportMetadata) { + private void checkProjectKeyConsistency(ScannerReport.Metadata reportMetadata) { String reportProjectKey = projectKeyFromReport(reportMetadata); String componentKey = ceTask.getComponentKey(); if (componentKey == null) { @@ -72,7 +72,7 @@ public class LoadReportAnalysisMetadataHolderStep implements ComputationStep { } } - private static String projectKeyFromReport(BatchReport.Metadata reportMetadata) { + private static String projectKeyFromReport(ScannerReport.Metadata reportMetadata) { if (reportMetadata.hasBranch()) { return reportMetadata.getProjectKey() + ":" + reportMetadata.getBranch(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStep.java index 0033463fab5..8a2410363fe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStep.java @@ -19,11 +19,11 @@ */ package org.sonar.server.computation.step; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.duplication.DuplicationUnitDto; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.CrawlerDepthLimit; @@ -88,10 +88,10 @@ public class PersistCrossProjectDuplicationIndexStep implements ComputationStep private void visitComponent(Component component) { int indexInFile = 0; - CloseableIterator<BatchReport.CpdTextBlock> blocks = reportReader.readCpdTextBlocks(component.getReportAttributes().getRef()); + CloseableIterator<ScannerReport.CpdTextBlock> blocks = reportReader.readCpdTextBlocks(component.getReportAttributes().getRef()); try { while (blocks.hasNext()) { - BatchReport.CpdTextBlock block = blocks.next(); + ScannerReport.CpdTextBlock block = blocks.next(); dbClient.duplicationDao().insert( session, new DuplicationUnitDto() diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java index 47827c044b7..55832544b7d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java @@ -32,7 +32,6 @@ import org.apache.commons.lang.ObjectUtils; import org.apache.ibatis.session.ResultContext; import org.apache.ibatis.session.ResultHandler; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -40,6 +39,7 @@ import org.sonar.db.MyBatis; import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.source.FileSourceDto; import org.sonar.db.source.FileSourceDto.Type; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.CrawlerDepthLimit; @@ -123,7 +123,7 @@ public class PersistFileSourcesStep implements ComputationStep { @Override public void visitFile(Component file) { int fileRef = file.getReportAttributes().getRef(); - BatchReport.Component component = reportReader.readComponent(fileRef); + ScannerReport.Component component = reportReader.readComponent(fileRef); CloseableIterator<String> linesIterator = sourceLinesRepository.readLines(file); LineReaders lineReaders = new LineReaders(reportReader, scmInfoRepository, duplicationRepository, file); try { @@ -206,7 +206,7 @@ public class PersistFileSourcesStep implements ComputationStep { LineReaders(BatchReportReader reportReader, ScmInfoRepository scmInfoRepository, DuplicationRepository duplicationRepository, Component component) { int componentRef = component.getReportAttributes().getRef(); - CloseableIterator<BatchReport.Coverage> coverageIt = reportReader.readComponentCoverage(componentRef); + CloseableIterator<ScannerReport.Coverage> coverageIt = reportReader.readComponentCoverage(componentRef); closeables.add(coverageIt); readers.add(new CoverageLineReader(coverageIt)); @@ -219,11 +219,11 @@ public class PersistFileSourcesStep implements ComputationStep { } RangeOffsetConverter rangeOffsetConverter = new RangeOffsetConverter(); - CloseableIterator<BatchReport.SyntaxHighlighting> highlightingIt = reportReader.readComponentSyntaxHighlighting(componentRef); + CloseableIterator<ScannerReport.SyntaxHighlighting> highlightingIt = reportReader.readComponentSyntaxHighlighting(componentRef); closeables.add(highlightingIt); readers.add(new HighlightingLineReader(component, highlightingIt, rangeOffsetConverter)); - CloseableIterator<BatchReport.Symbol> symbolsIt = reportReader.readComponentSymbols(componentRef); + CloseableIterator<ScannerReport.Symbol> symbolsIt = reportReader.readComponentSymbols(componentRef); closeables.add(symbolsIt); readers.add(new SymbolsLineReader(component, symbolsIt, rangeOffsetConverter)); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java index a25ccdc9f37..98fac5cb3c4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistProjectLinksStep.java @@ -28,12 +28,12 @@ import java.util.Map; import java.util.Set; import javax.annotation.Nullable; import org.sonar.api.i18n.I18n; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; import org.sonar.db.component.ComponentLinkDto; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.CrawlerDepthLimit; @@ -100,18 +100,18 @@ public class PersistProjectLinksStep implements ComputationStep { } private void processComponent(Component component) { - BatchReport.Component batchComponent = reportReader.readComponent(component.getReportAttributes().getRef()); + ScannerReport.Component batchComponent = reportReader.readComponent(component.getReportAttributes().getRef()); processLinks(component.getUuid(), batchComponent.getLinkList()); } - private void processLinks(String componentUuid, List<BatchReport.ComponentLink> links) { + private void processLinks(String componentUuid, List<ScannerReport.ComponentLink> links) { List<ComponentLinkDto> previousLinks = dbClient.componentLinkDao().selectByComponentUuid(session, componentUuid); mergeLinks(session, componentUuid, links, previousLinks); } - private void mergeLinks(DbSession session, String componentUuid, List<BatchReport.ComponentLink> links, List<ComponentLinkDto> previousLinks) { + private void mergeLinks(DbSession session, String componentUuid, List<ScannerReport.ComponentLink> links, List<ComponentLinkDto> previousLinks) { Set<String> linkType = newHashSet(); - for (final BatchReport.ComponentLink link : links) { + for (final ScannerReport.ComponentLink link : links) { String type = convertType(link.getType()); if (!linkType.contains(type)) { linkType.add(type); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java index 7f5dbb51f8a..fec594e8115 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistTestsStep.java @@ -37,7 +37,6 @@ import org.apache.ibatis.session.ResultHandler; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; import org.sonar.core.util.Uuids; import org.sonar.db.DbClient; @@ -46,6 +45,7 @@ import org.sonar.db.MyBatis; import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.source.FileSourceDto; import org.sonar.db.source.FileSourceDto.Type; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.ComponentVisitor; @@ -185,9 +185,9 @@ public class PersistTestsStep implements ComputationStep { private Multimap<String, DbFileSources.Test.Builder> buildDbTests(int componentRed) { Multimap<String, DbFileSources.Test.Builder> tests = ArrayListMultimap.create(); - try (CloseableIterator<BatchReport.Test> testIterator = reportReader.readTests(componentRed)) { + try (CloseableIterator<ScannerReport.Test> testIterator = reportReader.readTests(componentRed)) { while (testIterator.hasNext()) { - BatchReport.Test batchTest = testIterator.next(); + ScannerReport.Test batchTest = testIterator.next(); DbFileSources.Test.Builder dbTest = DbFileSources.Test.newBuilder(); dbTest.setUuid(Uuids.create()); dbTest.setName(batchTest.getName()); @@ -217,10 +217,10 @@ public class PersistTestsStep implements ComputationStep { private Table<String, String, DbFileSources.Test.CoveredFile.Builder> loadCoverageDetails(int testFileRef) { Table<String, String, DbFileSources.Test.CoveredFile.Builder> nameToCoveredFiles = HashBasedTable.create(); - try (CloseableIterator<BatchReport.CoverageDetail> coverageIterator = reportReader.readCoverageDetails(testFileRef)) { + try (CloseableIterator<ScannerReport.CoverageDetail> coverageIterator = reportReader.readCoverageDetails(testFileRef)) { while (coverageIterator.hasNext()) { - BatchReport.CoverageDetail batchCoverageDetail = coverageIterator.next(); - for (BatchReport.CoverageDetail.CoveredFile batchCoveredFile : batchCoverageDetail.getCoveredFileList()) { + ScannerReport.CoverageDetail batchCoverageDetail = coverageIterator.next(); + for (ScannerReport.CoverageDetail.CoveredFile batchCoveredFile : batchCoverageDetail.getCoveredFileList()) { String testName = batchCoverageDetail.getTestName(); String mainFileUuid = getUuid(batchCoveredFile.getFileRef()); DbFileSources.Test.CoveredFile.Builder existingDbCoveredFile = nameToCoveredFiles.get(testName, mainFileUuid); diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java index 9e1d18b0a36..944b683955b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java @@ -32,11 +32,11 @@ import org.sonar.api.platform.Server; import org.sonar.api.security.DefaultGroups; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.batch.protocol.Constants.Severity; -import org.sonar.batch.protocol.input.BatchInput.ServerIssue; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; +import org.sonar.scanner.protocol.Constants.Severity; +import org.sonar.scanner.protocol.input.ScannerInput.ServerIssue; import org.sonar.server.component.ComponentFinder; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.ForbiddenException; @@ -54,7 +54,6 @@ import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; - public class IssuesActionTest { final static String PROJECT_KEY = "struts"; @@ -336,7 +335,7 @@ public class IssuesActionTest { issueAuthorizationIndexer.index(newArrayList(new IssueAuthorizationDao.Dto(projectUuid, 1).addGroup(group).addUser(user))); } - private void addBrowsePermissionOnComponent(String componentKey){ + private void addBrowsePermissionOnComponent(String componentKey) { userSessionRule.addComponentPermission(UserRole.USER, PROJECT_KEY, componentKey); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java index c9255c47f8d..6bc3935f5fc 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java @@ -22,8 +22,8 @@ package org.sonar.server.batch; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.sonar.batch.protocol.input.FileData; -import org.sonar.batch.protocol.input.ProjectRepositories; +import org.sonar.scanner.protocol.input.FileData; +import org.sonar.scanner.protocol.input.ProjectRepositories; import org.sonar.server.ws.TestResponse; import org.sonar.server.ws.WsActionTester; import org.sonarqube.ws.MediaTypes; diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java index 6f170d8417e..f3424182762 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectDataLoaderMediumTest.java @@ -29,8 +29,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.web.UserRole; -import org.sonar.batch.protocol.input.FileData; -import org.sonar.batch.protocol.input.ProjectRepositories; import org.sonar.core.permission.GlobalPermissions; import org.sonar.db.DbClient; import org.sonar.db.DbSession; @@ -41,6 +39,8 @@ import org.sonar.db.qualityprofile.QualityProfileDto; import org.sonar.db.source.FileSourceDao; import org.sonar.db.source.FileSourceDto; import org.sonar.db.source.FileSourceDto.Type; +import org.sonar.scanner.protocol.input.FileData; +import org.sonar.scanner.protocol.input.ProjectRepositories; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.qualityprofile.QProfileName; import org.sonar.server.tester.ServerTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java index 56616c408d8..85577bd5245 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java @@ -29,7 +29,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.config.Settings; import org.sonar.api.platform.Server; -import org.sonar.batch.protocol.input.BatchInput.User; +import org.sonar.scanner.protocol.input.ScannerInput.User; import org.sonar.server.es.EsTester; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.tester.UserSessionRule; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java index e168ad4ccab..c265584c865 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderImplTest.java @@ -26,9 +26,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.internal.JUnitTempFolder; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReportWriter; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.scanner.protocol.output.ScannerReportWriter; import static com.google.common.collect.ImmutableList.of; import static org.assertj.core.api.Assertions.assertThat; @@ -36,33 +36,33 @@ import static org.assertj.guava.api.Assertions.assertThat; public class BatchReportReaderImplTest { private static final int COMPONENT_REF = 1; - private static final BatchReport.Changesets CHANGESETS = BatchReport.Changesets.newBuilder().setComponentRef(COMPONENT_REF).build(); - private static final BatchReport.Measure MEASURE = BatchReport.Measure.newBuilder().build(); - private static final BatchReport.Component COMPONENT = BatchReport.Component.newBuilder().setRef(COMPONENT_REF).build(); - private static final BatchReport.Issue ISSUE = BatchReport.Issue.newBuilder().build(); - private static final BatchReport.Duplication DUPLICATION = BatchReport.Duplication.newBuilder().build(); - private static final BatchReport.CpdTextBlock DUPLICATION_BLOCK = BatchReport.CpdTextBlock.newBuilder().build(); - private static final BatchReport.Symbol SYMBOL = BatchReport.Symbol.newBuilder().build(); - private static final BatchReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_1 = BatchReport.SyntaxHighlighting.newBuilder().build(); - private static final BatchReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_2 = BatchReport.SyntaxHighlighting.newBuilder().build(); - private static final BatchReport.Coverage COVERAGE_1 = BatchReport.Coverage.newBuilder().build(); - private static final BatchReport.Coverage COVERAGE_2 = BatchReport.Coverage.newBuilder().build(); - private static final BatchReport.Test TEST_1 = BatchReport.Test.newBuilder().setName("1").build(); - private static final BatchReport.Test TEST_2 = BatchReport.Test.newBuilder().setName("2").build(); - private static final BatchReport.CoverageDetail COVERAGE_DETAIL_1 = BatchReport.CoverageDetail.newBuilder().setTestName("1").build(); - private static final BatchReport.CoverageDetail COVERAGE_DETAIL_2 = BatchReport.CoverageDetail.newBuilder().setTestName("2").build(); + private static final ScannerReport.Changesets CHANGESETS = ScannerReport.Changesets.newBuilder().setComponentRef(COMPONENT_REF).build(); + private static final ScannerReport.Measure MEASURE = ScannerReport.Measure.newBuilder().build(); + private static final ScannerReport.Component COMPONENT = ScannerReport.Component.newBuilder().setRef(COMPONENT_REF).build(); + private static final ScannerReport.Issue ISSUE = ScannerReport.Issue.newBuilder().build(); + private static final ScannerReport.Duplication DUPLICATION = ScannerReport.Duplication.newBuilder().build(); + private static final ScannerReport.CpdTextBlock DUPLICATION_BLOCK = ScannerReport.CpdTextBlock.newBuilder().build(); + private static final ScannerReport.Symbol SYMBOL = ScannerReport.Symbol.newBuilder().build(); + private static final ScannerReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_1 = ScannerReport.SyntaxHighlighting.newBuilder().build(); + private static final ScannerReport.SyntaxHighlighting SYNTAX_HIGHLIGHTING_2 = ScannerReport.SyntaxHighlighting.newBuilder().build(); + private static final ScannerReport.Coverage COVERAGE_1 = ScannerReport.Coverage.newBuilder().build(); + private static final ScannerReport.Coverage COVERAGE_2 = ScannerReport.Coverage.newBuilder().build(); + private static final ScannerReport.Test TEST_1 = ScannerReport.Test.newBuilder().setName("1").build(); + private static final ScannerReport.Test TEST_2 = ScannerReport.Test.newBuilder().setName("2").build(); + private static final ScannerReport.CoverageDetail COVERAGE_DETAIL_1 = ScannerReport.CoverageDetail.newBuilder().setTestName("1").build(); + private static final ScannerReport.CoverageDetail COVERAGE_DETAIL_2 = ScannerReport.CoverageDetail.newBuilder().setTestName("2").build(); @Rule public JUnitTempFolder tempFolder = new JUnitTempFolder(); - private BatchReportWriter writer; + private ScannerReportWriter writer; private BatchReportReaderImpl underTest; @Before public void setUp() { BatchReportDirectoryHolder holder = new ImmutableBatchReportDirectoryHolder(tempFolder.newDir()); underTest = new BatchReportReaderImpl(holder); - writer = new BatchReportWriter(holder.getDirectory()); + writer = new ScannerReportWriter(holder.getDirectory()); } @Test(expected = IllegalStateException.class) @@ -72,11 +72,11 @@ public class BatchReportReaderImplTest { @Test public void readMetadata_result_is_cached() { - BatchReport.Metadata metadata = BatchReport.Metadata.newBuilder().build(); + ScannerReport.Metadata metadata = ScannerReport.Metadata.newBuilder().build(); writer.writeMetadata(metadata); - BatchReport.Metadata res = underTest.readMetadata(); + ScannerReport.Metadata res = underTest.readMetadata(); assertThat(res).isEqualTo(metadata); assertThat(underTest.readMetadata()).isSameAs(res); } @@ -105,7 +105,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentMeasures_returns_measures() { writer.writeComponentMeasures(COMPONENT_REF, of(MEASURE)); - try (CloseableIterator<BatchReport.Measure> measures = underTest.readComponentMeasures(COMPONENT_REF)) { + try (CloseableIterator<ScannerReport.Measure> measures = underTest.readComponentMeasures(COMPONENT_REF)) { assertThat(measures.next()).isEqualTo(MEASURE); assertThat(measures.hasNext()).isFalse(); } @@ -127,7 +127,7 @@ public class BatchReportReaderImplTest { public void verify_readChangesets_returns_changesets() { writer.writeComponentChangesets(CHANGESETS); - BatchReport.Changesets res = underTest.readChangesets(COMPONENT_REF); + ScannerReport.Changesets res = underTest.readChangesets(COMPONENT_REF); assertThat(res).isEqualTo(CHANGESETS); } @@ -166,7 +166,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentIssues_returns_Issues() { writer.writeComponentIssues(COMPONENT_REF, of(ISSUE)); - try (CloseableIterator<BatchReport.Issue> res = underTest.readComponentIssues(COMPONENT_REF)) { + try (CloseableIterator<ScannerReport.Issue> res = underTest.readComponentIssues(COMPONENT_REF)) { assertThat(res.next()).isEqualTo(ISSUE); assertThat(res.hasNext()).isFalse(); } @@ -188,7 +188,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentDuplications_returns_Issues() { writer.writeComponentDuplications(COMPONENT_REF, of(DUPLICATION)); - try (CloseableIterator<BatchReport.Duplication> res = underTest.readComponentDuplications(COMPONENT_REF)) { + try (CloseableIterator<ScannerReport.Duplication> res = underTest.readComponentDuplications(COMPONENT_REF)) { assertThat(res.next()).isEqualTo(DUPLICATION); assertThat(res.hasNext()).isFalse(); } @@ -210,7 +210,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentDuplicationBlocks_returns_Issues() { writer.writeCpdTextBlocks(COMPONENT_REF, of(DUPLICATION_BLOCK)); - try (CloseableIterator<BatchReport.CpdTextBlock> res = underTest.readCpdTextBlocks(COMPONENT_REF)) { + try (CloseableIterator<ScannerReport.CpdTextBlock> res = underTest.readCpdTextBlocks(COMPONENT_REF)) { assertThat(res.next()).isEqualTo(DUPLICATION_BLOCK); assertThat(res.hasNext()).isFalse(); } @@ -232,7 +232,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentSymbols_returns_Issues() { writer.writeComponentSymbols(COMPONENT_REF, of(SYMBOL)); - try (CloseableIterator<BatchReport.Symbol> res = underTest.readComponentSymbols(COMPONENT_REF)) { + try (CloseableIterator<ScannerReport.Symbol> res = underTest.readComponentSymbols(COMPONENT_REF)) { assertThat(res.next()).isEqualTo(SYMBOL); assertThat(res.hasNext()).isFalse(); } @@ -254,7 +254,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentSyntaxHighlighting() { writer.writeComponentSyntaxHighlighting(COMPONENT_REF, of(SYNTAX_HIGHLIGHTING_1, SYNTAX_HIGHLIGHTING_2)); - CloseableIterator<BatchReport.SyntaxHighlighting> res = underTest.readComponentSyntaxHighlighting(COMPONENT_REF); + CloseableIterator<ScannerReport.SyntaxHighlighting> res = underTest.readComponentSyntaxHighlighting(COMPONENT_REF); assertThat(res).containsExactly(SYNTAX_HIGHLIGHTING_1, SYNTAX_HIGHLIGHTING_2); res.close(); } @@ -268,7 +268,7 @@ public class BatchReportReaderImplTest { public void verify_readComponentCoverage() { writer.writeComponentCoverage(COMPONENT_REF, of(COVERAGE_1, COVERAGE_2)); - CloseableIterator<BatchReport.Coverage> res = underTest.readComponentCoverage(COMPONENT_REF); + CloseableIterator<ScannerReport.Coverage> res = underTest.readComponentCoverage(COMPONENT_REF); assertThat(res).containsExactly(COVERAGE_1, COVERAGE_2); res.close(); } @@ -297,7 +297,7 @@ public class BatchReportReaderImplTest { public void verify_readTests() { writer.writeTests(COMPONENT_REF, of(TEST_1, TEST_2)); - CloseableIterator<BatchReport.Test> res = underTest.readTests(COMPONENT_REF); + CloseableIterator<ScannerReport.Test> res = underTest.readTests(COMPONENT_REF); assertThat(res).containsExactly(TEST_1, TEST_2); res.close(); } @@ -311,7 +311,7 @@ public class BatchReportReaderImplTest { public void verify_readCoverageDetails() { writer.writeCoverageDetails(COMPONENT_REF, of(COVERAGE_DETAIL_1, COVERAGE_DETAIL_2)); - CloseableIterator<BatchReport.CoverageDetail> res = underTest.readCoverageDetails(COMPONENT_REF); + CloseableIterator<ScannerReport.CoverageDetail> res = underTest.readCoverageDetails(COMPONENT_REF); assertThat(res).containsExactly(COVERAGE_DETAIL_1, COVERAGE_DETAIL_2); res.close(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java index 528f0d9165e..323e7a85230 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/batch/BatchReportReaderRule.java @@ -31,25 +31,25 @@ import javax.annotation.Nullable; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.ScannerReport; public class BatchReportReaderRule implements TestRule, BatchReportReader { - private BatchReport.Metadata metadata; + private ScannerReport.Metadata metadata; private List<String> scannerLogs; - private List<BatchReport.ActiveRule> activeRules = new ArrayList<>(); - private Map<Integer, List<BatchReport.Measure>> measures = new HashMap<>(); - private Map<Integer, BatchReport.Changesets> changesets = new HashMap<>(); - private Map<Integer, BatchReport.Component> components = new HashMap<>(); - private Map<Integer, List<BatchReport.Issue>> issues = new HashMap<>(); - private Map<Integer, List<BatchReport.Duplication>> duplications = new HashMap<>(); - private Map<Integer, List<BatchReport.CpdTextBlock>> duplicationBlocks = new HashMap<>(); - private Map<Integer, List<BatchReport.Symbol>> symbols = new HashMap<>(); - private Map<Integer, List<BatchReport.SyntaxHighlighting>> syntaxHighlightings = new HashMap<>(); - private Map<Integer, List<BatchReport.Coverage>> coverages = new HashMap<>(); + private List<ScannerReport.ActiveRule> activeRules = new ArrayList<>(); + private Map<Integer, List<ScannerReport.Measure>> measures = new HashMap<>(); + private Map<Integer, ScannerReport.Changesets> changesets = new HashMap<>(); + private Map<Integer, ScannerReport.Component> components = new HashMap<>(); + private Map<Integer, List<ScannerReport.Issue>> issues = new HashMap<>(); + private Map<Integer, List<ScannerReport.Duplication>> duplications = new HashMap<>(); + private Map<Integer, List<ScannerReport.CpdTextBlock>> duplicationBlocks = new HashMap<>(); + private Map<Integer, List<ScannerReport.Symbol>> symbols = new HashMap<>(); + private Map<Integer, List<ScannerReport.SyntaxHighlighting>> syntaxHighlightings = new HashMap<>(); + private Map<Integer, List<ScannerReport.Coverage>> coverages = new HashMap<>(); private Map<Integer, List<String>> fileSources = new HashMap<>(); - private Map<Integer, List<BatchReport.Test>> tests = new HashMap<>(); - private Map<Integer, List<BatchReport.CoverageDetail>> coverageDetails = new HashMap<>(); + private Map<Integer, List<ScannerReport.Test>> tests = new HashMap<>(); + private Map<Integer, List<ScannerReport.CoverageDetail>> coverageDetails = new HashMap<>(); @Override public Statement apply(final Statement statement, Description description) { @@ -83,14 +83,14 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { } @Override - public BatchReport.Metadata readMetadata() { + public ScannerReport.Metadata readMetadata() { if (metadata == null) { throw new IllegalStateException("Metadata is missing"); } return metadata; } - public BatchReportReaderRule setMetadata(BatchReport.Metadata metadata) { + public BatchReportReaderRule setMetadata(ScannerReport.Metadata metadata) { this.metadata = metadata; return this; } @@ -109,85 +109,85 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { } @Override - public CloseableIterator<BatchReport.ActiveRule> readActiveRules() { + public CloseableIterator<ScannerReport.ActiveRule> readActiveRules() { if (activeRules == null) { throw new IllegalStateException("Active rules are not set"); } return CloseableIterator.from(activeRules.iterator()); } - public BatchReportReaderRule putActiveRules(List<BatchReport.ActiveRule> activeRules) { + public BatchReportReaderRule putActiveRules(List<ScannerReport.ActiveRule> activeRules) { this.activeRules = activeRules; return this; } @Override - public CloseableIterator<BatchReport.Measure> readComponentMeasures(int componentRef) { - List<BatchReport.Measure> res = this.measures.get(componentRef); + public CloseableIterator<ScannerReport.Measure> readComponentMeasures(int componentRef) { + List<ScannerReport.Measure> res = this.measures.get(componentRef); if (res == null) { return CloseableIterator.emptyCloseableIterator(); } return CloseableIterator.from(res.iterator()); } - public BatchReportReaderRule putMeasures(int componentRef, List<BatchReport.Measure> measures) { + public BatchReportReaderRule putMeasures(int componentRef, List<ScannerReport.Measure> measures) { this.measures.put(componentRef, measures); return this; } @Override @CheckForNull - public BatchReport.Changesets readChangesets(int componentRef) { + public ScannerReport.Changesets readChangesets(int componentRef) { return changesets.get(componentRef); } - public BatchReportReaderRule putChangesets(BatchReport.Changesets changesets) { + public BatchReportReaderRule putChangesets(ScannerReport.Changesets changesets) { this.changesets.put(changesets.getComponentRef(), changesets); return this; } @Override - public BatchReport.Component readComponent(int componentRef) { + public ScannerReport.Component readComponent(int componentRef) { return components.get(componentRef); } - public BatchReportReaderRule putComponent(BatchReport.Component component) { + public BatchReportReaderRule putComponent(ScannerReport.Component component) { this.components.put(component.getRef(), component); return this; } @Override - public CloseableIterator<BatchReport.Issue> readComponentIssues(int componentRef) { + public CloseableIterator<ScannerReport.Issue> readComponentIssues(int componentRef) { return closeableIterator(issues.get(componentRef)); } - public BatchReportReaderRule putIssues(int componentRef, List<BatchReport.Issue> issue) { + public BatchReportReaderRule putIssues(int componentRef, List<ScannerReport.Issue> issue) { this.issues.put(componentRef, issue); return this; } @Override - public CloseableIterator<BatchReport.Duplication> readComponentDuplications(int componentRef) { + public CloseableIterator<ScannerReport.Duplication> readComponentDuplications(int componentRef) { return closeableIterator(this.duplications.get(componentRef)); } - public BatchReportReaderRule putDuplications(int componentRef, BatchReport.Duplication... duplications) { + public BatchReportReaderRule putDuplications(int componentRef, ScannerReport.Duplication... duplications) { this.duplications.put(componentRef, Arrays.asList(duplications)); return this; } @Override - public CloseableIterator<BatchReport.CpdTextBlock> readCpdTextBlocks(int componentRef) { + public CloseableIterator<ScannerReport.CpdTextBlock> readCpdTextBlocks(int componentRef) { return closeableIterator(this.duplicationBlocks.get(componentRef)); } - public BatchReportReaderRule putDuplicationBlocks(int componentRef, List<BatchReport.CpdTextBlock> duplicationBlocks) { + public BatchReportReaderRule putDuplicationBlocks(int componentRef, List<ScannerReport.CpdTextBlock> duplicationBlocks) { this.duplicationBlocks.put(componentRef, duplicationBlocks); return this; } @Override - public CloseableIterator<BatchReport.Symbol> readComponentSymbols(int componentRef) { + public CloseableIterator<ScannerReport.Symbol> readComponentSymbols(int componentRef) { return closeableIterator(this.symbols.get(componentRef)); } @@ -195,14 +195,14 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { return list == null ? CloseableIterator.<T>emptyCloseableIterator() : CloseableIterator.from(list.iterator()); } - public BatchReportReaderRule putSymbols(int componentRef, List<BatchReport.Symbol> symbols) { + public BatchReportReaderRule putSymbols(int componentRef, List<ScannerReport.Symbol> symbols) { this.symbols.put(componentRef, symbols); return this; } @Override - public CloseableIterator<BatchReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef) { - List<BatchReport.SyntaxHighlighting> res = this.syntaxHighlightings.get(fileRef); + public CloseableIterator<ScannerReport.SyntaxHighlighting> readComponentSyntaxHighlighting(int fileRef) { + List<ScannerReport.SyntaxHighlighting> res = this.syntaxHighlightings.get(fileRef); if (res == null) { return CloseableIterator.emptyCloseableIterator(); } @@ -210,14 +210,14 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { return CloseableIterator.from(res.iterator()); } - public BatchReportReaderRule putSyntaxHighlighting(int fileRef, List<BatchReport.SyntaxHighlighting> syntaxHighlightings) { + public BatchReportReaderRule putSyntaxHighlighting(int fileRef, List<ScannerReport.SyntaxHighlighting> syntaxHighlightings) { this.syntaxHighlightings.put(fileRef, syntaxHighlightings); return this; } @Override - public CloseableIterator<BatchReport.Coverage> readComponentCoverage(int fileRef) { - List<BatchReport.Coverage> res = this.coverages.get(fileRef); + public CloseableIterator<ScannerReport.Coverage> readComponentCoverage(int fileRef) { + List<ScannerReport.Coverage> res = this.coverages.get(fileRef); if (res == null) { return CloseableIterator.emptyCloseableIterator(); } @@ -225,7 +225,7 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { return CloseableIterator.from(res.iterator()); } - public BatchReportReaderRule putCoverage(int fileRef, List<BatchReport.Coverage> coverages) { + public BatchReportReaderRule putCoverage(int fileRef, List<ScannerReport.Coverage> coverages) { this.coverages.put(fileRef, coverages); return this; } @@ -252,8 +252,8 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { } @Override - public CloseableIterator<BatchReport.Test> readTests(int testFileRef) { - List<BatchReport.Test> res = this.tests.get(testFileRef); + public CloseableIterator<ScannerReport.Test> readTests(int testFileRef) { + List<ScannerReport.Test> res = this.tests.get(testFileRef); if (res == null) { return CloseableIterator.emptyCloseableIterator(); } @@ -261,14 +261,14 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { return CloseableIterator.from(res.iterator()); } - public BatchReportReaderRule putTests(int testFileRed, List<BatchReport.Test> tests) { + public BatchReportReaderRule putTests(int testFileRed, List<ScannerReport.Test> tests) { this.tests.put(testFileRed, tests); return this; } @Override - public CloseableIterator<BatchReport.CoverageDetail> readCoverageDetails(int testFileRef) { - List<BatchReport.CoverageDetail> res = this.coverageDetails.get(testFileRef); + public CloseableIterator<ScannerReport.CoverageDetail> readCoverageDetails(int testFileRef) { + List<ScannerReport.CoverageDetail> res = this.coverageDetails.get(testFileRef); if (res == null) { return CloseableIterator.emptyCloseableIterator(); } @@ -276,7 +276,7 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { return CloseableIterator.from(res.iterator()); } - public BatchReportReaderRule putCoverageDetails(int testFileRef, List<BatchReport.CoverageDetail> coverageDetails) { + public BatchReportReaderRule putCoverageDetails(int testFileRef, List<ScannerReport.CoverageDetail> coverageDetails) { this.coverageDetails.put(testFileRef, coverageDetails); return this; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/component/ComponentImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/component/ComponentImplTest.java index 541dceafb98..1427bfb3c9b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/component/ComponentImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/component/ComponentImplTest.java @@ -22,7 +22,7 @@ package org.sonar.server.computation.component; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import static com.google.common.base.Predicates.equalTo; import static com.google.common.base.Predicates.not; @@ -30,8 +30,8 @@ import static com.google.common.collect.FluentIterable.from; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.sonar.batch.protocol.Constants.ComponentType; -import static org.sonar.batch.protocol.Constants.ComponentType.FILE; +import static org.sonar.scanner.protocol.Constants.ComponentType; +import static org.sonar.scanner.protocol.Constants.ComponentType.FILE; import static org.sonar.server.computation.component.ComponentImpl.builder; public class ComponentImplTest { @@ -44,7 +44,7 @@ public class ComponentImplTest { @Test public void verify_key_and_uuid() throws Exception { - ComponentImpl component = builder(BatchReport.Component.newBuilder().build()).setKey(KEY).setUuid(UUID).build(); + ComponentImpl component = builder(ScannerReport.Component.newBuilder().build()).setKey(KEY).setUuid(UUID).build(); assertThat(component.getKey()).isEqualTo(KEY); assertThat(component.getUuid()).isEqualTo(UUID); @@ -61,48 +61,48 @@ public class ComponentImplTest { public void set_key_throws_NPE_if_component_arg_is_Null() { thrown.expect(NullPointerException.class); - builder(BatchReport.Component.newBuilder().build()).setUuid(null); + builder(ScannerReport.Component.newBuilder().build()).setUuid(null); } @Test public void set_uuid_throws_NPE_if_component_arg_is_Null() { thrown.expect(NullPointerException.class); - builder(BatchReport.Component.newBuilder().build()).setKey(null); + builder(ScannerReport.Component.newBuilder().build()).setKey(null); } @Test public void build_without_key_throws_NPE_if_component_arg_is_Null() { thrown.expect(NullPointerException.class); - builder(BatchReport.Component.newBuilder().build()).setUuid("ABCD").build(); + builder(ScannerReport.Component.newBuilder().build()).setUuid("ABCD").build(); } @Test public void build_without_uuid_throws_NPE_if_component_arg_is_Null() { thrown.expect(NullPointerException.class); - builder(BatchReport.Component.newBuilder().build()).setKey(KEY).build(); + builder(ScannerReport.Component.newBuilder().build()).setKey(KEY).build(); } @Test public void get_name_from_batch_component() { String name = "project"; - ComponentImpl component = buildSimpleComponent(BatchReport.Component.newBuilder().setName(name).build()); + ComponentImpl component = buildSimpleComponent(ScannerReport.Component.newBuilder().setName(name).build()); assertThat(component.getName()).isEqualTo(name); } @Test public void get_version_from_batch_component() { String version = "1.0"; - ComponentImpl component = buildSimpleComponent(BatchReport.Component.newBuilder().setVersion(version).build()); + ComponentImpl component = buildSimpleComponent(ScannerReport.Component.newBuilder().setVersion(version).build()); assertThat(component.getReportAttributes().getVersion()).isEqualTo(version); } @Test public void getFileAttributes_throws_ISE_if_BatchComponent_does_not_have_type_FILE() { for (ComponentType componentType : from(asList(ComponentType.values())).filter(not(equalTo(FILE)))) { - ComponentImpl component = buildSimpleComponent(BatchReport.Component.newBuilder().setType(componentType).build()); + ComponentImpl component = buildSimpleComponent(ScannerReport.Component.newBuilder().setType(componentType).build()); try { component.getFileAttributes(); fail("A IllegalStateException should have been raised"); @@ -114,7 +114,7 @@ public class ComponentImplTest { @Test public void isUnitTest_returns_true_if_IsTest_is_set_in_BatchComponent() { - ComponentImpl component = buildSimpleComponent(BatchReport.Component.newBuilder().setType(FILE).setIsTest(true).build()); + ComponentImpl component = buildSimpleComponent(ScannerReport.Component.newBuilder().setType(FILE).setIsTest(true).build()); assertThat(component.getFileAttributes().isUnitTest()).isTrue(); } @@ -122,20 +122,20 @@ public class ComponentImplTest { @Test public void isUnitTest_returns_value_of_language_of_BatchComponent() { String languageKey = "some language key"; - ComponentImpl component = buildSimpleComponent(BatchReport.Component.newBuilder().setType(FILE).setLanguage(languageKey).build()); + ComponentImpl component = buildSimpleComponent(ScannerReport.Component.newBuilder().setType(FILE).setLanguage(languageKey).build()); assertThat(component.getFileAttributes().getLanguageKey()).isEqualTo(languageKey); } @Test public void build_with_child() throws Exception { - buildSimpleComponent(BatchReport.Component.newBuilder().build()); + buildSimpleComponent(ScannerReport.Component.newBuilder().build()); - ComponentImpl child = builder(BatchReport.Component.newBuilder().setType(FILE).build()) + ComponentImpl child = builder(ScannerReport.Component.newBuilder().setType(FILE).build()) .setKey("CHILD_KEY") .setUuid("CHILD_UUID") .build(); - ComponentImpl componentImpl = builder(BatchReport.Component.newBuilder().build()) + ComponentImpl componentImpl = builder(ScannerReport.Component.newBuilder().build()) .setKey(KEY) .setUuid(UUID) .addChildren(child) @@ -155,13 +155,13 @@ public class ComponentImplTest { } } - private static ComponentImpl buildSimpleComponent(BatchReport.Component reportComponent) { + private static ComponentImpl buildSimpleComponent(ScannerReport.Component reportComponent) { return builder(reportComponent).setKey(KEY).setUuid(UUID).build(); } @Test public void equals_compares_on_uuid_only() { - ComponentImpl.Builder builder = builder(BatchReport.Component.newBuilder().build()).setUuid(UUID); + ComponentImpl.Builder builder = builder(ScannerReport.Component.newBuilder().build()).setUuid(UUID); assertThat(builder.setKey("1").build()).isEqualTo(builder.setKey("1").build()); assertThat(builder.setKey("1").build()).isEqualTo(builder.setKey("2").build()); @@ -169,7 +169,7 @@ public class ComponentImplTest { @Test public void hashCode_is_hashcode_of_uuid() { - ComponentImpl.Builder builder = builder(BatchReport.Component.newBuilder().build()).setUuid(UUID); + ComponentImpl.Builder builder = builder(ScannerReport.Component.newBuilder().build()).setUuid(UUID); assertThat(builder.setKey("1").build().hashCode()).isEqualTo(builder.setKey("1").build().hashCode()); assertThat(builder.setKey("1").build().hashCode()).isEqualTo(builder.setKey("2").build().hashCode()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IntegrateIssuesVisitorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IntegrateIssuesVisitorTest.java index eb02da08aa7..83b89c79d96 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IntegrateIssuesVisitorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/IntegrateIssuesVisitorTest.java @@ -30,8 +30,6 @@ import org.sonar.api.issue.Issue; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.tracking.Tracker; import org.sonar.db.DbTester; @@ -40,6 +38,8 @@ import org.sonar.db.component.ComponentTesting; import org.sonar.db.issue.IssueDto; import org.sonar.db.rule.RuleDto; import org.sonar.db.rule.RuleTesting; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -126,7 +126,7 @@ public class IntegrateIssuesVisitorTest { public void process_new_issue() throws Exception { componentsWithUnprocessedIssues.setUuids(Collections.<String>emptySet()); - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository("xoo") .setRuleKey("S001") @@ -156,7 +156,7 @@ public class IntegrateIssuesVisitorTest { addBaseIssue(ruleKey); // Issue from report has severity blocker - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository(ruleKey.repository()) .setRuleKey(ruleKey.rule()) @@ -205,7 +205,7 @@ public class IntegrateIssuesVisitorTest { @Test public void execute_issue_visitors() throws Exception { componentsWithUnprocessedIssues.setUuids(Collections.<String>emptySet()); - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository("xoo") .setRuleKey("S001") @@ -244,7 +244,7 @@ public class IntegrateIssuesVisitorTest { public void feed_component_issues_repo() throws Exception { componentsWithUnprocessedIssues.setUuids(Collections.<String>emptySet()); - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository("xoo") .setRuleKey("S001") @@ -262,7 +262,7 @@ public class IntegrateIssuesVisitorTest { public void empty_component_issues_repo_when_no_issue() throws Exception { componentsWithUnprocessedIssues.setUuids(Collections.<String>emptySet()); - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository("xoo") .setRuleKey("S001") diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java index c2d2baab706..fc43b2639cf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/issue/TrackerRawInputFactoryTest.java @@ -26,10 +26,10 @@ import org.junit.Test; import org.sonar.api.issue.Issue; import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.tracking.Input; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -87,7 +87,7 @@ public class TrackerRawInputFactoryTest { @Test public void load_issues() throws Exception { fileSourceRepository.addLines(FILE_REF, "line 1;", "line 2;"); - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setLine(2) .setMsg("the message") .setRuleRepository("java") @@ -119,7 +119,7 @@ public class TrackerRawInputFactoryTest { @Test public void ignore_report_issues_on_common_rules() throws Exception { fileSourceRepository.addLines(FILE_REF, "line 1;", "line 2;"); - BatchReport.Issue reportIssue = BatchReport.Issue.newBuilder() + ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository(CommonRuleKeys.commonRepositoryForLang("java")) .setRuleKey("S001") diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java index d8bd68eda8e..ddc18d8c558 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchMeasureToMeasureTest.java @@ -24,7 +24,7 @@ import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; import org.junit.Test; import org.junit.runner.RunWith; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.metric.Metric; import org.sonar.server.computation.metric.MetricImpl; @@ -41,7 +41,7 @@ public class BatchMeasureToMeasureTest { private static final Metric SOME_LEVEL_METRIC = new MetricImpl(42, "level", "name", Metric.MetricType.LEVEL); private static final String SOME_DATA = "some_data man!"; - private static final BatchReport.Measure EMPTY_BATCH_MEASURE = BatchReport.Measure.newBuilder().build(); + private static final ScannerReport.Measure EMPTY_BATCH_MEASURE = ScannerReport.Measure.newBuilder().build(); private BatchMeasureToMeasure underTest = new BatchMeasureToMeasure(); @@ -70,7 +70,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_returns_no_value_if_dto_has_invalid_string_value_for_LEVEL_Metric() { - Optional<Measure> measure = underTest.toMeasure(BatchReport.Measure.newBuilder().setStringValue("trololo").build(), SOME_LEVEL_METRIC); + Optional<Measure> measure = underTest.toMeasure(ScannerReport.Measure.newBuilder().setStringValue("trololo").build(), SOME_LEVEL_METRIC); assertThat(measure).isPresent(); assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.NO_VALUE); @@ -78,7 +78,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_returns_no_value_if_dto_has_value_in_wrong_case_for_LEVEL_Metric() { - Optional<Measure> measure = underTest.toMeasure(BatchReport.Measure.newBuilder().setStringValue("waRn").build(), SOME_LEVEL_METRIC); + Optional<Measure> measure = underTest.toMeasure(ScannerReport.Measure.newBuilder().setStringValue("waRn").build(), SOME_LEVEL_METRIC); assertThat(measure).isPresent(); assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.NO_VALUE); @@ -92,7 +92,7 @@ public class BatchMeasureToMeasureTest { } private void verify_toMeasure_returns_value_for_LEVEL_Metric(Measure.Level expectedQualityGateStatus) { - Optional<Measure> measure = underTest.toMeasure(BatchReport.Measure.newBuilder().setStringValue(expectedQualityGateStatus.name()).build(), SOME_LEVEL_METRIC); + Optional<Measure> measure = underTest.toMeasure(ScannerReport.Measure.newBuilder().setStringValue(expectedQualityGateStatus.name()).build(), SOME_LEVEL_METRIC); assertThat(measure).isPresent(); assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.LEVEL); assertThat(measure.get().getLevelValue()).isEqualTo(expectedQualityGateStatus); @@ -100,7 +100,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_for_LEVEL_Metric_maps_QualityGateStatus() { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setStringValue(Measure.Level.OK.name()) .build(); @@ -119,7 +119,7 @@ public class BatchMeasureToMeasureTest { } private void verify_toMeasure_for_LEVEL_Metric_parses_level_from_data(Measure.Level expectedLevel) { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setStringValue(expectedLevel.name()) .build(); @@ -139,7 +139,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_maps_data_and_alert_properties_in_dto_for_Int_Metric() { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setIntValue(10) .setStringValue(SOME_DATA) .build(); @@ -162,7 +162,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_returns_long_part_of_value_in_dto_for_Long_Metric() { - Optional<Measure> measure = underTest.toMeasure(BatchReport.Measure.newBuilder().setLongValue(15l).build(), SOME_LONG_METRIC); + Optional<Measure> measure = underTest.toMeasure(ScannerReport.Measure.newBuilder().setLongValue(15l).build(), SOME_LONG_METRIC); assertThat(measure.isPresent()).isTrue(); assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.LONG); @@ -171,7 +171,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_maps_data_and_alert_properties_in_dto_for_Long_Metric() { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setLongValue(10l) .setStringValue(SOME_DATA) .build(); @@ -194,7 +194,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_maps_data_and_alert_properties_in_dto_for_Double_Metric() { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setDoubleValue(10.6395d) .setStringValue(SOME_DATA) .build(); @@ -222,7 +222,7 @@ public class BatchMeasureToMeasureTest { } private void verify_toMeasure_returns_false_value_if_dto_has_invalid_value_for_Boolean_metric(boolean expected) { - Optional<Measure> measure = underTest.toMeasure(BatchReport.Measure.newBuilder().setBooleanValue(expected).build(), SOME_BOOLEAN_METRIC); + Optional<Measure> measure = underTest.toMeasure(ScannerReport.Measure.newBuilder().setBooleanValue(expected).build(), SOME_BOOLEAN_METRIC); assertThat(measure.isPresent()).isTrue(); assertThat(measure.get().getValueType()).isEqualTo(Measure.ValueType.BOOLEAN); @@ -231,7 +231,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_maps_data_and_alert_properties_in_dto_for_Boolean_metric() { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setBooleanValue(true).setStringValue(SOME_DATA).build(); Optional<Measure> measure = underTest.toMeasure(batchMeasure, SOME_BOOLEAN_METRIC); @@ -252,7 +252,7 @@ public class BatchMeasureToMeasureTest { @Test public void toMeasure_maps_alert_properties_in_dto_for_String_Metric() { - BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + ScannerReport.Measure batchMeasure = ScannerReport.Measure.newBuilder() .setStringValue(SOME_DATA) .build(); @@ -267,12 +267,12 @@ public class BatchMeasureToMeasureTest { @DataProvider public static Object[][] all_types_batch_measure_builders() { return new Object[][] { - {BatchReport.Measure.newBuilder().setBooleanValue(true), SOME_BOOLEAN_METRIC}, - {BatchReport.Measure.newBuilder().setIntValue(1), SOME_INT_METRIC}, - {BatchReport.Measure.newBuilder().setLongValue(1), SOME_LONG_METRIC}, - {BatchReport.Measure.newBuilder().setDoubleValue(1), SOME_DOUBLE_METRIC}, - {BatchReport.Measure.newBuilder().setStringValue("1"), SOME_STRING_METRIC}, - {BatchReport.Measure.newBuilder().setStringValue(Measure.Level.OK.name()), SOME_LEVEL_METRIC} + {ScannerReport.Measure.newBuilder().setBooleanValue(true), SOME_BOOLEAN_METRIC}, + {ScannerReport.Measure.newBuilder().setIntValue(1), SOME_INT_METRIC}, + {ScannerReport.Measure.newBuilder().setLongValue(1), SOME_LONG_METRIC}, + {ScannerReport.Measure.newBuilder().setDoubleValue(1), SOME_DOUBLE_METRIC}, + {ScannerReport.Measure.newBuilder().setStringValue("1"), SOME_STRING_METRIC}, + {ScannerReport.Measure.newBuilder().setStringValue(Measure.Level.OK.name()), SOME_LEVEL_METRIC} }; } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java index 5db038fccc2..060cee163be 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryImplTest.java @@ -37,12 +37,12 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.measure.MeasureDto; import org.sonar.db.rule.RuleDto; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.component.Component; @@ -354,7 +354,7 @@ public class MeasureRepositoryImplTest { when(reportMetricValidator.validate(METRIC_KEY_1)).thenReturn(true); reportReader.putMeasures(FILE_COMPONENT.getReportAttributes().getRef(), ImmutableList.of( - BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue(value).build() + ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue(value).build() )); Optional<Measure> res = underTest.getRawMeasure(FILE_COMPONENT, metric1); @@ -373,8 +373,8 @@ public class MeasureRepositoryImplTest { when(reportMetricValidator.validate(METRIC_KEY_2)).thenReturn(false); reportReader.putMeasures(FILE_COMPONENT.getReportAttributes().getRef(), ImmutableList.of( - BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("value1").build(), - BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_2).setStringValue("value2").build() + ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("value1").build(), + ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_2).setStringValue("value2").build() )); assertThat(underTest.getRawMeasure(FILE_COMPONENT, metric1)).isPresent(); @@ -385,7 +385,7 @@ public class MeasureRepositoryImplTest { public void getRawMeasure_retrieves_added_measure_over_batch_measure() { when(reportMetricValidator.validate(METRIC_KEY_1)).thenReturn(true); reportReader.putMeasures(FILE_COMPONENT.getReportAttributes().getRef(), ImmutableList.of( - BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("some value").build() + ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("some value").build() )); Measure addedMeasure = SOME_MEASURE; @@ -401,7 +401,7 @@ public class MeasureRepositoryImplTest { public void getRawMeasure_retrieves_measure_from_batch_and_caches_it_locally_so_that_it_can_be_updated() { when(reportMetricValidator.validate(METRIC_KEY_1)).thenReturn(true); reportReader.putMeasures(FILE_COMPONENT.getReportAttributes().getRef(), ImmutableList.of( - BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("some value").build() + ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("some value").build() )); Optional<Measure> measure = underTest.getRawMeasure(FILE_COMPONENT, metric1); @@ -441,8 +441,8 @@ public class MeasureRepositoryImplTest { public void getRawMeasures_returns_added_measures_over_batch_measures() { when(reportMetricValidator.validate(METRIC_KEY_1)).thenReturn(true); when(reportMetricValidator.validate(METRIC_KEY_2)).thenReturn(true); - BatchReport.Measure batchMeasure1 = BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("some value").build(); - BatchReport.Measure batchMeasure2 = BatchReport.Measure.newBuilder().setMetricKey(METRIC_KEY_2).setStringValue("some value").build(); + ScannerReport.Measure batchMeasure1 = ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_1).setStringValue("some value").build(); + ScannerReport.Measure batchMeasure2 = ScannerReport.Measure.newBuilder().setMetricKey(METRIC_KEY_2).setStringValue("some value").build(); reportReader.putMeasures(FILE_COMPONENT.getReportAttributes().getRef(), ImmutableList.of(batchMeasure1, batchMeasure2)); Measure addedMeasure = SOME_MEASURE; diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ReportScmInfoTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ReportScmInfoTest.java index a36d84c386b..f08358ee138 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ReportScmInfoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ReportScmInfoTest.java @@ -22,7 +22,7 @@ package org.sonar.server.computation.scm; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import static org.assertj.core.api.Assertions.assertThat; @@ -35,14 +35,14 @@ public class ReportScmInfoTest { @Test public void create_scm_info_with_some_changesets() throws Exception { - ScmInfo scmInfo = new ReportScmInfo(BatchReport.Changesets.newBuilder() + ScmInfo scmInfo = new ReportScmInfo(ScannerReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") .build()) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("henry") .setDate(1234567810L) .setRevision("rev-2") @@ -58,14 +58,14 @@ public class ReportScmInfoTest { @Test public void return_changeset_for_a_given_line() throws Exception { - ScmInfo scmInfo = new ReportScmInfo(BatchReport.Changesets.newBuilder() + ScmInfo scmInfo = new ReportScmInfo(ScannerReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") .build()) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("henry") .setDate(1234567810L) .setRevision("rev-2") @@ -86,15 +86,15 @@ public class ReportScmInfoTest { @Test public void return_latest_changeset() throws Exception { - ScmInfo scmInfo = new ReportScmInfo(BatchReport.Changesets.newBuilder() + ScmInfo scmInfo = new ReportScmInfo(ScannerReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setDate(123456789L) .setRevision("rev-1") .build()) // Older changeset - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("henry") .setDate(1234567810L) .setRevision("rev-2") @@ -114,7 +114,7 @@ public class ReportScmInfoTest { public void fail_with_ISE_when_no_changeset() throws Exception { thrown.expect(IllegalStateException.class); - new ReportScmInfo(BatchReport.Changesets.newBuilder().build()); + new ReportScmInfo(ScannerReport.Changesets.newBuilder().build()); } @Test @@ -129,9 +129,9 @@ public class ReportScmInfoTest { thrown.expect(IllegalStateException.class); thrown.expectMessage("Changeset on line 1 must have a revision"); - new ReportScmInfo(BatchReport.Changesets.newBuilder() + new ReportScmInfo(ScannerReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setDate(123456789L) .build()) @@ -144,9 +144,9 @@ public class ReportScmInfoTest { thrown.expect(IllegalStateException.class); thrown.expectMessage("Changeset on line 1 must have a date"); - new ReportScmInfo(BatchReport.Changesets.newBuilder() + new ReportScmInfo(ScannerReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor("john") .setRevision("rev-1") .build()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java index e756e694da4..6a2f1f4d564 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/scm/ScmInfoRepositoryImplTest.java @@ -33,12 +33,12 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.LogTester; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.hash.SourceHashComputer; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.source.FileSourceDto; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.AnalysisMetadataHolder; import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.batch.BatchReportReader; @@ -234,9 +234,9 @@ public class ScmInfoRepositoryImplTest { } private void addChangesetInReport(String author, Long date, String revision) { - reportReader.putChangesets(BatchReport.Changesets.newBuilder() + reportReader.putChangesets(ScannerReport.Changesets.newBuilder() .setComponentRef(FILE_REF) - .addChangeset(BatchReport.Changesets.Changeset.newBuilder() + .addChangeset(ScannerReport.Changesets.Changeset.newBuilder() .setAuthor(author) .setDate(date) .setRevision(revision) @@ -247,7 +247,7 @@ public class ScmInfoRepositoryImplTest { private void addFileSourceInReport(int lineCount) { reportReader.putFileSourceLines(FILE_REF, generateLines(lineCount)); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(FILE_REF) .setLines(lineCount) .build()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/CoverageLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/CoverageLineReaderTest.java index 44052a83024..247105f8004 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/CoverageLineReaderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/CoverageLineReaderTest.java @@ -21,8 +21,8 @@ package org.sonar.server.computation.source; import java.util.Collections; import org.junit.Test; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.protobuf.DbFileSources; +import org.sonar.scanner.protocol.output.ScannerReport; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; @@ -31,7 +31,7 @@ public class CoverageLineReaderTest { @Test public void set_coverage() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(BatchReport.Coverage.newBuilder() + CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .setConditions(10) .setUtHits(true) @@ -55,7 +55,7 @@ public class CoverageLineReaderTest { @Test public void set_coverage_on_uncovered_lines() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(BatchReport.Coverage.newBuilder() + CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .setUtHits(false) .setItHits(false) @@ -74,7 +74,7 @@ public class CoverageLineReaderTest { @Test public void set_coverage_without_line_hits() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(BatchReport.Coverage.newBuilder() + CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .build()).iterator()); @@ -88,7 +88,7 @@ public class CoverageLineReaderTest { @Test public void set_overall_line_hits_with_only_ut() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(BatchReport.Coverage.newBuilder() + CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .setUtHits(true) .setItHits(false) @@ -102,7 +102,7 @@ public class CoverageLineReaderTest { @Test public void set_overall_line_hits_with_only_it() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(BatchReport.Coverage.newBuilder() + CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .setUtHits(false) .setItHits(true) @@ -116,7 +116,7 @@ public class CoverageLineReaderTest { @Test public void set_overall_line_hits_with_ut_and_it() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(BatchReport.Coverage.newBuilder() + CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .setUtHits(true) .setItHits(true) @@ -130,7 +130,7 @@ public class CoverageLineReaderTest { @Test public void nothing_to_do_when_no_coverage_info() { - CoverageLineReader computeCoverageLine = new CoverageLineReader(Collections.<BatchReport.Coverage>emptyList().iterator()); + CoverageLineReader computeCoverageLine = new CoverageLineReader(Collections.<ScannerReport.Coverage>emptyList().iterator()); DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1); computeCoverageLine.read(lineBuilder); @@ -147,7 +147,7 @@ public class CoverageLineReaderTest { @Test public void nothing_to_do_when_no_coverage_info_for_current_line() { CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList( - BatchReport.Coverage.newBuilder() + ScannerReport.Coverage.newBuilder() .setLine(1) .setConditions(10) .setUtHits(true) @@ -174,7 +174,7 @@ public class CoverageLineReaderTest { @Test public void nothing_to_do_when_no_coverage_info_for_next_line() { CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList( - BatchReport.Coverage.newBuilder() + ScannerReport.Coverage.newBuilder() .setLine(1) .setConditions(10) .setUtHits(true) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/HighlightingLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/HighlightingLineReaderTest.java index 1ead6a6e873..dea1dd7d97b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/HighlightingLineReaderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/HighlightingLineReaderTest.java @@ -27,10 +27,10 @@ import java.util.Random; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.log.LogTester; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReport.TextRange; import org.sonar.db.protobuf.DbFileSources; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.scanner.protocol.output.ScannerReport.TextRange; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.source.RangeOffsetConverter.RangeOffsetConverterException; @@ -40,11 +40,11 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.api.utils.log.LoggerLevel.WARN; -import static org.sonar.batch.protocol.Constants.HighlightingType.ANNOTATION; -import static org.sonar.batch.protocol.Constants.HighlightingType.COMMENT; -import static org.sonar.batch.protocol.Constants.HighlightingType.CONSTANT; -import static org.sonar.batch.protocol.Constants.HighlightingType.HIGHLIGHTING_STRING; import static org.sonar.db.protobuf.DbFileSources.Data.newBuilder; +import static org.sonar.scanner.protocol.Constants.HighlightingType.ANNOTATION; +import static org.sonar.scanner.protocol.Constants.HighlightingType.COMMENT; +import static org.sonar.scanner.protocol.Constants.HighlightingType.CONSTANT; +import static org.sonar.scanner.protocol.Constants.HighlightingType.HIGHLIGHTING_STRING; import static org.sonar.server.computation.component.ReportComponent.builder; public class HighlightingLineReaderTest { @@ -242,9 +242,9 @@ public class HighlightingLineReaderTest { } private HighlightingLineReader newReader(Map<TextRange, Constants.HighlightingType> textRangeByType) { - List<BatchReport.SyntaxHighlighting> syntaxHighlightingList = new ArrayList<>(); + List<ScannerReport.SyntaxHighlighting> syntaxHighlightingList = new ArrayList<>(); for (Map.Entry<TextRange, Constants.HighlightingType> entry : textRangeByType.entrySet()) { - syntaxHighlightingList.add(BatchReport.SyntaxHighlighting.newBuilder() + syntaxHighlightingList.add(ScannerReport.SyntaxHighlighting.newBuilder() .setRange(entry.getKey()) .setType(entry.getValue()) .build()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/RangeOffsetConverterTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/RangeOffsetConverterTest.java index 71291ca70d1..77d10666b27 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/RangeOffsetConverterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/RangeOffsetConverterTest.java @@ -22,7 +22,7 @@ package org.sonar.server.computation.source; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.source.RangeOffsetConverter.RangeOffsetConverterException; import static org.assertj.core.api.Assertions.assertThat; @@ -115,8 +115,8 @@ public class RangeOffsetConverterTest { LINE_1, DEFAULT_LINE_LENGTH); } - private static BatchReport.TextRange createTextRange(int startLine, int enLine, int startOffset, int endOffset) { - return BatchReport.TextRange.newBuilder() + private static ScannerReport.TextRange createTextRange(int startLine, int enLine, int startOffset, int endOffset) { + return ScannerReport.TextRange.newBuilder() .setStartLine(startLine).setEndLine(enLine) .setStartOffset(startOffset).setEndOffset(endOffset) .build(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java index 3c658b6e4d7..33422d738bf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/ReportIteratorTest.java @@ -24,10 +24,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReportWriter; -import org.sonar.batch.protocol.output.FileStructure; - +import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.scanner.protocol.output.ScannerReportWriter; +import org.sonar.scanner.protocol.output.FileStructure; import java.io.File; import java.util.NoSuchElementException; @@ -41,15 +40,15 @@ public class ReportIteratorTest { File file; - ReportIterator<BatchReport.Coverage> underTest; + ReportIterator<ScannerReport.Coverage> underTest; @Before public void setUp() throws Exception { File dir = temp.newFolder(); - BatchReportWriter writer = new BatchReportWriter(dir); + ScannerReportWriter writer = new ScannerReportWriter(dir); writer.writeComponentCoverage(1, newArrayList( - BatchReport.Coverage.newBuilder() + ScannerReport.Coverage.newBuilder() .setLine(1) .build() )); @@ -66,13 +65,13 @@ public class ReportIteratorTest { @Test public void read_report() { - underTest = new ReportIterator<>(file, BatchReport.Coverage.PARSER); + underTest = new ReportIterator<>(file, ScannerReport.Coverage.PARSER); assertThat(underTest.next().getLine()).isEqualTo(1); } @Test public void do_not_fail_when_calling_has_next_with_iterator_already_closed() { - underTest = new ReportIterator<>(file, BatchReport.Coverage.PARSER); + underTest = new ReportIterator<>(file, ScannerReport.Coverage.PARSER); assertThat(underTest.next().getLine()).isEqualTo(1); assertThat(underTest.hasNext()).isFalse(); @@ -82,7 +81,7 @@ public class ReportIteratorTest { @Test(expected = NoSuchElementException.class) public void test_error() throws Exception { - underTest = new ReportIterator<>(file, BatchReport.Coverage.PARSER); + underTest = new ReportIterator<>(file, ScannerReport.Coverage.PARSER); underTest.next(); // fail ! diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/SourceLinesRepositoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/SourceLinesRepositoryImplTest.java index 5a49562ce7f..dcf600f0a24 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/SourceLinesRepositoryImplTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/SourceLinesRepositoryImplTest.java @@ -22,8 +22,8 @@ package org.sonar.server.computation.source; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.util.CloseableIterator; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.component.Component; @@ -121,8 +121,8 @@ public class SourceLinesRepositoryImplTest { underTest.readLines(builder(Component.Type.PROJECT, 123).setKey("NotFile").build()); } - private static BatchReport.Component createFileBatchComponent(int lineCount) { - return BatchReport.Component.newBuilder().setRef(FILE_REF).setLines(lineCount).build(); + private static ScannerReport.Component createFileBatchComponent(int lineCount) { + return ScannerReport.Component.newBuilder().setRef(FILE_REF).setLines(lineCount).build(); } private static void consume(CloseableIterator<String> stringCloseableIterator) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java index 3adf5b4eaab..023db6eb798 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/source/SymbolsLineReaderTest.java @@ -23,9 +23,9 @@ import java.util.Arrays; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.log.LogTester; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReport.TextRange; import org.sonar.db.protobuf.DbFileSources; +import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.scanner.protocol.output.ScannerReport.TextRange; import org.sonar.server.computation.component.Component; import static org.assertj.core.api.Assertions.assertThat; @@ -299,8 +299,8 @@ public class SymbolsLineReaderTest { assertThat(logTester.logs(WARN)).containsOnly("Inconsistency detected in Symbols data. Symbols will be ignored for file 'FILE_KEY'"); } - private BatchReport.Symbol newSymbol(TextRange declaration, TextRange... references) { - BatchReport.Symbol.Builder builder = BatchReport.Symbol.newBuilder() + private ScannerReport.Symbol newSymbol(TextRange declaration, TextRange... references) { + ScannerReport.Symbol.Builder builder = ScannerReport.Symbol.newBuilder() .setDeclaration(declaration); for (TextRange reference : references) { builder.addReference(reference); @@ -308,7 +308,7 @@ public class SymbolsLineReaderTest { return builder.build(); } - private SymbolsLineReader newReader(BatchReport.Symbol... symbols) { + private SymbolsLineReader newReader(ScannerReport.Symbol... symbols) { return new SymbolsLineReader(FILE, Arrays.asList(symbols).iterator(), rangeOffsetConverter); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java index f4493dc1213..e58395b5c96 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/BuildComponentTreeStepTest.java @@ -29,12 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl; import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolder; import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolderRule; @@ -43,15 +43,15 @@ import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.MutableTreeRootHolderRule; import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.batch.protocol.Constants.ComponentType.DIRECTORY; -import static org.sonar.batch.protocol.Constants.ComponentType.FILE; -import static org.sonar.batch.protocol.Constants.ComponentType.MODULE; -import static org.sonar.batch.protocol.Constants.ComponentType.PROJECT; import static org.sonar.db.component.ComponentTesting.newDirectory; import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newModuleDto; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.SnapshotTesting.newSnapshotForProject; +import static org.sonar.scanner.protocol.Constants.ComponentType.DIRECTORY; +import static org.sonar.scanner.protocol.Constants.ComponentType.FILE; +import static org.sonar.scanner.protocol.Constants.ComponentType.MODULE; +import static org.sonar.scanner.protocol.Constants.ComponentType.PROJECT; @RunWith(DataProviderRunner.class) @@ -316,20 +316,20 @@ public class BuildComponentTreeStepTest { } } - private static BatchReport.Component component(int componentRef, Constants.ComponentType componentType, int... children) { + private static ScannerReport.Component component(int componentRef, Constants.ComponentType componentType, int... children) { return component(componentRef, componentType, null, null, children); } - private static BatchReport.Component componentWithKey(int componentRef, Constants.ComponentType componentType, String key, int... children) { + private static ScannerReport.Component componentWithKey(int componentRef, Constants.ComponentType componentType, String key, int... children) { return component(componentRef, componentType, key, null, children); } - private static BatchReport.Component componentWithPath(int componentRef, Constants.ComponentType componentType, String path, int... children) { + private static ScannerReport.Component componentWithPath(int componentRef, Constants.ComponentType componentType, String path, int... children) { return component(componentRef, componentType, null, path, children); } - private static BatchReport.Component component(int componentRef, Constants.ComponentType componentType, @Nullable String key, @Nullable String path, int... children) { - BatchReport.Component.Builder builder = BatchReport.Component.newBuilder() + private static ScannerReport.Component component(int componentRef, Constants.ComponentType componentType, @Nullable String key, @Nullable String path, int... children) { + ScannerReport.Component.Builder builder = ScannerReport.Component.newBuilder() .setType(componentType) .setRef(componentRef); if (key != null) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java index 4e5b98aa6e0..356e33c0b5a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadCrossProjectDuplicationsRepositoryStepTest.java @@ -27,7 +27,6 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.ArgumentCaptor; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -38,6 +37,7 @@ import org.sonar.db.component.SnapshotTesting; import org.sonar.db.duplication.DuplicationUnitDto; import org.sonar.duplications.block.Block; import org.sonar.duplications.block.ByteArray; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; @@ -134,7 +134,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { dbClient.duplicationDao().insert(dbSession, duplicate); dbSession.commit(); - BatchReport.CpdTextBlock originBlock = BatchReport.CpdTextBlock.newBuilder() + ScannerReport.CpdTextBlock originBlock = ScannerReport.CpdTextBlock.newBuilder() .setHash(hash) .setStartLine(30) .setEndLine(45) @@ -177,14 +177,14 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { ComponentDto otherFIle = createFile("OTHER_FILE_KEY", otherProject); SnapshotDto otherFileSnapshot = createFileSnapshot(otherFIle, otherProjectSnapshot); - BatchReport.CpdTextBlock originBlock1 = BatchReport.CpdTextBlock.newBuilder() + ScannerReport.CpdTextBlock originBlock1 = ScannerReport.CpdTextBlock.newBuilder() .setHash("a8998353e96320ec") .setStartLine(30) .setEndLine(45) .setStartTokenIndex(0) .setEndTokenIndex(10) .build(); - BatchReport.CpdTextBlock originBlock2 = BatchReport.CpdTextBlock.newBuilder() + ScannerReport.CpdTextBlock originBlock2 = ScannerReport.CpdTextBlock.newBuilder() .setHash("b1234353e96320ff") .setStartLine(10) .setEndLine(25) @@ -281,7 +281,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { dbClient.duplicationDao().insert(dbSession, duplicate); dbSession.commit(); - BatchReport.CpdTextBlock originBlock = BatchReport.CpdTextBlock.newBuilder() + ScannerReport.CpdTextBlock originBlock = ScannerReport.CpdTextBlock.newBuilder() .setHash(hash) .setStartLine(30) .setEndLine(45) @@ -300,7 +300,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true); analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot); - batchReportReader.putDuplicationBlocks(FILE_REF, Collections.<BatchReport.CpdTextBlock>emptyList()); + batchReportReader.putDuplicationBlocks(FILE_REF, Collections.<ScannerReport.CpdTextBlock>emptyList()); underTest.execute(); @@ -312,7 +312,7 @@ public class LoadCrossProjectDuplicationsRepositoryStepTest { when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true); analysisMetadataHolder.setBaseProjectSnapshot(baseProjectSnapshot); - BatchReport.CpdTextBlock originBlock = BatchReport.CpdTextBlock.newBuilder() + ScannerReport.CpdTextBlock originBlock = ScannerReport.CpdTextBlock.newBuilder() .setHash("a8998353e96320ec") .setStartLine(30) .setEndLine(45) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStepTest.java index 774c3ea0883..6f6f787340c 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadDuplicationsFromReportStepTest.java @@ -23,7 +23,7 @@ import java.util.Arrays; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -200,30 +200,30 @@ public class LoadDuplicationsFromReportStepTest { return new DetailedTextBlock(id, line, line); } - private static BatchReport.Duplication createDuplication(BatchReport.TextRange original, BatchReport.Duplicate... duplicates) { - BatchReport.Duplication.Builder builder = BatchReport.Duplication.newBuilder() + private static ScannerReport.Duplication createDuplication(ScannerReport.TextRange original, ScannerReport.Duplicate... duplicates) { + ScannerReport.Duplication.Builder builder = ScannerReport.Duplication.newBuilder() .setOriginPosition(original); - for (BatchReport.Duplicate duplicate : duplicates) { + for (ScannerReport.Duplicate duplicate : duplicates) { builder.addDuplicate(duplicate); } return builder.build(); } - private static BatchReport.Duplicate createInnerDuplicate(int line) { - return BatchReport.Duplicate.newBuilder() + private static ScannerReport.Duplicate createInnerDuplicate(int line) { + return ScannerReport.Duplicate.newBuilder() .setRange(singleLineTextRange(line)) .build(); } - private static BatchReport.Duplicate createInProjectDuplicate(int componentRef, int line) { - return BatchReport.Duplicate.newBuilder() + private static ScannerReport.Duplicate createInProjectDuplicate(int componentRef, int line) { + return ScannerReport.Duplicate.newBuilder() .setOtherFileRef(componentRef) .setRange(singleLineTextRange(line)) .build(); } - private static BatchReport.TextRange singleLineTextRange(int line) { - return BatchReport.TextRange.newBuilder() + private static ScannerReport.TextRange singleLineTextRange(int line) { + return ScannerReport.TextRange.newBuilder() .setStartLine(line) .setEndLine(line) .build(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadQualityProfilesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadQualityProfilesStepTest.java index 1504b808f18..415867e6294 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadQualityProfilesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadQualityProfilesStepTest.java @@ -25,8 +25,8 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.issue.DumbRule; import org.sonar.server.computation.issue.RuleRepositoryRule; @@ -54,12 +54,12 @@ public class LoadQualityProfilesStepTest { ruleRepository.add(XOO_X1); ruleRepository.add(XOO_X2); - BatchReport.ActiveRule.Builder batch1 = BatchReport.ActiveRule.newBuilder() + ScannerReport.ActiveRule.Builder batch1 = ScannerReport.ActiveRule.newBuilder() .setRuleRepository(XOO_X1.repository()).setRuleKey(XOO_X1.rule()) .setSeverity(Constants.Severity.BLOCKER); batch1.addParamBuilder().setKey("p1").setValue("v1").build(); - BatchReport.ActiveRule.Builder batch2 = BatchReport.ActiveRule.newBuilder() + ScannerReport.ActiveRule.Builder batch2 = ScannerReport.ActiveRule.newBuilder() .setRuleRepository(XOO_X2.repository()).setRuleKey(XOO_X2.rule()).setSeverity(Constants.Severity.MAJOR); batchReportReader.putActiveRules(asList(batch1.build(), batch2.build())); @@ -80,7 +80,7 @@ public class LoadQualityProfilesStepTest { public void ignore_rules_with_status_REMOVED() throws Exception { ruleRepository.add(new DumbRule(XOO_X1).setStatus(RuleStatus.REMOVED)); - BatchReport.ActiveRule.Builder batch1 = BatchReport.ActiveRule.newBuilder() + ScannerReport.ActiveRule.Builder batch1 = ScannerReport.ActiveRule.newBuilder() .setRuleRepository(XOO_X1.repository()).setRuleKey(XOO_X1.rule()) .setSeverity(Constants.Severity.BLOCKER); batchReportReader.putActiveRules(asList(batch1.build())); @@ -92,7 +92,7 @@ public class LoadQualityProfilesStepTest { @Test public void ignore_not_found_rules() throws Exception { - BatchReport.ActiveRule.Builder batch1 = BatchReport.ActiveRule.newBuilder() + ScannerReport.ActiveRule.Builder batch1 = ScannerReport.ActiveRule.newBuilder() .setRuleRepository(XOO_X1.repository()).setRuleKey(XOO_X1.rule()) .setSeverity(Constants.Severity.BLOCKER); batchReportReader.putActiveRules(asList(batch1.build())); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStepTest.java index 2ae20cd8289..c1bab1e0875 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/LoadReportAnalysisMetadataHolderStepTest.java @@ -23,7 +23,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.utils.MessageException; -import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.MutableAnalysisMetadataHolderRule; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.queue.CeTask; @@ -138,7 +138,7 @@ public class LoadReportAnalysisMetadataHolderStepTest { public void execute_fails_with_MessageException_if_projectKey_is_null_in_CE_task() { CeTask res = mock(CeTask.class); when(res.getComponentUuid()).thenReturn("prj_uuid"); - reportReader.setMetadata(BatchReport.Metadata.newBuilder().build()); + reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build()); ComputationStep underTest = new LoadReportAnalysisMetadataHolderStep(res, reportReader, analysisMetadataHolder); @@ -151,7 +151,7 @@ public class LoadReportAnalysisMetadataHolderStepTest { @Test public void execute_fails_with_MessageException_when_projectKey_in_report_is_different_from_componentKey_in_CE_task() { reportReader.setMetadata( - BatchReport.Metadata.newBuilder() + ScannerReport.Metadata.newBuilder() .setProjectKey("some other key") .build()); @@ -161,8 +161,8 @@ public class LoadReportAnalysisMetadataHolderStepTest { underTest.execute(); } - private static BatchReport.Metadata.Builder newBatchReportBuilder() { - return BatchReport.Metadata.newBuilder() + private static ScannerReport.Metadata.Builder newBatchReportBuilder() { + return ScannerReport.Metadata.newBuilder() .setProjectKey(PROJECT_KEY); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStepTest.java index 4439b6516f1..cfee41ef09a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistCrossProjectDuplicationIndexStepTest.java @@ -28,9 +28,9 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbTester; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -54,7 +54,7 @@ public class PersistCrossProjectDuplicationIndexStepTest { .build(); static final long PROJECT_SNAPSHOT_ID = 10L; - static final BatchReport.CpdTextBlock CPD_TEXT_BLOCK = BatchReport.CpdTextBlock.newBuilder() + static final ScannerReport.CpdTextBlock CPD_TEXT_BLOCK = ScannerReport.CpdTextBlock.newBuilder() .setHash("a8998353e96320ec") .setStartLine(30) .setEndLine(45) @@ -105,7 +105,7 @@ public class PersistCrossProjectDuplicationIndexStepTest { when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true); reportReader.putDuplicationBlocks(FILE_REF, Arrays.asList( CPD_TEXT_BLOCK, - BatchReport.CpdTextBlock.newBuilder() + ScannerReport.CpdTextBlock.newBuilder() .setHash("b1234353e96320ff") .setStartLine(20) .setEndLine(15) @@ -126,7 +126,7 @@ public class PersistCrossProjectDuplicationIndexStepTest { @Test public void nothing_to_persist_when_no_cpd_text_blocks_in_report() throws Exception { when(crossProjectDuplicationStatusHolder.isEnabled()).thenReturn(true); - reportReader.putDuplicationBlocks(FILE_REF, Collections.<BatchReport.CpdTextBlock>emptyList()); + reportReader.putDuplicationBlocks(FILE_REF, Collections.<ScannerReport.CpdTextBlock>emptyList()); underTest.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java index f17ed019831..63b515b4a44 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java @@ -25,14 +25,14 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.source.FileSourceDto; import org.sonar.db.source.FileSourceDto.Type; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -135,7 +135,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public void persist_coverage() { initBasicReport(1); - reportReader.putCoverage(FILE_REF, newArrayList(BatchReport.Coverage.newBuilder() + reportReader.putCoverage(FILE_REF, newArrayList(ScannerReport.Coverage.newBuilder() .setLine(1) .setConditions(10) .setUtHits(true) @@ -193,8 +193,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest { public void persist_highlighting() { initBasicReport(1); - reportReader.putSyntaxHighlighting(FILE_REF, newArrayList(BatchReport.SyntaxHighlighting.newBuilder() - .setRange(BatchReport.TextRange.newBuilder() + reportReader.putSyntaxHighlighting(FILE_REF, newArrayList(ScannerReport.SyntaxHighlighting.newBuilder() + .setRange(ScannerReport.TextRange.newBuilder() .setStartLine(1).setEndLine(1) .setStartOffset(2).setEndOffset(4) .build()) @@ -217,11 +217,11 @@ public class PersistFileSourcesStepTest extends BaseStepTest { initBasicReport(3); reportReader.putSymbols(FILE_REF, newArrayList( - BatchReport.Symbol.newBuilder() - .setDeclaration(BatchReport.TextRange.newBuilder() + ScannerReport.Symbol.newBuilder() + .setDeclaration(ScannerReport.TextRange.newBuilder() .setStartLine(1).setEndLine(1).setStartOffset(2).setEndOffset(4) .build()) - .addReference(BatchReport.TextRange.newBuilder() + .addReference(ScannerReport.TextRange.newBuilder() .setStartLine(3).setEndLine(3).setStartOffset(1).setEndOffset(3) .build()) .build())); @@ -439,17 +439,17 @@ public class PersistFileSourcesStepTest extends BaseStepTest { .build()) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .addChildRef(2) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) .addChildRef(FILE_REF) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(FILE_REF) .setType(Constants.ComponentType.FILE) .build()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java index d7b8e88fdc3..4266a76e38d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistIssuesStepTest.java @@ -29,7 +29,6 @@ import org.sonar.api.rule.RuleKey; import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.DefaultIssueComment; import org.sonar.core.issue.FieldDiffs; @@ -41,6 +40,7 @@ import org.sonar.db.component.ComponentTesting; import org.sonar.db.issue.IssueDto; import org.sonar.db.rule.RuleDto; import org.sonar.db.rule.RuleTesting; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.issue.IssueCache; import org.sonar.server.computation.issue.RuleRepositoryImpl; @@ -84,7 +84,7 @@ public class PersistIssuesStepTest extends BaseStepTest { issueCache = new IssueCache(temp.newFile(), System2.INSTANCE); system2 = mock(System2.class); when(system2.now()).thenReturn(NOW); - reportReader.setMetadata(BatchReport.Metadata.getDefaultInstance()); + reportReader.setMetadata(ScannerReport.Metadata.getDefaultInstance()); step = new PersistIssuesStep(dbClient, system2, new UpdateConflictResolver(), new RuleRepositoryImpl(dbClient), issueCache); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistProjectLinksStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistProjectLinksStepTest.java index 35e973fc5ca..0f7e9671905 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistProjectLinksStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistProjectLinksStepTest.java @@ -25,9 +25,9 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.i18n.I18n; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbTester; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -79,20 +79,20 @@ public class PersistProjectLinksStepTest extends BaseStepTest { .build()); // project and 1 module - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .addChildRef(2) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.SCM).setHref("https://github.com/SonarSource/sonar").build()) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.SCM_DEV).setHref("scm:git:git@github.com:SonarSource/sonar.git/sonar").build()) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.ISSUE).setHref("http://jira.sonarsource.com/").build()) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.CI).setHref("http://bamboo.ci.codehaus.org/browse/SONAR").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.SCM).setHref("https://github.com/SonarSource/sonar").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.SCM_DEV).setHref("scm:git:git@github.com:SonarSource/sonar.git/sonar").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.ISSUE).setHref("http://jira.sonarsource.com/").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.CI).setHref("http://bamboo.ci.codehaus.org/browse/SONAR").build()) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.SCM).setHref("https://github.com/SonarSource/sonar/server").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.SCM).setHref("https://github.com/SonarSource/sonar/server").build()) .build()); step.execute(); @@ -106,10 +106,10 @@ public class PersistProjectLinksStepTest extends BaseStepTest { treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) .build()); step.execute(); @@ -125,15 +125,15 @@ public class PersistProjectLinksStepTest extends BaseStepTest { ReportComponent.builder(Component.Type.FILE, 2).setUuid("BCDE").build()) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .addChildRef(2) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.FILE) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) .build()); step.execute(); @@ -147,10 +147,10 @@ public class PersistProjectLinksStepTest extends BaseStepTest { treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) .build()); step.execute(); @@ -164,7 +164,7 @@ public class PersistProjectLinksStepTest extends BaseStepTest { treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .build()); @@ -180,7 +180,7 @@ public class PersistProjectLinksStepTest extends BaseStepTest { treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .build()); @@ -196,11 +196,11 @@ public class PersistProjectLinksStepTest extends BaseStepTest { treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) - .addLink(BatchReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) + .addLink(ScannerReport.ComponentLink.newBuilder().setType(Constants.ComponentLinkType.HOME).setHref("http://www.sonarqube.org").build()) .build()); try { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java index d74f5c955b8..b84689867f5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistTestsStepTest.java @@ -27,13 +27,13 @@ import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; -import org.sonar.batch.protocol.output.BatchReport.CoverageDetail; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.protobuf.DbFileSources; import org.sonar.db.source.FileSourceDto; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; +import org.sonar.scanner.protocol.output.ScannerReport.CoverageDetail; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; @@ -110,7 +110,7 @@ public class PersistTestsStepTest extends BaseStepTest { @Test public void insert_several_tests_in_a_report() { - List<BatchReport.Test> batchTests = Arrays.asList( + List<ScannerReport.Test> batchTests = Arrays.asList( newTest(1), newTest(2)); reportReader.putTests(TEST_FILE_REF_1, batchTests); List<CoverageDetail> coverageDetails = Arrays.asList( @@ -163,7 +163,7 @@ public class PersistTestsStepTest extends BaseStepTest { @Test public void insert_tests_without_coverage_details() { - List<BatchReport.Test> batchTests = Arrays.asList(newTest(1)); + List<ScannerReport.Test> batchTests = Arrays.asList(newTest(1)); reportReader.putTests(TEST_FILE_REF_1, batchTests); underTest.execute(); @@ -178,7 +178,7 @@ public class PersistTestsStepTest extends BaseStepTest { @Test public void insert_coverage_details_not_taken_into_account() { - List<BatchReport.Test> batchTests = Arrays.asList(newTest(1)); + List<ScannerReport.Test> batchTests = Arrays.asList(newTest(1)); reportReader.putTests(TEST_FILE_REF_1, batchTests); List<CoverageDetail> coverageDetails = Arrays.asList(newCoverageDetail(1, MAIN_FILE_REF_1), newCoverageDetail(2, MAIN_FILE_REF_2)); reportReader.putCoverageDetails(TEST_FILE_REF_1, coverageDetails); @@ -227,7 +227,7 @@ public class PersistTestsStepTest extends BaseStepTest { db.getSession().commit(); assertThat(dbClient.fileSourceDao().selectTest(TEST_FILE_UUID_1)).isNotNull(); - BatchReport.Test newBatchTest = newTest(1); + ScannerReport.Test newBatchTest = newTest(1); reportReader.putTests(TEST_FILE_REF_1, Arrays.asList(newBatchTest)); CoverageDetail newCoverageDetail = newCoverageDetail(1, MAIN_FILE_REF_1); @@ -254,8 +254,8 @@ public class PersistTestsStepTest extends BaseStepTest { assertThat(test.getCoveredFile(0).getFileUuid()).isEqualTo(MAIN_FILE_UUID_1); } - private BatchReport.Test newTest(int id) { - return BatchReport.Test.newBuilder() + private ScannerReport.Test newTest(int id) { + return ScannerReport.Test.newBuilder() .setStatus(Constants.TestStatus.FAILURE) .setName("name#" + id) .setStacktrace("stacktrace#" + id) @@ -264,11 +264,11 @@ public class PersistTestsStepTest extends BaseStepTest { .build(); } - private BatchReport.CoverageDetail newCoverageDetail(int id, int covered_file_ref) { + private ScannerReport.CoverageDetail newCoverageDetail(int id, int covered_file_ref) { return newCoverageDetailWithLines(id, covered_file_ref, 1, 2, 3); } - private BatchReport.CoverageDetail newCoverageDetailWithLines(int id, int covered_file_ref, Integer... lines) { + private ScannerReport.CoverageDetail newCoverageDetailWithLines(int id, int covered_file_ref, Integer... lines) { return CoverageDetail.newBuilder() .setTestName("name#" + id) .addCoveredFile(CoverageDetail.CoveredFile.newBuilder() diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java index 840096b6794..61f1a0265b2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ValidateProjectStepTest.java @@ -27,13 +27,13 @@ import org.junit.rules.ExpectedException; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.MessageException; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.db.component.SnapshotTesting; +import org.sonar.scanner.protocol.Constants; +import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.server.computation.analysis.AnalysisMetadataHolderRule; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; @@ -77,7 +77,7 @@ public class ValidateProjectStepTest { @Test public void not_fail_on_valid_branch() { analysisMetadataHolder.setBranch(DEFAULT_BRANCH); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) @@ -94,7 +94,7 @@ public class ValidateProjectStepTest { " o \"bran#ch\" is not a valid branch name. Allowed characters are alphanumeric, '-', '_', '.' and '/'."); analysisMetadataHolder.setBranch("bran#ch"); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) @@ -113,13 +113,13 @@ public class ValidateProjectStepTest { " o \"Project\\Key\" is not a valid project or module key. Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.\n" + " o \"Module$Key\" is not a valid project or module key. Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit"); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(invalidProjectKey) .addChildRef(2) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) .setKey("Module$Key") @@ -139,13 +139,13 @@ public class ValidateProjectStepTest { "If you really want to stop directly analysing project \"" + MODULE_KEY + "\", please first delete it from SonarQube and then relaunch the analysis of project \"" + PROJECT_KEY + "\"."); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) .addChildRef(2) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) .setKey(MODULE_KEY) @@ -169,13 +169,13 @@ public class ValidateProjectStepTest { thrown.expectMessage("Validation of project failed:\n" + " o Module \"" + MODULE_KEY + "\" is already part of project \"" + anotherProjectKey + "\""); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) .addChildRef(2) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) .setKey(MODULE_KEY) @@ -204,13 +204,13 @@ public class ValidateProjectStepTest { "If you really want to stop directly analysing project \"" + anotherProjectKey + "\", please first delete it from SonarQube and then relaunch the analysis of project \"" + PROJECT_KEY + "\"."); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) .addChildRef(2) .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) .setKey(MODULE_KEY) @@ -231,7 +231,7 @@ public class ValidateProjectStepTest { @Test public void not_fail_if_analysis_date_is_after_last_analysis() { - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) @@ -257,7 +257,7 @@ public class ValidateProjectStepTest { analysisMetadataHolder.setAnalysisDate(DateUtils.parseDate("2015-01-01")); - reportReader.putComponent(BatchReport.Component.newBuilder() + reportReader.putComponent(ScannerReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) .setKey(PROJECT_KEY) |