From 8beb0aa8ad8e191f532ea3ada6941708ba844af6 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 8 Jun 2015 15:43:53 +0200 Subject: [PATCH] SONAR-6260 Remove snapshot id from batch report --- .../step/PersistDuplicationsStep.java | 7 +- .../computation/step/PersistEventsStep.java | 26 +- .../computation/step/PersistMeasuresStep.java | 7 +- ...ersistNumberOfDaysSinceLastCommitStep.java | 14 +- .../computation/step/SwitchSnapshotStep.java | 15 +- .../computation/step/FeedPeriodsStepTest.java | 3 +- .../step/PersistDuplicationsStepTest.java | 126 +---- .../step/PersistEventsStepTest.java | 25 +- .../step/PersistMeasuresStepTest.java | 21 +- ...stNumberOfDaysSinceLastCommitStepTest.java | 36 +- .../step/PersistSnapshotsStepTest.java | 34 +- .../step/SwitchSnapshotStepTest.java | 18 +- .../batch/protocol/output/BatchReport.java | 449 +++++------------- .../src/main/protobuf/batch_report.proto | 8 +- .../batch/report/ComponentsPublisher.java | 4 - .../sonar/batch/report/IssuesPublisher.java | 4 - .../batch/report/IssuesPublisherTest.java | 2 - 17 files changed, 249 insertions(+), 550 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java index f635806afd1..1baae898213 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistDuplicationsStep.java @@ -86,18 +86,17 @@ public class PersistDuplicationsStep implements ComputationStep { private void visitComponent(Component component) { List duplications = reportReader.readComponentDuplications(component.getRef()); if (!duplications.isEmpty()) { - BatchReport.Component batchComponent = reportReader.readComponent(component.getRef()); - saveDuplications(batchComponent, component, duplications); + saveDuplications( component, duplications); } } - private void saveDuplications(BatchReport.Component batchComponent, Component component, List duplications) { + private void saveDuplications(Component component, List duplications) { String duplicationXml = createXmlDuplications(component.getKey(), duplications); MeasureDto measureDto = new MeasureDto() .setMetricId(duplicationMetric.getId()) .setData(duplicationXml) .setComponentId(dbIdsRepository.getComponentId(component)) - .setSnapshotId(batchComponent.getSnapshotId()); + .setSnapshotId(dbIdsRepository.getSnapshotId(component)); dbClient.measureDao().insert(session, measureDto); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java index 5088b6139ae..642343fc6d2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistEventsStep.java @@ -29,6 +29,7 @@ import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.DbIdsRepository; import org.sonar.server.computation.component.DepthTraversalTypeAwareVisitor; import org.sonar.server.computation.component.TreeRootHolder; import org.sonar.server.computation.event.Event; @@ -44,14 +45,16 @@ public class PersistEventsStep implements ComputationStep { private final BatchReportReader reportReader; private final TreeRootHolder treeRootHolder; private final EventRepository eventRepository; + private final DbIdsRepository dbIdsRepository; public PersistEventsStep(DbClient dbClient, System2 system2, TreeRootHolder treeRootHolder, BatchReportReader reportReader, - EventRepository eventRepository) { + EventRepository eventRepository, DbIdsRepository dbIdsRepository) { this.dbClient = dbClient; this.system2 = system2; this.treeRootHolder = treeRootHolder; this.reportReader = reportReader; this.eventRepository = eventRepository; + this.dbIdsRepository = dbIdsRepository; } @Override @@ -68,15 +71,15 @@ public class PersistEventsStep implements ComputationStep { private void processComponent(Component component, DbSession session, long analysisDate) { BatchReport.Component batchComponent = reportReader.readComponent(component.getRef()); - processEvents(session, batchComponent, component, analysisDate); + processEvents(session, component, analysisDate); saveVersionEvent(session, batchComponent, component, analysisDate); } - private void processEvents(DbSession session, final BatchReport.Component batchComponent, final Component component, final Long analysisDate) { + private void processEvents(DbSession session, final Component component, final Long analysisDate) { Function eventToEventDto = new Function() { @Override public EventDto apply(@Nonnull Event event) { - return newBaseEvent(batchComponent, component, analysisDate) + return newBaseEvent(component, analysisDate) .setName(event.getName()) .setCategory(convertCategory(event.getCategory())) .setDescription(event.getDescription()) @@ -91,26 +94,27 @@ public class PersistEventsStep implements ComputationStep { private void saveVersionEvent(DbSession session, BatchReport.Component batchComponent, Component component, Long analysisDate) { if (batchComponent.hasVersion()) { - deletePreviousEventsHavingSameVersion(session, batchComponent, component); - dbClient.eventDao().insert(session, newBaseEvent(batchComponent, component, analysisDate) - .setName(batchComponent.getVersion()) + String version = batchComponent.getVersion(); + deletePreviousEventsHavingSameVersion(session, version, component); + dbClient.eventDao().insert(session, newBaseEvent(component, analysisDate) + .setName(version) .setCategory(EventDto.CATEGORY_VERSION) ); } } - private void deletePreviousEventsHavingSameVersion(DbSession session, BatchReport.Component batchComponent, Component component) { + private void deletePreviousEventsHavingSameVersion(DbSession session, String version, Component component) { for (EventDto dto : dbClient.eventDao().selectByComponentUuid(session, component.getUuid())) { - if (dto.getCategory().equals(EventDto.CATEGORY_VERSION) && dto.getName().equals(batchComponent.getVersion())) { + if (dto.getCategory().equals(EventDto.CATEGORY_VERSION) && dto.getName().equals(version)) { dbClient.eventDao().delete(session, dto.getId()); } } } - private EventDto newBaseEvent(BatchReport.Component batchComponent, Component component, Long analysisDate) { + private EventDto newBaseEvent(Component component, Long analysisDate) { return new EventDto() .setComponentUuid(component.getUuid()) - .setSnapshotId(batchComponent.getSnapshotId()) + .setSnapshotId(dbIdsRepository.getSnapshotId(component)) .setCreatedAt(system2.now()) .setDate(analysisDate); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java index 44a20d7a9fe..b28e1559c52 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java @@ -54,8 +54,8 @@ public class PersistMeasuresStep implements ComputationStep { private final TreeRootHolder treeRootHolder; private final BatchReportReader reportReader; - public PersistMeasuresStep(DbClient dbClient, RuleCache ruleCache, MetricCache metricCache, - DbIdsRepository dbIdsRepository, TreeRootHolder treeRootHolder, BatchReportReader reportReader) { + public PersistMeasuresStep(DbClient dbClient, RuleCache ruleCache, MetricCache metricCache, DbIdsRepository dbIdsRepository, TreeRootHolder treeRootHolder, + BatchReportReader reportReader) { this.dbClient = dbClient; this.ruleCache = ruleCache; this.metricCache = metricCache; @@ -92,9 +92,8 @@ public class PersistMeasuresStep implements ComputationStep { @Override protected void visitAny(Component component) { int componentRef = component.getRef(); - BatchReport.Component batchComponent = reportReader.readComponent(componentRef); List measures = reportReader.readComponentMeasures(componentRef); - persistMeasures(measures, dbIdsRepository.getComponentId(component), batchComponent.getSnapshotId()); + persistMeasures(measures, dbIdsRepository.getComponentId(component), dbIdsRepository.getComponentId(component)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java index 74f9bd8258e..bf122a3714c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStep.java @@ -31,6 +31,7 @@ import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.computation.batch.BatchReportReader; import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.DbIdsRepository; import org.sonar.server.computation.component.DepthTraversalTypeAwareVisitor; import org.sonar.server.computation.component.TreeRootHolder; import org.sonar.server.computation.measure.MetricCache; @@ -50,15 +51,17 @@ public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep { private final System2 system; private final TreeRootHolder treeRootHolder; private final BatchReportReader reportReader; + private final DbIdsRepository dbIdsRepository; public PersistNumberOfDaysSinceLastCommitStep(System2 system, DbClient dbClient, SourceLineIndex sourceLineIndex, MetricCache metricCache, - TreeRootHolder treeRootHolder, BatchReportReader reportReader) { + TreeRootHolder treeRootHolder, BatchReportReader reportReader, DbIdsRepository dbIdsRepository) { this.dbClient = dbClient; this.sourceLineIndex = sourceLineIndex; this.metricCache = metricCache; this.system = system; this.treeRootHolder = treeRootHolder; this.reportReader = reportReader; + this.dbIdsRepository = dbIdsRepository; } @Override @@ -69,7 +72,8 @@ public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep { @Override public void execute() { NumberOfDaysSinceLastCommitVisitor visitor = new NumberOfDaysSinceLastCommitVisitor(); - visitor.visit(treeRootHolder.getRoot()); + Component project = treeRootHolder.getRoot(); + visitor.visit(project); long lastCommitTimestamp = visitor.lastCommitTimestampFromReport; if (lastCommitTimestamp == 0L) { @@ -78,7 +82,7 @@ public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep { } if (lastCommitTimestamp != 0L) { - persistNumberOfDaysSinceLastCommit(lastCommitTimestamp); + persistNumberOfDaysSinceLastCommit(lastCommitTimestamp, dbIdsRepository.getSnapshotId(project)); } } @@ -88,14 +92,14 @@ public class PersistNumberOfDaysSinceLastCommitStep implements ComputationStep { return lastCommitDate == null ? null : lastCommitDate.getTime(); } - private void persistNumberOfDaysSinceLastCommit(long lastCommitTimestamp) { + private void persistNumberOfDaysSinceLastCommit(long lastCommitTimestamp, long projectSnapshotId) { long numberOfDaysSinceLastCommit = (system.now() - lastCommitTimestamp) / MILLISECONDS_PER_DAY; DbSession dbSession = dbClient.openSession(true); try { dbClient.measureDao().insert(dbSession, new MeasureDto() .setValue((double) numberOfDaysSinceLastCommit) .setMetricId(metricCache.get(CoreMetrics.DAYS_SINCE_LAST_COMMIT_KEY).getId()) - .setSnapshotId(reportReader.readMetadata().getSnapshotId())); + .setSnapshotId(projectSnapshotId)); dbSession.commit(); } finally { MyBatis.closeQuietly(dbSession); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java index 14060e9cd24..c575dc7a346 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/SwitchSnapshotStep.java @@ -25,7 +25,9 @@ import org.sonar.core.component.SnapshotDto; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.component.db.SnapshotDao; -import org.sonar.server.computation.batch.BatchReportReader; +import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.DbIdsRepository; +import org.sonar.server.computation.component.TreeRootHolder; import org.sonar.server.db.DbClient; import static org.sonar.server.component.db.SnapshotDao.isLast; @@ -33,18 +35,21 @@ import static org.sonar.server.component.db.SnapshotDao.isLast; public class SwitchSnapshotStep implements ComputationStep { private final DbClient dbClient; - private final BatchReportReader reportReader; + private final TreeRootHolder treeRootHolder; + private final DbIdsRepository dbIdsRepository; - public SwitchSnapshotStep(DbClient dbClient, BatchReportReader reportReader) { + public SwitchSnapshotStep(DbClient dbClient, TreeRootHolder treeRootHolder, DbIdsRepository dbIdsRepository) { this.dbClient = dbClient; - this.reportReader = reportReader; + this.treeRootHolder = treeRootHolder; + this.dbIdsRepository = dbIdsRepository; } @Override public void execute() { DbSession session = dbClient.openSession(true); try { - long snapshotId = reportReader.readMetadata().getSnapshotId(); + Component project = treeRootHolder.getRoot(); + long snapshotId = dbIdsRepository.getSnapshotId(project); disablePreviousSnapshot(session, snapshotId); enableCurrentSnapshot(session, snapshotId); } finally { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java index a8ce47afa02..7f4be0fa733 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/FeedPeriodsStepTest.java @@ -100,8 +100,7 @@ public class FeedPeriodsStepTest extends BaseStepTest { .setVersion("1.1") .build()); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY); - treeRootHolder.setRoot(project); + treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build()); sut = new FeedPeriodsStep(dbClient, settings, treeRootHolder, reportReader, periodsHolder); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java index 258456a233b..b5ace55beb3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java @@ -28,7 +28,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.sonar.api.measures.CoreMetrics; -import org.sonar.batch.protocol.Constants; import org.sonar.batch.protocol.output.BatchReport; import org.sonar.batch.protocol.output.BatchReport.Range; import org.sonar.core.metric.db.MetricDto; @@ -137,33 +136,14 @@ public class PersistDuplicationsStepTest extends BaseStepTest { treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, 1); + dbIdsRepository.setSnapshotId(project, 10); dbIdsRepository.setComponentId(module, 3); + dbIdsRepository.setSnapshotId(module, 11); dbIdsRepository.setComponentId(file, 2); + dbIdsRepository.setSnapshotId(file, 12); saveDuplicationMetric(); - // TODO remove this when snapshot id will come from the DbIdsRepo - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(1) - .setType(Constants.ComponentType.PROJECT) - .setKey(PROJECT_KEY) - .setSnapshotId(10L) - .addChildRef(2) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(2) - .setType(Constants.ComponentType.MODULE) - .setKey("MODULE_KEY") - .setSnapshotId(11L) - .addChildRef(3) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(3) - .setType(Constants.ComponentType.FILE) - .setSnapshotId(12L) - .setPath("file") - .build()); - BatchReport.Duplication duplication = BatchReport.Duplication.newBuilder() .setOriginPosition(Range.newBuilder() .setStartLine(1) @@ -196,33 +176,14 @@ public class PersistDuplicationsStepTest extends BaseStepTest { treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, 1); + dbIdsRepository.setSnapshotId(project, 10); dbIdsRepository.setComponentId(directory, 3); + dbIdsRepository.setSnapshotId(directory, 11); dbIdsRepository.setComponentId(file, 2); + dbIdsRepository.setSnapshotId(file, 12); saveDuplicationMetric(); - // TODO remove this when snapshot id will come from the DbIdsRepo - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(1) - .setType(Constants.ComponentType.PROJECT) - .setKey(PROJECT_KEY) - .setSnapshotId(10L) - .addChildRef(2) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(2) - .setType(Constants.ComponentType.DIRECTORY) - .setSnapshotId(11L) - .addChildRef(3) - .setPath("dir") - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(3) - .setType(Constants.ComponentType.FILE) - .setSnapshotId(12L) - .setPath("file") - .build()); - BatchReport.Duplication duplication = BatchReport.Duplication.newBuilder() .setOriginPosition(Range.newBuilder() .setStartLine(1) @@ -256,41 +217,16 @@ public class PersistDuplicationsStepTest extends BaseStepTest { treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, 1); + dbIdsRepository.setSnapshotId(project, 10); dbIdsRepository.setComponentId(directory1, 2); + dbIdsRepository.setSnapshotId(directory1, 11); dbIdsRepository.setComponentId(directory2, 3); + dbIdsRepository.setSnapshotId(directory2, 12); dbIdsRepository.setComponentId(file, 10); + dbIdsRepository.setSnapshotId(file, 20); saveDuplicationMetric(); - // TODO remove this when snapshot id will come from the DbIdsRepo - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(1) - .setType(Constants.ComponentType.PROJECT) - .setKey(PROJECT_KEY) - .setSnapshotId(10L) - .addChildRef(2) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(2) - .setType(Constants.ComponentType.DIRECTORY) - .setSnapshotId(11L) - .addChildRef(3) - .setPath("dir") - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(3) - .setType(Constants.ComponentType.DIRECTORY) - .setSnapshotId(12L) - .addChildRef(10) - .setPath("dir2") - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(10) - .setType(Constants.ComponentType.FILE) - .setSnapshotId(20L) - .setPath("file") - .build()); - BatchReport.Duplication duplication = BatchReport.Duplication.newBuilder() .setOriginPosition(Range.newBuilder() .setStartLine(1) @@ -324,28 +260,11 @@ public class PersistDuplicationsStepTest extends BaseStepTest { treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, 1); + dbIdsRepository.setSnapshotId(project, 10); dbIdsRepository.setComponentId(file, 2); - - // TODO remove this when snapshot id will come from the DbIdsRepo - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(1) - .setType(Constants.ComponentType.PROJECT) - .setKey(PROJECT_KEY) - .setSnapshotId(10L) - .addChildRef(2) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(2) - .setType(Constants.ComponentType.FILE) - .setSnapshotId(11L) - .setPath("file") - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(3) - .setType(Constants.ComponentType.FILE) - .setSnapshotId(12L) - .setPath("file2") - .build()); + dbIdsRepository.setSnapshotId(file, 11); + dbIdsRepository.setComponentId(file2, 2); + dbIdsRepository.setSnapshotId(file2, 12); BatchReport.Duplication duplication = BatchReport.Duplication.newBuilder() .setOriginPosition(Range.newBuilder() @@ -406,22 +325,9 @@ public class PersistDuplicationsStepTest extends BaseStepTest { treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, 1); + dbIdsRepository.setSnapshotId(project, 10); dbIdsRepository.setComponentId(file, 2); - - // TODO remove this when snapshot id will come from the DbIdsRepo - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(1) - .setType(Constants.ComponentType.PROJECT) - .setKey(PROJECT_KEY) - .setSnapshotId(10L) - .addChildRef(2) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(2) - .setType(Constants.ComponentType.FILE) - .setSnapshotId(11L) - .setPath("file") - .build()); + dbIdsRepository.setSnapshotId(file, 11); } private MetricDto saveDuplicationMetric() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistEventsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistEventsStepTest.java index dfb6a949c36..d639a2d23b0 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistEventsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistEventsStepTest.java @@ -36,6 +36,7 @@ import org.sonar.core.persistence.DbTester; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.DbIdsRepository; import org.sonar.server.computation.component.DumbComponent; import org.sonar.server.computation.event.Event; import org.sonar.server.computation.event.EventRepository; @@ -57,6 +58,8 @@ public class PersistEventsStepTest extends BaseStepTest { @Rule public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); + DbIdsRepository dbIdsRepository = new DbIdsRepository(); + DbSession session; EventRepository eventRepository = mock(EventRepository.class); PersistEventsStep step; @@ -69,7 +72,7 @@ public class PersistEventsStepTest extends BaseStepTest { System2 system2 = mock(System2.class); when(system2.now()).thenReturn(1225630680000L); - step = new PersistEventsStep(dbClient, system2, treeRootHolder, reportReader, eventRepository); + step = new PersistEventsStep(dbClient, system2, treeRootHolder, reportReader, eventRepository, dbIdsRepository); when(eventRepository.getEvents(any(Component.class))).thenReturn(Collections.emptyList()); } @@ -109,11 +112,13 @@ public class PersistEventsStepTest extends BaseStepTest { public void persist_report_events_with_component_children() throws Exception { dbTester.prepareDbUnit(getClass(), "empty.xml"); - DumbComponent root = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").addChildren( - DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").build() - ).build(); + DumbComponent module = DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").build(); + DumbComponent root = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").addChildren(module).build(); treeRootHolder.setRoot(root); + dbIdsRepository.setSnapshotId(root, 1000L); + dbIdsRepository.setSnapshotId(module, 1001L); + reportReader.setMetadata(BatchReport.Metadata.newBuilder() .setRootComponentRef(1) .setAnalysisDate(150000000L) @@ -122,14 +127,12 @@ public class PersistEventsStepTest extends BaseStepTest { reportReader.putComponent(BatchReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) - .setSnapshotId(1000L) .addChildRef(2) .build()); reportReader.putComponent(BatchReport.Component.newBuilder() .setRef(2) .setType(Constants.ComponentType.MODULE) - .setSnapshotId(1001L) .build()); Component child = root.getChildren().get(0); @@ -147,7 +150,9 @@ public class PersistEventsStepTest extends BaseStepTest { public void create_version_event() throws Exception { dbTester.prepareDbUnit(getClass(), "empty.xml"); - treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build(); + treeRootHolder.setRoot(project); + dbIdsRepository.setSnapshotId(project, 1000L); reportReader.setMetadata(BatchReport.Metadata.newBuilder() .setRootComponentRef(1) @@ -157,7 +162,6 @@ public class PersistEventsStepTest extends BaseStepTest { reportReader.putComponent(BatchReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) - .setSnapshotId(1000L) .setVersion("1.0") .build()); @@ -170,7 +174,9 @@ public class PersistEventsStepTest extends BaseStepTest { public void keep_one_event_by_version() throws Exception { dbTester.prepareDbUnit(getClass(), "keep_one_event_by_version.xml"); - treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build()); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").build(); + treeRootHolder.setRoot(project); + dbIdsRepository.setSnapshotId(project, 1001L); reportReader.setMetadata(BatchReport.Metadata.newBuilder() .setRootComponentRef(1) @@ -180,7 +186,6 @@ public class PersistEventsStepTest extends BaseStepTest { reportReader.putComponent(BatchReport.Component.newBuilder() .setRef(1) .setType(Constants.ComponentType.PROJECT) - .setSnapshotId(1001L) .setVersion("1.5-SNAPSHOT") .build()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java index 45ae35d92a3..ef400b4a4e6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java @@ -21,7 +21,6 @@ package org.sonar.server.computation.step; import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.Map; import org.junit.After; @@ -123,22 +122,9 @@ public class PersistMeasuresStepTest extends BaseStepTest { treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); + dbIdsRepository.setSnapshotId(project, 3L); dbIdsRepository.setComponentId(file, fileDto.getId()); - - reportReader.setMetadata(BatchReport.Metadata.newBuilder() - .setAnalysisDate(new Date().getTime()) - .setRootComponentRef(1) - .setProjectKey("project-key") - .setSnapshotId(3) - .build()); - - reportReader.putComponent(defaultComponent() - .addChildRef(2) - .build()); - reportReader.putComponent( - defaultComponent() - .setRef(2) - .build()); + dbIdsRepository.setSnapshotId(file, 4L); reportReader.putMeasures(1, Arrays.asList( BatchReport.Measure.newBuilder() @@ -410,8 +396,7 @@ public class PersistMeasuresStepTest extends BaseStepTest { private BatchReport.Component.Builder defaultComponent() { return BatchReport.Component.newBuilder() - .setRef(1) - .setSnapshotId(FILE_SNAPSHOT_ID); + .setRef(1); } private ComponentDto addComponent(int ref, String key) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java index e8641103de4..a7a7e2fc9df 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistNumberOfDaysSinceLastCommitStepTest.java @@ -28,13 +28,13 @@ import org.junit.Test; import org.sonar.api.config.Settings; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.Constants; import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.metric.db.MetricDto; import org.sonar.core.persistence.DbTester; import org.sonar.server.computation.batch.BatchReportReaderRule; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.DbIdsRepository; import org.sonar.server.computation.component.DumbComponent; import org.sonar.server.computation.language.LanguageRepository; import org.sonar.server.computation.measure.MetricCache; @@ -57,6 +57,8 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { @Rule public BatchReportReaderRule reportReader = new BatchReportReaderRule(); + DbIdsRepository dbIdsRepository = new DbIdsRepository(); + PersistNumberOfDaysSinceLastCommitStep sut; DbClient dbClient; @@ -75,7 +77,7 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { languageRepository = mock(LanguageRepository.class); when(metricCache.get(anyString())).thenReturn(new MetricDto().setId(10)); - sut = new PersistNumberOfDaysSinceLastCommitStep(System2.INSTANCE, dbClient, sourceLineIndex, metricCache, treeRootHolder, reportReader); + sut = new PersistNumberOfDaysSinceLastCommitStep(System2.INSTANCE, dbClient, sourceLineIndex, metricCache, treeRootHolder, reportReader, dbIdsRepository); } @Override @@ -86,7 +88,7 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { @Test public void persist_number_of_days_since_last_commit_from_report() { long threeDaysAgo = DateUtils.addDays(new Date(), -3).getTime(); - initReportWithProjectAndFile(); + initProject(); reportReader.putChangesets( BatchReport.Changesets.newBuilder() .setComponentRef(2) @@ -95,7 +97,7 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { .setDate(threeDaysAgo) ) .build() - ); + ); sut.execute(); @@ -106,7 +108,7 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { public void persist_number_of_days_since_last_commit_from_index() { Date sixDaysAgo = DateUtils.addDays(new Date(), -6); when(sourceLineIndex.lastCommitDateOnProject("project-uuid")).thenReturn(sixDaysAgo); - initReportWithProjectAndFile(); + initProject(); sut.execute(); @@ -115,30 +117,18 @@ public class PersistNumberOfDaysSinceLastCommitStepTest extends BaseStepTest { @Test public void no_scm_information_in_report_and_index() { - initReportWithProjectAndFile(); + initProject(); sut.execute(); db.assertDbUnit(getClass(), "empty.xml"); } - private void initReportWithProjectAndFile() { - treeRootHolder.setRoot(DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("project-uuid").addChildren( + private void initProject() { + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("project-uuid").addChildren( DumbComponent.builder(Component.Type.FILE, 2).setUuid("file-uuid").build()) - .build()); - - reportReader.setMetadata(BatchReport.Metadata.newBuilder() - .setSnapshotId(1000) - .build()); - - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(1) - .setType(Constants.ComponentType.PROJECT) - .addChildRef(2) - .build()); - reportReader.putComponent(BatchReport.Component.newBuilder() - .setRef(2) - .setType(Constants.ComponentType.FILE) - .build()); + .build(); + treeRootHolder.setRoot(project); + dbIdsRepository.setSnapshotId(project, 1000); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSnapshotsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSnapshotsStepTest.java index 5384ad62956..87a59cdbb4f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSnapshotsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistSnapshotsStepTest.java @@ -152,10 +152,10 @@ public class PersistSnapshotsStepTest extends BaseStepTest { .setType(Constants.ComponentType.FILE) .build()); - Component file = new DumbComponent(Component.Type.FILE, 4, "DEFG", "MODULE_KEY:src/main/java/dir/Foo.java"); - Component directory = new DumbComponent(Component.Type.DIRECTORY, 3, "CDEF", "MODULE_KEY:src/main/java/dir", file); - Component module = new DumbComponent(Component.Type.MODULE, 2, "BCDE", "MODULE_KEY", directory); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY, module); + Component file = DumbComponent.builder(Component.Type.FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build(); + Component directory = DumbComponent.builder(Component.Type.DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build(); + Component module = DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").addChildren(directory).build(); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(module).build(); treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); @@ -261,9 +261,9 @@ public class PersistSnapshotsStepTest extends BaseStepTest { .setIsTest(true) .build()); - Component file = new DumbComponent(Component.Type.FILE, 3, "DEFG", PROJECT_KEY + ":src/test/java/dir/FooTest.java"); - Component directory = new DumbComponent(Component.Type.DIRECTORY, 2, "CDEF", PROJECT_KEY + ":src/test/java/dir", file); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY, directory); + Component file = DumbComponent.builder(Component.Type.FILE, 3).setUuid("DEFG").setKey(PROJECT_KEY + ":src/main/java/dir/Foo.java").build(); + Component directory = DumbComponent.builder(Component.Type.DIRECTORY, 2).setUuid("CDEF").setKey(PROJECT_KEY + ":src/main/java/dir").addChildren(file).build(); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(directory).build(); treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); @@ -309,10 +309,10 @@ public class PersistSnapshotsStepTest extends BaseStepTest { .setType(Constants.ComponentType.MODULE) .build()); - Component moduleB = new DumbComponent(Component.Type.MODULE, 4, "DEFG", "MODULE_B"); - Component subModuleA = new DumbComponent(Component.Type.MODULE, 3, "CDEF", "SUB_MODULE_A"); - Component moduleA = new DumbComponent(Component.Type.MODULE, 2, "BCDE", "MODULE_A", subModuleA); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY, moduleA, moduleB); + Component moduleB = DumbComponent.builder(Component.Type.MODULE, 4).setUuid("DEFG").setKey("MODULE_B").build(); + Component subModuleA = DumbComponent.builder(Component.Type.MODULE, 3).setUuid("CDEF").setKey("SUB_MODULE_A").build(); + Component moduleA = DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_A").addChildren(subModuleA).build(); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(moduleA, moduleB).build(); treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); @@ -371,7 +371,7 @@ public class PersistSnapshotsStepTest extends BaseStepTest { .addChildRef(2) .build()); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build(); treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); @@ -439,10 +439,10 @@ public class PersistSnapshotsStepTest extends BaseStepTest { .setLanguage("java") .build()); - Component file = new DumbComponent(Component.Type.FILE, 4, "DEFG", "MODULE_KEY:src/main/java/dir/Foo.java"); - Component directory = new DumbComponent(Component.Type.DIRECTORY, 3, "CDEF", "MODULE_KEY:src/main/java/dir", file); - Component module = new DumbComponent(Component.Type.MODULE, 2, "BCDE", "MODULE_KEY", directory); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY, module); + Component file = DumbComponent.builder(Component.Type.FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build(); + Component directory = DumbComponent.builder(Component.Type.DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build(); + Component module = DumbComponent.builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY").addChildren(directory).build(); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(module).build(); treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); @@ -482,7 +482,7 @@ public class PersistSnapshotsStepTest extends BaseStepTest { .addChildRef(2) .build()); - Component project = new DumbComponent(Component.Type.PROJECT, 1, "ABCD", PROJECT_KEY); + Component project = DumbComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build(); treeRootHolder.setRoot(project); dbIdsRepository.setComponentId(project, projectDto.getId()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java index 2f76cc9f8a0..b43e283e108 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/SwitchSnapshotStepTest.java @@ -27,10 +27,12 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; -import org.sonar.batch.protocol.output.BatchReport; import org.sonar.core.persistence.DbTester; import org.sonar.server.component.db.SnapshotDao; -import org.sonar.server.computation.batch.BatchReportReaderRule; +import org.sonar.server.computation.batch.TreeRootHolderRule; +import org.sonar.server.computation.component.Component; +import org.sonar.server.computation.component.DbIdsRepository; +import org.sonar.server.computation.component.DumbComponent; import org.sonar.server.db.DbClient; import org.sonar.test.DbTests; @@ -42,8 +44,11 @@ public class SwitchSnapshotStepTest { @ClassRule public static DbTester db = new DbTester(); + @Rule - public BatchReportReaderRule reportReader = new BatchReportReaderRule(); + public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); + + DbIdsRepository dbIdsRepository = new DbIdsRepository(); SwitchSnapshotStep sut; @@ -52,15 +57,16 @@ public class SwitchSnapshotStepTest { db.truncateTables(); System2 system2 = mock(System2.class); when(system2.now()).thenReturn(DateUtils.parseDate("2011-09-29").getTime()); - this.sut = new SwitchSnapshotStep(new DbClient(db.database(), db.myBatis(), new SnapshotDao()), reportReader); + this.sut = new SwitchSnapshotStep(new DbClient(db.database(), db.myBatis(), new SnapshotDao()), treeRootHolder, dbIdsRepository); } @Test public void one_switch_with_a_snapshot_and_his_children() { db.prepareDbUnit(getClass(), "snapshots.xml"); - reportReader.setMetadata(BatchReport.Metadata.newBuilder() - .setSnapshotId(1L).build()); + Component project = DumbComponent.DUMB_PROJECT; + treeRootHolder.setRoot(project); + dbIdsRepository.setSnapshotId(project, 1); sut.execute(); diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java index 31419aec015..1903e566549 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java @@ -48,52 +48,43 @@ public final class BatchReport { getProjectKeyBytes(); /** - * optional string branch = 6; + * optional string branch = 3; */ boolean hasBranch(); /** - * optional string branch = 6; + * optional string branch = 3; */ java.lang.String getBranch(); /** - * optional string branch = 6; + * optional string branch = 3; */ com.google.protobuf.ByteString getBranchBytes(); /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ boolean hasRootComponentRef(); /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ int getRootComponentRef(); /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
      * temporary fields used during development of computation stack
      * 
*/ - boolean hasSnapshotId(); + boolean hasDeletedComponentsCount(); /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
      * temporary fields used during development of computation stack
      * 
*/ - long getSnapshotId(); - - /** - * optional int32 deleted_components_count = 5; - */ - boolean hasDeletedComponentsCount(); - /** - * optional int32 deleted_components_count = 5; - */ int getDeletedComponentsCount(); } /** @@ -159,27 +150,22 @@ public final class BatchReport { projectKey_ = bs; break; } - case 24: { - bitField0_ |= 0x00000008; - rootComponentRef_ = input.readInt32(); + case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000004; + branch_ = bs; break; } case 32: { - bitField0_ |= 0x00000010; - snapshotId_ = input.readInt64(); + bitField0_ |= 0x00000008; + rootComponentRef_ = input.readInt32(); break; } case 40: { - bitField0_ |= 0x00000020; + bitField0_ |= 0x00000010; deletedComponentsCount_ = input.readInt32(); break; } - case 50: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000004; - branch_ = bs; - break; - } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -289,16 +275,16 @@ public final class BatchReport { } } - public static final int BRANCH_FIELD_NUMBER = 6; + public static final int BRANCH_FIELD_NUMBER = 3; private java.lang.Object branch_; /** - * optional string branch = 6; + * optional string branch = 3; */ public boolean hasBranch() { return ((bitField0_ & 0x00000004) == 0x00000004); } /** - * optional string branch = 6; + * optional string branch = 3; */ public java.lang.String getBranch() { java.lang.Object ref = branch_; @@ -315,7 +301,7 @@ public final class BatchReport { } } /** - * optional string branch = 6; + * optional string branch = 3; */ public com.google.protobuf.ByteString getBranchBytes() { @@ -331,55 +317,40 @@ public final class BatchReport { } } - public static final int ROOT_COMPONENT_REF_FIELD_NUMBER = 3; + public static final int ROOT_COMPONENT_REF_FIELD_NUMBER = 4; private int rootComponentRef_; /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ public boolean hasRootComponentRef() { return ((bitField0_ & 0x00000008) == 0x00000008); } /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ public int getRootComponentRef() { return rootComponentRef_; } - public static final int SNAPSHOT_ID_FIELD_NUMBER = 4; - private long snapshotId_; + public static final int DELETED_COMPONENTS_COUNT_FIELD_NUMBER = 5; + private int deletedComponentsCount_; /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
      * temporary fields used during development of computation stack
      * 
*/ - public boolean hasSnapshotId() { + public boolean hasDeletedComponentsCount() { return ((bitField0_ & 0x00000010) == 0x00000010); } /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
      * temporary fields used during development of computation stack
      * 
*/ - public long getSnapshotId() { - return snapshotId_; - } - - public static final int DELETED_COMPONENTS_COUNT_FIELD_NUMBER = 5; - private int deletedComponentsCount_; - /** - * optional int32 deleted_components_count = 5; - */ - public boolean hasDeletedComponentsCount() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional int32 deleted_components_count = 5; - */ public int getDeletedComponentsCount() { return deletedComponentsCount_; } @@ -389,7 +360,6 @@ public final class BatchReport { projectKey_ = ""; branch_ = ""; rootComponentRef_ = 0; - snapshotId_ = 0L; deletedComponentsCount_ = 0; } private byte memoizedIsInitialized = -1; @@ -411,18 +381,15 @@ public final class BatchReport { if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeBytes(2, getProjectKeyBytes()); } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getBranchBytes()); + } if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeInt32(3, rootComponentRef_); + output.writeInt32(4, rootComponentRef_); } if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeInt64(4, snapshotId_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { output.writeInt32(5, deletedComponentsCount_); } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(6, getBranchBytes()); - } getUnknownFields().writeTo(output); } @@ -440,22 +407,18 @@ public final class BatchReport { size += com.google.protobuf.CodedOutputStream .computeBytesSize(2, getProjectKeyBytes()); } - if (((bitField0_ & 0x00000008) == 0x00000008)) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, rootComponentRef_); + .computeBytesSize(3, getBranchBytes()); } - if (((bitField0_ & 0x00000010) == 0x00000010)) { + if (((bitField0_ & 0x00000008) == 0x00000008)) { size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, snapshotId_); + .computeInt32Size(4, rootComponentRef_); } - if (((bitField0_ & 0x00000020) == 0x00000020)) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(5, deletedComponentsCount_); } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(6, getBranchBytes()); - } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -581,10 +544,8 @@ public final class BatchReport { bitField0_ = (bitField0_ & ~0x00000004); rootComponentRef_ = 0; bitField0_ = (bitField0_ & ~0x00000008); - snapshotId_ = 0L; - bitField0_ = (bitField0_ & ~0x00000010); deletedComponentsCount_ = 0; - bitField0_ = (bitField0_ & ~0x00000020); + bitField0_ = (bitField0_ & ~0x00000010); return this; } @@ -632,10 +593,6 @@ public final class BatchReport { if (((from_bitField0_ & 0x00000010) == 0x00000010)) { to_bitField0_ |= 0x00000010; } - result.snapshotId_ = snapshotId_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { - to_bitField0_ |= 0x00000020; - } result.deletedComponentsCount_ = deletedComponentsCount_; result.bitField0_ = to_bitField0_; onBuilt(); @@ -669,9 +626,6 @@ public final class BatchReport { if (other.hasRootComponentRef()) { setRootComponentRef(other.getRootComponentRef()); } - if (other.hasSnapshotId()) { - setSnapshotId(other.getSnapshotId()); - } if (other.hasDeletedComponentsCount()) { setDeletedComponentsCount(other.getDeletedComponentsCount()); } @@ -836,13 +790,13 @@ public final class BatchReport { private java.lang.Object branch_ = ""; /** - * optional string branch = 6; + * optional string branch = 3; */ public boolean hasBranch() { return ((bitField0_ & 0x00000004) == 0x00000004); } /** - * optional string branch = 6; + * optional string branch = 3; */ public java.lang.String getBranch() { java.lang.Object ref = branch_; @@ -859,7 +813,7 @@ public final class BatchReport { } } /** - * optional string branch = 6; + * optional string branch = 3; */ public com.google.protobuf.ByteString getBranchBytes() { @@ -875,7 +829,7 @@ public final class BatchReport { } } /** - * optional string branch = 6; + * optional string branch = 3; */ public Builder setBranch( java.lang.String value) { @@ -888,7 +842,7 @@ public final class BatchReport { return this; } /** - * optional string branch = 6; + * optional string branch = 3; */ public Builder clearBranch() { bitField0_ = (bitField0_ & ~0x00000004); @@ -897,7 +851,7 @@ public final class BatchReport { return this; } /** - * optional string branch = 6; + * optional string branch = 3; */ public Builder setBranchBytes( com.google.protobuf.ByteString value) { @@ -912,19 +866,19 @@ public final class BatchReport { private int rootComponentRef_ ; /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ public boolean hasRootComponentRef() { return ((bitField0_ & 0x00000008) == 0x00000008); } /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ public int getRootComponentRef() { return rootComponentRef_; } /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ public Builder setRootComponentRef(int value) { bitField0_ |= 0x00000008; @@ -933,7 +887,7 @@ public final class BatchReport { return this; } /** - * optional int32 root_component_ref = 3; + * optional int32 root_component_ref = 4; */ public Builder clearRootComponentRef() { bitField0_ = (bitField0_ & ~0x00000008); @@ -942,81 +896,49 @@ public final class BatchReport { return this; } - private long snapshotId_ ; + private int deletedComponentsCount_ ; /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
        * temporary fields used during development of computation stack
        * 
*/ - public boolean hasSnapshotId() { + public boolean hasDeletedComponentsCount() { return ((bitField0_ & 0x00000010) == 0x00000010); } /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
        * temporary fields used during development of computation stack
        * 
*/ - public long getSnapshotId() { - return snapshotId_; + public int getDeletedComponentsCount() { + return deletedComponentsCount_; } /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
        * temporary fields used during development of computation stack
        * 
*/ - public Builder setSnapshotId(long value) { + public Builder setDeletedComponentsCount(int value) { bitField0_ |= 0x00000010; - snapshotId_ = value; + deletedComponentsCount_ = value; onChanged(); return this; } /** - * optional int64 snapshot_id = 4; + * optional int32 deleted_components_count = 5; * *
        * temporary fields used during development of computation stack
        * 
*/ - public Builder clearSnapshotId() { - bitField0_ = (bitField0_ & ~0x00000010); - snapshotId_ = 0L; - onChanged(); - return this; - } - - private int deletedComponentsCount_ ; - /** - * optional int32 deleted_components_count = 5; - */ - public boolean hasDeletedComponentsCount() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * optional int32 deleted_components_count = 5; - */ - public int getDeletedComponentsCount() { - return deletedComponentsCount_; - } - /** - * optional int32 deleted_components_count = 5; - */ - public Builder setDeletedComponentsCount(int value) { - bitField0_ |= 0x00000020; - deletedComponentsCount_ = value; - onChanged(); - return this; - } - /** - * optional int32 deleted_components_count = 5; - */ public Builder clearDeletedComponentsCount() { - bitField0_ = (bitField0_ & ~0x00000020); + bitField0_ = (bitField0_ & ~0x00000010); deletedComponentsCount_ = 0; onChanged(); return this; @@ -1803,23 +1725,6 @@ public final class BatchReport { */ com.google.protobuf.ByteString getDescriptionBytes(); - - /** - * optional int64 snapshot_id = 13; - * - *
-     * temporary fields during development of computation stack
-     * 
- */ - boolean hasSnapshotId(); - /** - * optional int64 snapshot_id = 13; - * - *
-     * temporary fields during development of computation stack
-     * 
- */ - long getSnapshotId(); } /** * Protobuf type {@code Component} @@ -1964,11 +1869,6 @@ public final class BatchReport { description_ = bs; break; } - case 104: { - bitField0_ |= 0x00000400; - snapshotId_ = input.readInt64(); - break; - } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -2432,29 +2332,6 @@ public final class BatchReport { } } - public static final int SNAPSHOT_ID_FIELD_NUMBER = 13; - private long snapshotId_; - /** - * optional int64 snapshot_id = 13; - * - *
-     * temporary fields during development of computation stack
-     * 
- */ - public boolean hasSnapshotId() { - return ((bitField0_ & 0x00000400) == 0x00000400); - } - /** - * optional int64 snapshot_id = 13; - * - *
-     * temporary fields during development of computation stack
-     * 
- */ - public long getSnapshotId() { - return snapshotId_; - } - private void initFields() { ref_ = 0; path_ = ""; @@ -2468,7 +2345,6 @@ public final class BatchReport { key_ = ""; lines_ = 0; description_ = ""; - snapshotId_ = 0L; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -2523,9 +2399,6 @@ public final class BatchReport { if (((bitField0_ & 0x00000200) == 0x00000200)) { output.writeBytes(12, getDescriptionBytes()); } - if (((bitField0_ & 0x00000400) == 0x00000400)) { - output.writeInt64(13, snapshotId_); - } getUnknownFields().writeTo(output); } @@ -2593,10 +2466,6 @@ public final class BatchReport { size += com.google.protobuf.CodedOutputStream .computeBytesSize(12, getDescriptionBytes()); } - if (((bitField0_ & 0x00000400) == 0x00000400)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(13, snapshotId_); - } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -2743,8 +2612,6 @@ public final class BatchReport { bitField0_ = (bitField0_ & ~0x00000400); description_ = ""; bitField0_ = (bitField0_ & ~0x00000800); - snapshotId_ = 0L; - bitField0_ = (bitField0_ & ~0x00001000); return this; } @@ -2827,10 +2694,6 @@ public final class BatchReport { to_bitField0_ |= 0x00000200; } result.description_ = description_; - if (((from_bitField0_ & 0x00001000) == 0x00001000)) { - to_bitField0_ |= 0x00000400; - } - result.snapshotId_ = snapshotId_; result.bitField0_ = to_bitField0_; onBuilt(); return result; @@ -2925,9 +2788,6 @@ public final class BatchReport { description_ = other.description_; onChanged(); } - if (other.hasSnapshotId()) { - setSnapshotId(other.getSnapshotId()); - } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -3942,54 +3802,6 @@ public final class BatchReport { return this; } - private long snapshotId_ ; - /** - * optional int64 snapshot_id = 13; - * - *
-       * temporary fields during development of computation stack
-       * 
- */ - public boolean hasSnapshotId() { - return ((bitField0_ & 0x00001000) == 0x00001000); - } - /** - * optional int64 snapshot_id = 13; - * - *
-       * temporary fields during development of computation stack
-       * 
- */ - public long getSnapshotId() { - return snapshotId_; - } - /** - * optional int64 snapshot_id = 13; - * - *
-       * temporary fields during development of computation stack
-       * 
- */ - public Builder setSnapshotId(long value) { - bitField0_ |= 0x00001000; - snapshotId_ = value; - onChanged(); - return this; - } - /** - * optional int64 snapshot_id = 13; - * - *
-       * temporary fields during development of computation stack
-       * 
- */ - public Builder clearSnapshotId() { - bitField0_ = (bitField0_ & ~0x00001000); - snapshotId_ = 0L; - onChanged(); - return this; - } - // @@protoc_insertion_point(builder_scope:Component) } @@ -22332,78 +22144,77 @@ public final class BatchReport { descriptor; static { java.lang.String[] descriptorData = { - "\n\022batch_report.proto\032\017constants.proto\"\231\001" + + "\n\022batch_report.proto\032\017constants.proto\"\204\001" + "\n\010Metadata\022\025\n\ranalysis_date\030\001 \001(\003\022\023\n\013pro" + - "ject_key\030\002 \001(\t\022\016\n\006branch\030\006 \001(\t\022\032\n\022root_c" + - "omponent_ref\030\003 \001(\005\022\023\n\013snapshot_id\030\004 \001(\003\022" + - " \n\030deleted_components_count\030\005 \001(\005\"?\n\rCom" + - "ponentLink\022 \n\004type\030\001 \001(\0162\022.ComponentLink" + - "Type\022\014\n\004href\030\002 \001(\t\"\201\002\n\tComponent\022\013\n\003ref\030" + - "\001 \001(\005\022\014\n\004path\030\002 \001(\t\022\014\n\004name\030\003 \001(\t\022\034\n\004typ" + - "e\030\004 \001(\0162\016.ComponentType\022\017\n\007is_test\030\005 \001(\010" + - "\022\020\n\010language\030\006 \001(\t\022\025\n\tchild_ref\030\007 \003(\005B\002\020", - "\001\022\034\n\004link\030\010 \003(\0132\016.ComponentLink\022\017\n\007versi" + - "on\030\t \001(\t\022\013\n\003key\030\n \001(\t\022\r\n\005lines\030\013 \001(\005\022\023\n\013" + - "description\030\014 \001(\t\022\023\n\013snapshot_id\030\r \001(\003\"\316" + - "\003\n\007Measure\022%\n\nvalue_type\030\001 \001(\0162\021.Measure" + - "ValueType\022\025\n\rboolean_value\030\002 \001(\010\022\021\n\tint_" + - "value\030\003 \001(\005\022\022\n\nlong_value\030\004 \001(\003\022\024\n\014doubl" + - "e_value\030\005 \001(\001\022\024\n\014string_value\030\006 \001(\t\022\022\n\nm" + - "etric_key\030\007 \001(\t\022\023\n\013description\030\t \001(\t\022\020\n\010" + - "rule_key\030\n \001(\t\022\033\n\010severity\030\013 \001(\0162\t.Sever" + - "ity\022\024\n\014alert_status\030\014 \001(\t\022\022\n\nalert_text\030", - "\r \001(\t\022\031\n\021variation_value_1\030\016 \001(\001\022\031\n\021vari" + - "ation_value_2\030\017 \001(\001\022\031\n\021variation_value_3" + - "\030\020 \001(\001\022\031\n\021variation_value_4\030\021 \001(\001\022\031\n\021var" + - "iation_value_5\030\022 \001(\001\022\026\n\016characteric_id\030\023" + - " \001(\005\022\021\n\tperson_id\030\024 \001(\005\"<\n\010Measures\022\025\n\rc" + - "omponent_ref\030\001 \001(\005\022\031\n\007measure\030\002 \003(\0132\010.Me" + - "asure\"\231\004\n\005Issue\022\027\n\017rule_repository\030\001 \001(\t" + - "\022\020\n\010rule_key\030\002 \001(\t\022\014\n\004line\030\003 \001(\005\022\013\n\003msg\030" + - "\004 \001(\t\022\033\n\010severity\030\005 \001(\0162\t.Severity\022\013\n\003ta" + - "g\030\006 \003(\t\022\025\n\reffort_to_fix\030\007 \001(\001\022\016\n\006is_new", - "\030\010 \001(\010\022\014\n\004uuid\030\t \001(\t\022\027\n\017debt_in_minutes\030" + - "\n \001(\003\022\022\n\nresolution\030\013 \001(\t\022\016\n\006status\030\014 \001(" + - "\t\022\020\n\010checksum\030\r \001(\t\022\027\n\017manual_severity\030\016" + - " \001(\010\022\020\n\010reporter\030\017 \001(\t\022\020\n\010assignee\030\020 \001(\t" + - "\022\027\n\017action_plan_key\030\021 \001(\t\022\022\n\nattributes\030" + - "\022 \001(\t\022\024\n\014author_login\030\023 \001(\t\022\025\n\rcreation_" + - "date\030\024 \001(\003\022\022\n\nclose_date\030\025 \001(\003\022\023\n\013update" + - "_date\030\026 \001(\003\022\023\n\013selected_at\030\027 \001(\003\022\023\n\013diff" + - "_fields\030\030 \001(\t\022\022\n\nis_changed\030\031 \001(\010\022\036\n\026mus" + - "t_send_notification\030\032 \001(\010\"N\n\006Issues\022\025\n\rc", - "omponent_ref\030\001 \001(\005\022\025\n\005issue\030\002 \003(\0132\006.Issu" + - "e\022\026\n\016component_uuid\030\003 \001(\t\"\254\001\n\nChangesets" + - "\022\025\n\rcomponent_ref\030\001 \001(\005\022(\n\tchangeset\030\002 \003" + - "(\0132\025.Changesets.Changeset\022 \n\024changesetIn" + - "dexByLine\030\003 \003(\005B\002\020\001\032;\n\tChangeset\022\020\n\010revi" + - "sion\030\001 \001(\t\022\016\n\006author\030\002 \001(\t\022\014\n\004date\030\003 \001(\003" + - "\"R\n\tDuplicate\022\026\n\016other_file_ref\030\001 \001(\005\022\025\n" + - "\005range\030\002 \001(\0132\006.Range\022\026\n\016other_file_key\030\003" + - " \001(\t\"M\n\013Duplication\022\037\n\017origin_position\030\001" + - " \001(\0132\006.Range\022\035\n\tduplicate\030\002 \003(\0132\n.Duplic", - "ate\"H\n\014Duplications\022\025\n\rcomponent_ref\030\001 \001" + - "(\005\022!\n\013duplication\030\002 \003(\0132\014.Duplication\"W\n" + - "\005Range\022\022\n\nstart_line\030\001 \001(\005\022\020\n\010end_line\030\002" + - " \001(\005\022\024\n\014start_offset\030\003 \001(\005\022\022\n\nend_offset" + - "\030\004 \001(\005\"~\n\007Symbols\022\020\n\010file_ref\030\001 \001(\005\022\037\n\006s" + - "ymbol\030\002 \003(\0132\017.Symbols.Symbol\032@\n\006Symbol\022\033" + - "\n\013declaration\030\001 \001(\0132\006.Range\022\031\n\treference" + - "\030\002 \003(\0132\006.Range\"\260\001\n\010Coverage\022\014\n\004line\030\001 \001(" + - "\005\022\022\n\nconditions\030\002 \001(\005\022\017\n\007ut_hits\030\003 \001(\010\022\017" + - "\n\007it_hits\030\004 \001(\010\022\035\n\025ut_covered_conditions", - "\030\005 \001(\005\022\035\n\025it_covered_conditions\030\006 \001(\005\022\"\n" + - "\032overall_covered_conditions\030\007 \001(\005\"L\n\022Syn" + - "taxHighlighting\022\025\n\005range\030\001 \001(\0132\006.Range\022\037" + - "\n\004type\030\002 \001(\0162\021.HighlightingType\"j\n\004Test\022" + - "\014\n\004name\030\001 \001(\t\022\033\n\006status\030\002 \001(\0162\013.TestStat" + - "us\022\026\n\016duration_in_ms\030\003 \001(\003\022\022\n\nstacktrace" + - "\030\004 \001(\t\022\013\n\003msg\030\005 \001(\t\"\221\001\n\016CoverageDetail\022\021" + - "\n\ttest_name\030\001 \001(\t\0221\n\014covered_file\030\002 \003(\0132" + - "\033.CoverageDetail.CoveredFile\0329\n\013CoveredF" + - "ile\022\020\n\010file_ref\030\001 \001(\005\022\030\n\014covered_line\030\002 ", - "\003(\005B\002\020\001B#\n\037org.sonar.batch.protocol.outp" + - "utH\001" + "ject_key\030\002 \001(\t\022\016\n\006branch\030\003 \001(\t\022\032\n\022root_c" + + "omponent_ref\030\004 \001(\005\022 \n\030deleted_components" + + "_count\030\005 \001(\005\"?\n\rComponentLink\022 \n\004type\030\001 " + + "\001(\0162\022.ComponentLinkType\022\014\n\004href\030\002 \001(\t\"\354\001" + + "\n\tComponent\022\013\n\003ref\030\001 \001(\005\022\014\n\004path\030\002 \001(\t\022\014" + + "\n\004name\030\003 \001(\t\022\034\n\004type\030\004 \001(\0162\016.ComponentTy" + + "pe\022\017\n\007is_test\030\005 \001(\010\022\020\n\010language\030\006 \001(\t\022\025\n" + + "\tchild_ref\030\007 \003(\005B\002\020\001\022\034\n\004link\030\010 \003(\0132\016.Com", + "ponentLink\022\017\n\007version\030\t \001(\t\022\013\n\003key\030\n \001(\t" + + "\022\r\n\005lines\030\013 \001(\005\022\023\n\013description\030\014 \001(\t\"\316\003\n" + + "\007Measure\022%\n\nvalue_type\030\001 \001(\0162\021.MeasureVa" + + "lueType\022\025\n\rboolean_value\030\002 \001(\010\022\021\n\tint_va" + + "lue\030\003 \001(\005\022\022\n\nlong_value\030\004 \001(\003\022\024\n\014double_" + + "value\030\005 \001(\001\022\024\n\014string_value\030\006 \001(\t\022\022\n\nmet" + + "ric_key\030\007 \001(\t\022\023\n\013description\030\t \001(\t\022\020\n\010ru" + + "le_key\030\n \001(\t\022\033\n\010severity\030\013 \001(\0162\t.Severit" + + "y\022\024\n\014alert_status\030\014 \001(\t\022\022\n\nalert_text\030\r " + + "\001(\t\022\031\n\021variation_value_1\030\016 \001(\001\022\031\n\021variat", + "ion_value_2\030\017 \001(\001\022\031\n\021variation_value_3\030\020" + + " \001(\001\022\031\n\021variation_value_4\030\021 \001(\001\022\031\n\021varia" + + "tion_value_5\030\022 \001(\001\022\026\n\016characteric_id\030\023 \001" + + "(\005\022\021\n\tperson_id\030\024 \001(\005\"<\n\010Measures\022\025\n\rcom" + + "ponent_ref\030\001 \001(\005\022\031\n\007measure\030\002 \003(\0132\010.Meas" + + "ure\"\231\004\n\005Issue\022\027\n\017rule_repository\030\001 \001(\t\022\020" + + "\n\010rule_key\030\002 \001(\t\022\014\n\004line\030\003 \001(\005\022\013\n\003msg\030\004 " + + "\001(\t\022\033\n\010severity\030\005 \001(\0162\t.Severity\022\013\n\003tag\030" + + "\006 \003(\t\022\025\n\reffort_to_fix\030\007 \001(\001\022\016\n\006is_new\030\010" + + " \001(\010\022\014\n\004uuid\030\t \001(\t\022\027\n\017debt_in_minutes\030\n ", + "\001(\003\022\022\n\nresolution\030\013 \001(\t\022\016\n\006status\030\014 \001(\t\022" + + "\020\n\010checksum\030\r \001(\t\022\027\n\017manual_severity\030\016 \001" + + "(\010\022\020\n\010reporter\030\017 \001(\t\022\020\n\010assignee\030\020 \001(\t\022\027" + + "\n\017action_plan_key\030\021 \001(\t\022\022\n\nattributes\030\022 " + + "\001(\t\022\024\n\014author_login\030\023 \001(\t\022\025\n\rcreation_da" + + "te\030\024 \001(\003\022\022\n\nclose_date\030\025 \001(\003\022\023\n\013update_d" + + "ate\030\026 \001(\003\022\023\n\013selected_at\030\027 \001(\003\022\023\n\013diff_f" + + "ields\030\030 \001(\t\022\022\n\nis_changed\030\031 \001(\010\022\036\n\026must_" + + "send_notification\030\032 \001(\010\"N\n\006Issues\022\025\n\rcom" + + "ponent_ref\030\001 \001(\005\022\025\n\005issue\030\002 \003(\0132\006.Issue\022", + "\026\n\016component_uuid\030\003 \001(\t\"\254\001\n\nChangesets\022\025" + + "\n\rcomponent_ref\030\001 \001(\005\022(\n\tchangeset\030\002 \003(\013" + + "2\025.Changesets.Changeset\022 \n\024changesetInde" + + "xByLine\030\003 \003(\005B\002\020\001\032;\n\tChangeset\022\020\n\010revisi" + + "on\030\001 \001(\t\022\016\n\006author\030\002 \001(\t\022\014\n\004date\030\003 \001(\003\"R" + + "\n\tDuplicate\022\026\n\016other_file_ref\030\001 \001(\005\022\025\n\005r" + + "ange\030\002 \001(\0132\006.Range\022\026\n\016other_file_key\030\003 \001" + + "(\t\"M\n\013Duplication\022\037\n\017origin_position\030\001 \001" + + "(\0132\006.Range\022\035\n\tduplicate\030\002 \003(\0132\n.Duplicat" + + "e\"H\n\014Duplications\022\025\n\rcomponent_ref\030\001 \001(\005", + "\022!\n\013duplication\030\002 \003(\0132\014.Duplication\"W\n\005R" + + "ange\022\022\n\nstart_line\030\001 \001(\005\022\020\n\010end_line\030\002 \001" + + "(\005\022\024\n\014start_offset\030\003 \001(\005\022\022\n\nend_offset\030\004" + + " \001(\005\"~\n\007Symbols\022\020\n\010file_ref\030\001 \001(\005\022\037\n\006sym" + + "bol\030\002 \003(\0132\017.Symbols.Symbol\032@\n\006Symbol\022\033\n\013" + + "declaration\030\001 \001(\0132\006.Range\022\031\n\treference\030\002" + + " \003(\0132\006.Range\"\260\001\n\010Coverage\022\014\n\004line\030\001 \001(\005\022" + + "\022\n\nconditions\030\002 \001(\005\022\017\n\007ut_hits\030\003 \001(\010\022\017\n\007" + + "it_hits\030\004 \001(\010\022\035\n\025ut_covered_conditions\030\005" + + " \001(\005\022\035\n\025it_covered_conditions\030\006 \001(\005\022\"\n\032o", + "verall_covered_conditions\030\007 \001(\005\"L\n\022Synta" + + "xHighlighting\022\025\n\005range\030\001 \001(\0132\006.Range\022\037\n\004" + + "type\030\002 \001(\0162\021.HighlightingType\"j\n\004Test\022\014\n" + + "\004name\030\001 \001(\t\022\033\n\006status\030\002 \001(\0162\013.TestStatus" + + "\022\026\n\016duration_in_ms\030\003 \001(\003\022\022\n\nstacktrace\030\004" + + " \001(\t\022\013\n\003msg\030\005 \001(\t\"\221\001\n\016CoverageDetail\022\021\n\t" + + "test_name\030\001 \001(\t\0221\n\014covered_file\030\002 \003(\0132\033." + + "CoverageDetail.CoveredFile\0329\n\013CoveredFil" + + "e\022\020\n\010file_ref\030\001 \001(\005\022\030\n\014covered_line\030\002 \003(" + + "\005B\002\020\001B#\n\037org.sonar.batch.protocol.output", + "H\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -22423,7 +22234,7 @@ public final class BatchReport { internal_static_Metadata_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_Metadata_descriptor, - new java.lang.String[] { "AnalysisDate", "ProjectKey", "Branch", "RootComponentRef", "SnapshotId", "DeletedComponentsCount", }); + new java.lang.String[] { "AnalysisDate", "ProjectKey", "Branch", "RootComponentRef", "DeletedComponentsCount", }); internal_static_ComponentLink_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_ComponentLink_fieldAccessorTable = new @@ -22435,7 +22246,7 @@ public final class BatchReport { internal_static_Component_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_Component_descriptor, - new java.lang.String[] { "Ref", "Path", "Name", "Type", "IsTest", "Language", "ChildRef", "Link", "Version", "Key", "Lines", "Description", "SnapshotId", }); + new java.lang.String[] { "Ref", "Path", "Name", "Type", "IsTest", "Language", "ChildRef", "Link", "Version", "Key", "Lines", "Description", }); internal_static_Measure_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_Measure_fieldAccessorTable = new diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto index 31b42388b42..88d4c6abdc5 100644 --- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto +++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto @@ -43,11 +43,10 @@ message Metadata { optional int64 analysis_date = 1; // TODO should we keep this project_key here or not ? Because it's a duplication of Component.key optional string project_key = 2; - optional string branch = 6; - optional int32 root_component_ref = 3; + optional string branch = 3; + optional int32 root_component_ref = 4; // temporary fields used during development of computation stack - optional int64 snapshot_id = 4; optional int32 deleted_components_count = 5; } @@ -74,9 +73,6 @@ message Component { optional int32 lines = 11; // Only available on PROJECT and MODULE types optional string description = 12; - - // temporary fields during development of computation stack - optional int64 snapshot_id = 13; } message Measure { diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java index 7117aebaf30..e3c971fd10c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java @@ -72,10 +72,6 @@ public class ComponentsPublisher implements ReportPublisherStep { // protocol buffers does not accept null values - Integer sid = batchComponent.snapshotId(); - if (sid != null) { - builder.setSnapshotId(sid); - } if (batchComponent.isFile()) { builder.setIsTest(ResourceUtils.isUnitTestFile(r)); builder.setLines(((InputFile) batchComponent.inputPath()).lines()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java index 9af7a18fe12..08be39df953 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/IssuesPublisher.java @@ -86,10 +86,6 @@ public class IssuesPublisher implements ReportPublisherStep { if (branch != null) { builder.setBranch(branch); } - Integer sid = rootProject.snapshotId(); - if (sid != null) { - builder.setSnapshotId(sid); - } writer.writeMetadata(builder.build()); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/IssuesPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/IssuesPublisherTest.java index 7f0b40c8d59..8e49ddb719f 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/report/IssuesPublisherTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/report/IssuesPublisherTest.java @@ -111,7 +111,6 @@ public class IssuesPublisherTest { assertThat(metadata.getAnalysisDate()).isEqualTo(1234567L); assertThat(metadata.getProjectKey()).isEqualTo("foo"); assertThat(metadata.getDeletedComponentsCount()).isEqualTo(0); - assertThat(metadata.getSnapshotId()).isEqualTo(2); assertThat(reader.readComponentIssues(1)).hasSize(0); assertThat(reader.readComponentIssues(2)).hasSize(2); @@ -135,7 +134,6 @@ public class IssuesPublisherTest { assertThat(metadata.getProjectKey()).isEqualTo("foo"); assertThat(metadata.getBranch()).isEqualTo("myBranch"); assertThat(metadata.getDeletedComponentsCount()).isEqualTo(0); - assertThat(metadata.getSnapshotId()).isEqualTo(2); } @Test -- 2.39.5