From ee5860395a505e9acee4a3908e1c7df3c9541536 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 13 Mar 2015 16:15:47 +0100 Subject: [PATCH] persist measures on server side - SONAR-6253 --- .../component/ws/ComponentAppAction.java | 52 +- .../computation/ComputationContainer.java | 42 +- .../measure/BatchReportMeasureUtils.java | 87 + .../computation/measure/MetricCache.java | 56 + .../computation/step/ComputationSteps.java | 1 + .../computation/step/PersistMeasuresStep.java | 120 + .../server/duplication/ws/ShowAction.java | 8 +- .../measure/persistence/MeasureDao.java | 53 +- .../sonar/server/source/SourceService.java | 4 +- .../sonar/server/test/CoverageService.java | 3 +- .../sonar/server/test/ws/TestsShowAction.java | 2 +- .../component/ws/ComponentAppActionTest.java | 13 +- .../measure/BatchReportMeasureUtilsTest.java | 93 + .../computation/measure/MetricCacheTest.java | 56 + .../step/ComputationStepsTest.java | 5 +- .../step/PersistMeasuresStepTest.java | 234 + .../server/duplication/ws/ShowActionTest.java | 16 +- .../measure/persistence/MeasureDaoTest.java | 89 +- .../server/source/SourceServiceTest.java | 25 +- .../server/test/CoverageServiceTest.java | 28 +- .../server/test/ws/TestsShowActionTest.java | 18 +- .../measure/MetricCacheTest/metrics.xml | 13 + .../step/PersistMeasuresStepTest/shared.xml | 5 + .../persistence/MeasureDaoTest/empty.xml | 3 + .../MeasureDaoTest/insert-result.xml | 27 + .../persistence/MeasureDaoTest/shared.xml | 2 +- .../org/sonar/batch/protocol/Constants.java | 138 +- .../batch/protocol/input/BatchInput.java | 209 +- .../batch/protocol/output/BatchReport.java | 4351 ++++++++++++++--- .../sonar/server/source/db/FileSourceDb.java | 198 +- .../protocol/output/BatchReportReader.java | 20 +- .../protocol/output/BatchReportWriter.java | 8 + .../batch/protocol/output/FileStructure.java | 2 +- .../src/main/protobuf/batch_report.proto | 31 + .../src/main/protobuf/constants.proto | 8 + .../output/BatchReportReaderTest.java | 54 +- .../output/BatchReportWriterTest.java | 24 + .../components/DefaultTimeMachine.java | 1 - .../sonar/batch/index/MeasurePersister.java | 1 - .../org/sonar/core/measure/db/MeasureDto.java | 212 +- .../org/sonar/core/measure/db/MeasureKey.java | 79 - .../sonar/core/measure/db/MeasureMapper.java | 5 +- .../java/org/sonar/core/rule/RuleDto.java | 2 +- .../sonar/core/measure/db/MeasureMapper.xml | 50 +- .../sonar/core/measure/db/MeasureDtoTest.java | 74 +- .../sonar/core/measure/db/MeasureKeyTest.java | 72 - .../core/persistence/AbstractDaoTestCase.java | 31 +- 47 files changed, 5325 insertions(+), 1300 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchReportMeasureUtils.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/computation/measure/MetricCache.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchReportMeasureUtilsTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/computation/measure/MetricCacheTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java create mode 100644 server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MetricCacheTest/metrics.xml create mode 100644 server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistMeasuresStepTest/shared.xml create mode 100644 server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/empty.xml create mode 100644 server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml delete mode 100644 sonar-core/src/main/java/org/sonar/core/measure/db/MeasureKey.java delete mode 100644 sonar-core/src/test/java/org/sonar/core/measure/db/MeasureKeyTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java index c5132c9c9348..e08f7aa136af 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ComponentAppAction.java @@ -183,8 +183,8 @@ private MeasureDto coverageMeasure(Map measuresByMetricKey) private Map measuresByMetricKey(ComponentDto component, DbSession session) { Map measuresByMetricKey = newHashMap(); String fileKey = component.getKey(); - for (MeasureDto measureDto : dbClient.measureDao().findByComponentKeyAndMetricKeys(fileKey, METRIC_KEYS, session)) { - measuresByMetricKey.put(measureDto.getKey().metricKey(), measureDto); + for (MeasureDto measureDto : dbClient.measureDao().findByComponentKeyAndMetricKeys(session, fileKey, METRIC_KEYS)) { + measuresByMetricKey.put(measureDto.getMetricKey(), measureDto); } return measuresByMetricKey; } @@ -199,29 +199,31 @@ private ComponentDto nullableComponentById(@Nullable Long componentId, DbSession @CheckForNull private String formatMeasure(@Nullable MeasureDto measure) { - if (measure != null) { - Metric metric = CoreMetrics.getMetric(measure.getKey().metricKey()); - Metric.ValueType metricType = metric.getType(); - Double value = measure.getValue(); - String data = measure.getData(); - if (BooleanUtils.isTrue(metric.isOptimizedBestValue()) && value == null) { - value = metric.getBestValue(); - } - if (metricType.equals(Metric.ValueType.FLOAT) && value != null) { - return i18n.formatDouble(UserSession.get().locale(), value); - } - if (metricType.equals(Metric.ValueType.INT) && value != null) { - return i18n.formatInteger(UserSession.get().locale(), value.intValue()); - } - if (metricType.equals(Metric.ValueType.PERCENT) && value != null) { - return i18n.formatDouble(UserSession.get().locale(), value) + "%"; - } - if (metricType.equals(Metric.ValueType.WORK_DUR) && value != null) { - return durations.format(UserSession.get().locale(), durations.create(value.longValue()), Durations.DurationFormat.SHORT); - } - if ((metricType.equals(Metric.ValueType.STRING) || metricType.equals(Metric.ValueType.RATING)) && data != null) { - return data; - } + if (measure == null) { + return null; + } + + Metric metric = CoreMetrics.getMetric(measure.getMetricKey()); + Metric.ValueType metricType = metric.getType(); + Double value = measure.getValue(); + String data = measure.getData(); + if (BooleanUtils.isTrue(metric.isOptimizedBestValue()) && value == null) { + value = metric.getBestValue(); + } + if (metricType.equals(Metric.ValueType.FLOAT) && value != null) { + return i18n.formatDouble(UserSession.get().locale(), value); + } + if (metricType.equals(Metric.ValueType.INT) && value != null) { + return i18n.formatInteger(UserSession.get().locale(), value.intValue()); + } + if (metricType.equals(Metric.ValueType.PERCENT) && value != null) { + return i18n.formatDouble(UserSession.get().locale(), value) + "%"; + } + if (metricType.equals(Metric.ValueType.WORK_DUR) && value != null) { + return durations.format(UserSession.get().locale(), durations.create(value.longValue()), Durations.DurationFormat.SHORT); + } + if ((metricType.equals(Metric.ValueType.STRING) || metricType.equals(Metric.ValueType.RATING)) && data != null) { + return data; } return null; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationContainer.java b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationContainer.java index 21e9e7c9cb27..95ad3ef370e7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationContainer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/ComputationContainer.java @@ -21,13 +21,8 @@ import org.sonar.api.platform.ComponentContainer; import org.sonar.core.issue.db.UpdateConflictResolver; -import org.sonar.server.computation.issue.IssueCache; -import org.sonar.server.computation.issue.IssueComputation; -import org.sonar.server.computation.issue.RuleCache; -import org.sonar.server.computation.issue.RuleCacheLoader; -import org.sonar.server.computation.issue.ScmAccountCache; -import org.sonar.server.computation.issue.ScmAccountCacheLoader; -import org.sonar.server.computation.issue.SourceLinesCache; +import org.sonar.server.computation.issue.*; +import org.sonar.server.computation.measure.MetricCache; import org.sonar.server.computation.step.ComputationSteps; import org.sonar.server.platform.Platform; import org.sonar.server.view.index.ViewIndex; @@ -37,22 +32,6 @@ public class ComputationContainer { - public void execute(ReportQueue.Item item) { - ComponentContainer container = Platform.getInstance().getContainer(); - ComponentContainer child = container.createChild(); - child.addSingletons(componentClasses()); - child.addSingletons(ComputationSteps.orderedStepClasses()); - child.startComponents(); - try { - child.getComponentByType(ComputationService.class).process(item); - } finally { - child.stopComponents(); - // TODO not possible to have multiple children -> will be - // a problem when we will have multiple concurrent computation workers - container.removeChild(); - } - } - /** * List of all objects to be injected in the picocontainer dedicated to computation stack. * Does not contain the steps declared in {@link org.sonar.server.computation.step.ComputationSteps#orderedStepClasses()}. @@ -70,9 +49,26 @@ static List componentClasses() { RuleCache.class, RuleCacheLoader.class, IssueCache.class, + MetricCache.class, UpdateConflictResolver.class, // views ViewIndex.class); } + + public void execute(ReportQueue.Item item) { + ComponentContainer container = Platform.getInstance().getContainer(); + ComponentContainer child = container.createChild(); + child.addSingletons(componentClasses()); + child.addSingletons(ComputationSteps.orderedStepClasses()); + child.startComponents(); + try { + child.getComponentByType(ComputationService.class).process(item); + } finally { + child.stopComponents(); + // TODO not possible to have multiple children -> will be + // a problem when we will have multiple concurrent computation workers + container.removeChild(); + } + } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchReportMeasureUtils.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchReportMeasureUtils.java new file mode 100644 index 000000000000..3e35b9970aad --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/BatchReportMeasureUtils.java @@ -0,0 +1,87 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.computation.measure; + +import org.sonar.batch.protocol.output.BatchReport; + +import javax.annotation.CheckForNull; + +public class BatchReportMeasureUtils { + private BatchReportMeasureUtils() { + // static methods only + } + + /** + * return the numerical value as a double. It's the type used in db. + * Returns null if no numerical value found + */ + @CheckForNull + public static Double valueAsDouble(BatchReport.Measure measure) { + switch (measure.getValueType()) { + case BOOLEAN: + return measure.getBooleanValue() ? 1.0d : 0.0d; + case INT: + return Double.valueOf(measure.getIntValue()); + case LONG: + return Double.valueOf(measure.getLongValue()); + case DOUBLE: + return measure.getDoubleValue(); + default: + return null; + } + } + + /** + * check that measure has a value (numerical or string) and a metric key + */ + public static void checkMeasure(BatchReport.Measure measure) { + if (!measure.hasValueType() || !measure.hasMetricKey()) { + throw newIllegalStateException(measure); + } + + boolean hasValueOrData = false; + switch (measure.getValueType()) { + case DOUBLE: + hasValueOrData = measure.hasDoubleValue(); + break; + case INT: + hasValueOrData = measure.hasIntValue(); + break; + case LONG: + hasValueOrData = measure.hasLongValue(); + break; + case STRING: + hasValueOrData = measure.hasStringValue(); + break; + case BOOLEAN: + hasValueOrData = measure.hasBooleanValue(); + break; + } + + if (!hasValueOrData) { + throw newIllegalStateException(measure); + } + } + + private static IllegalStateException newIllegalStateException(BatchReport.Measure measure) { + return new IllegalStateException(String.format("Measure %s does not have value", measure)); + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MetricCache.java b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MetricCache.java new file mode 100644 index 000000000000..cd908bf41908 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/measure/MetricCache.java @@ -0,0 +1,56 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.computation.measure; + +import com.google.common.base.Function; +import com.google.common.collect.Maps; +import org.sonar.core.measure.db.MetricDto; +import org.sonar.core.persistence.DbSession; +import org.sonar.server.db.DbClient; +import org.sonar.server.exceptions.NotFoundException; + +import java.util.List; +import java.util.Map; + +public class MetricCache { + private final Map metrics; + + public MetricCache(DbClient dbClient) { + try (DbSession dbSession = dbClient.openSession(false)) { + List metricList = dbClient.metricDao().findEnabled(dbSession); + this.metrics = Maps.uniqueIndex(metricList, new Function() { + @Override + public String apply(MetricDto metric) { + return metric.getKey(); + } + }); + } + } + + public MetricDto get(String key) { + MetricDto metric = metrics.get(key); + if (metric == null) { + throw new NotFoundException(String.format("Not found: '%s'", key)); + } + + return metric; + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java index 81cdeea9eda6..530fcaad11b4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java @@ -41,6 +41,7 @@ public static List> orderedStepClasses() { ParseReportStep.class, // Persist data + PersistMeasuresStep.class, PersistIssuesStep.class, PersistComponentLinksStep.class, PersistEventsStep.class, 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 new file mode 100644 index 000000000000..68d8ea117067 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java @@ -0,0 +1,120 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.computation.step; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.collect.Lists; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.rule.RuleKey; +import org.sonar.batch.protocol.output.BatchReport; +import org.sonar.batch.protocol.output.BatchReportReader; +import org.sonar.core.measure.db.MeasureDto; +import org.sonar.core.persistence.DbSession; +import org.sonar.server.computation.ComputationContext; +import org.sonar.server.computation.issue.RuleCache; +import org.sonar.server.computation.measure.MetricCache; +import org.sonar.server.db.DbClient; + +import java.util.List; + +import static org.sonar.server.computation.measure.BatchReportMeasureUtils.checkMeasure; +import static org.sonar.server.computation.measure.BatchReportMeasureUtils.valueAsDouble; + +public class PersistMeasuresStep implements ComputationStep { + + private final DbClient dbClient; + private final RuleCache ruleCache; + private final MetricCache metricCache; + + public PersistMeasuresStep(DbClient dbClient, RuleCache ruleCache, MetricCache metricCache) { + this.dbClient = dbClient; + this.ruleCache = ruleCache; + this.metricCache = metricCache; + } + + @Override + public String[] supportedProjectQualifiers() { + return new String[] {Qualifiers.PROJECT, Qualifiers.VIEW}; + } + + @Override + public String getDescription() { + return "Persist measures"; + } + + @Override + public void execute(ComputationContext context) { + int rootComponentRef = context.getReportMetadata().getRootComponentRef(); + try (DbSession dbSession = dbClient.openSession(true)) { + recursivelyProcessComponent(dbSession, context, rootComponentRef); + dbSession.commit(); + } + } + + private void recursivelyProcessComponent(DbSession dbSession, ComputationContext context, int componentRef) { + BatchReportReader reportReader = context.getReportReader(); + BatchReport.Component component = reportReader.readComponent(componentRef); + List measures = reportReader.readComponentMeasures(componentRef); + persistMeasures(dbSession, measures, component); + for (Integer childRef : component.getChildRefList()) { + recursivelyProcessComponent(dbSession, context, childRef); + } + } + + private void persistMeasures(DbSession dbSession, List batchReportMeasures, final BatchReport.Component component) { + List measures = Lists.transform(batchReportMeasures, new Function() { + @Override + public MeasureDto apply(BatchReport.Measure batchMeasure) { + return toMeasureDto(batchMeasure, component); + } + }); + + for (MeasureDto measure : measures) { + dbClient.measureDao().insert(dbSession, measure); + } + } + + @VisibleForTesting + MeasureDto toMeasureDto(BatchReport.Measure in, BatchReport.Component component) { + checkMeasure(in); + + MeasureDto out = new MeasureDto() + .setTendency(in.hasTendency() ? in.getTendency() : null) + .setVariation(1, in.hasVariationValue1() ? in.getVariationValue1() : null) + .setVariation(2, in.hasVariationValue2() ? in.getVariationValue2() : null) + .setVariation(3, in.hasVariationValue3() ? in.getVariationValue3() : null) + .setVariation(4, in.hasVariationValue4() ? in.getVariationValue4() : null) + .setVariation(5, in.hasVariationValue5() ? in.getVariationValue5() : null) + .setAlertStatus(in.hasAlertStatus() ? in.getAlertStatus() : null) + .setAlertText(in.hasAlertText() ? in.getAlertText() : null) + .setDescription(in.hasDescription() ? in.getDescription() : null) + .setSeverity(in.hasSeverity() ? in.getSeverity().name() : null) + .setComponentId(component.getId()) + .setSnapshotId(component.getSnapshotId()) + .setMetricId(metricCache.get(in.getMetricKey()).getId()) + .setRuleId(ruleCache.get(RuleKey.parse(in.getRuleKey())).getId()) + .setCharacteristicId(in.hasCharactericId() ? in.getCharactericId() : null); + out.setValue(valueAsDouble(in)); + out.setData(in.hasStringValue() ? in.getStringValue() : null); + return out; + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java index e3d309a57cc9..5f18d58f81fd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowAction.java @@ -31,7 +31,6 @@ import org.sonar.api.web.UserRole; import org.sonar.core.component.ComponentDto; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.component.db.ComponentDao; @@ -41,7 +40,6 @@ import org.sonar.server.user.UserSession; import javax.annotation.CheckForNull; - import java.util.List; public class ShowAction implements RequestHandler { @@ -105,9 +103,9 @@ public void handle(Request request, Response response) { @CheckForNull private String findDataFromComponent(String fileKey, String metricKey, DbSession session) { - MeasureDto data = measureDao.getNullableByKey(session, MeasureKey.of(fileKey, metricKey)); - if (data != null) { - return data.getData(); + MeasureDto measure = measureDao.findByComponentKeyAndMetricKey(session, fileKey, metricKey); + if (measure != null) { + return measure.getData(); } return null; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/persistence/MeasureDao.java b/server/sonar-server/src/main/java/org/sonar/server/measure/persistence/MeasureDao.java index 89790d9524c6..7b1b40db23d3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/persistence/MeasureDao.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/persistence/MeasureDao.java @@ -20,55 +20,42 @@ package org.sonar.server.measure.persistence; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Lists; +import com.google.common.base.Function; import org.sonar.api.ServerComponent; -import org.sonar.api.utils.System2; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.measure.db.MeasureMapper; import org.sonar.core.persistence.DaoComponent; +import org.sonar.core.persistence.DaoUtils; import org.sonar.core.persistence.DbSession; -import org.sonar.server.db.BaseDao; -import java.util.Collections; +import javax.annotation.CheckForNull; import java.util.List; -import static com.google.common.collect.Lists.newArrayList; +public class MeasureDao implements ServerComponent, DaoComponent { -public class MeasureDao extends BaseDao implements ServerComponent, DaoComponent { - - public MeasureDao() { - this(System2.INSTANCE); - } - - @VisibleForTesting - public MeasureDao(System2 system) { - super(MeasureMapper.class, system); + public boolean existsByKey(DbSession session, String componentKey, String metricKey) { + return mapper(session).countByComponentAndMetric(componentKey, metricKey) > 0; } - @Override - protected MeasureDto doGetNullableByKey(DbSession session, MeasureKey key) { - return mapper(session).selectByKey(key); + @CheckForNull + public MeasureDto findByComponentKeyAndMetricKey(DbSession session, String componentKey, String metricKey) { + return mapper(session).selectByComponentAndMetric(componentKey, metricKey); } - public boolean existsByKey(MeasureKey key, DbSession session) { - return mapper(session).countByKey(key) > 0; + public List findByComponentKeyAndMetricKeys(final DbSession session, final String componentKey, List metricKeys) { + return DaoUtils.executeLargeInputs(metricKeys, new Function, List>() { + @Override + public List apply(List keys) { + return mapper(session).selectByComponentAndMetrics(componentKey, keys); + } + }); } - public List findByComponentKeyAndMetricKeys(String componentKey, List metricKeys, DbSession session) { - if (metricKeys.isEmpty()) { - return Collections.emptyList(); - } - List dtos = newArrayList(); - List> partitions = Lists.partition(newArrayList(metricKeys), 1000); - for (List partition : partitions) { - dtos.addAll(mapper(session).selectByComponentAndMetrics(componentKey, partition)); - } - return dtos; + public void insert(DbSession session, MeasureDto measureDto) { + mapper(session).insert(measureDto); } - public MeasureDto findByComponentKeyAndMetricKey(String componentKey, String metricKey, DbSession session) { - return mapper(session).selectByComponentAndMetric(componentKey, metricKey); + private MeasureMapper mapper(DbSession session) { + return session.getMapper(MeasureMapper.class); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java b/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java index 4b4add00ce50..ed80adb8f940 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java @@ -26,7 +26,6 @@ import org.sonar.api.measures.CoreMetrics; import org.sonar.api.web.UserRole; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.db.DbClient; @@ -36,7 +35,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; - import java.util.List; public class SourceService implements ServerComponent { @@ -97,7 +95,7 @@ private void checkPermission(String fileKey) { private String findDataFromComponent(String fileKey, String metricKey) { DbSession session = dbClient.openSession(false); try { - MeasureDto data = dbClient.measureDao().getNullableByKey(session, MeasureKey.of(fileKey, metricKey)); + MeasureDto data = dbClient.measureDao().findByComponentKeyAndMetricKey(session, fileKey, metricKey); if (data != null) { return data.getData(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java b/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java index 3a72095367c8..3f34be942f33 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/test/CoverageService.java @@ -29,7 +29,6 @@ import org.sonar.api.web.UserRole; import org.sonar.core.component.SnapshotPerspectives; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.measure.persistence.MeasureDao; @@ -109,7 +108,7 @@ public Map getTestCases(String fileKey, CoverageService.TYPE t private Map findDataFromComponent(String fileKey, String metricKey) { DbSession session = myBatis.openSession(false); try { - MeasureDto data = measureDao.getNullableByKey(session, MeasureKey.of(fileKey, metricKey)); + MeasureDto data = measureDao.findByComponentKeyAndMetricKey(session, fileKey, metricKey); String dataValue = data != null ? data.getData() : null; if (dataValue != null) { return KeyValueFormat.parseIntInt(dataValue); diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/ws/TestsShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/test/ws/TestsShowAction.java index 4213c5553bee..2b04e68cf0ae 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/test/ws/TestsShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/test/ws/TestsShowAction.java @@ -138,7 +138,7 @@ private void writeFromTestData(String data, JsonWriter json) { private String findTestData(String fileKey) { DbSession session = dbClient.openSession(false); try { - MeasureDto testData = dbClient.measureDao().findByComponentKeyAndMetricKey(fileKey, CoreMetrics.TEST_DATA_KEY, session); + MeasureDto testData = dbClient.measureDao().findByComponentKeyAndMetricKey(session, fileKey, CoreMetrics.TEST_DATA_KEY); if (testData != null) { return testData.getData(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ComponentAppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ComponentAppActionTest.java index 19496fb97ada..b7d0e9492169 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ComponentAppActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ComponentAppActionTest.java @@ -34,7 +34,6 @@ import org.sonar.api.web.UserRole; import org.sonar.core.component.ComponentDto; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.core.properties.PropertiesDao; import org.sonar.core.properties.PropertyDto; @@ -99,7 +98,7 @@ public void setUp() throws Exception { when(dbClient.propertiesDao()).thenReturn(propertiesDao); when(dbClient.measureDao()).thenReturn(measureDao); - when(measureDao.findByComponentKeyAndMetricKeys(anyString(), anyListOf(String.class), eq(session))).thenReturn(measures); + when(measureDao.findByComponentKeyAndMetricKeys(eq(session), anyString(), anyListOf(String.class))).thenReturn(measures); tester = new WsTester(new ComponentsWs(new ComponentAppAction(dbClient, durations, i18n), mock(SearchAction.class))); } @@ -139,13 +138,13 @@ public void app_with_measures() throws Exception { addMeasure(CoreMetrics.SQALE_RATING_KEY, "C"); addMeasure(CoreMetrics.SQALE_DEBT_RATIO_KEY, 35d); - measures.add(MeasureDto.createFor(MeasureKey.of(COMPONENT_KEY, CoreMetrics.TECHNICAL_DEBT_KEY)).setValue(182.0)); + measures.add(new MeasureDto().setComponentKey(COMPONENT_KEY).setMetricKey(CoreMetrics.TECHNICAL_DEBT_KEY).setValue(182.0)); when(durations.format(any(Locale.class), any(Duration.class), eq(Durations.DurationFormat.SHORT))).thenReturn("3h 2min"); WsTester.TestRequest request = tester.newGetRequest("api/components", "app").setParam("uuid", COMPONENT_UUID); request.execute().assertJson(getClass(), "app_with_measures.json"); - verify(measureDao).findByComponentKeyAndMetricKeys(eq(COMPONENT_KEY), measureKeysCaptor.capture(), eq(session)); + verify(measureDao).findByComponentKeyAndMetricKeys(eq(session), eq(COMPONENT_KEY), measureKeysCaptor.capture()); assertThat(measureKeysCaptor.getValue()).contains(CoreMetrics.LINES_KEY, CoreMetrics.COVERAGE_KEY, CoreMetrics.DUPLICATED_LINES_DENSITY_KEY, CoreMetrics.TECHNICAL_DEBT_KEY); } @@ -229,17 +228,17 @@ private ComponentDto newComponent(ComponentDto project) { } private void addMeasure(String metricKey, Integer value) { - measures.add(MeasureDto.createFor(MeasureKey.of(COMPONENT_KEY, metricKey)).setValue(value.doubleValue())); + measures.add(new MeasureDto().setComponentKey(COMPONENT_KEY).setMetricKey(metricKey).setValue(value.doubleValue())); when(i18n.formatInteger(any(Locale.class), eq(value.intValue()))).thenReturn(Integer.toString(value)); } private void addMeasure(String metricKey, Double value) { - measures.add(MeasureDto.createFor(MeasureKey.of(COMPONENT_KEY, metricKey)).setValue(value)); + measures.add(new MeasureDto().setComponentKey(COMPONENT_KEY).setMetricKey(metricKey).setValue(value)); when(i18n.formatDouble(any(Locale.class), eq(value))).thenReturn(Double.toString(value)); } private void addMeasure(String metricKey, String value) { - measures.add(MeasureDto.createFor(MeasureKey.of(COMPONENT_KEY, metricKey)).setTextValue(value)); + measures.add(new MeasureDto().setComponentKey(COMPONENT_KEY).setMetricKey(metricKey).setData(value)); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchReportMeasureUtilsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchReportMeasureUtilsTest.java new file mode 100644 index 000000000000..6d743fa27577 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/BatchReportMeasureUtilsTest.java @@ -0,0 +1,93 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.computation.measure; + +import org.junit.Test; +import org.sonar.batch.protocol.Constants; +import org.sonar.batch.protocol.output.BatchReport; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.batch.protocol.Constants.MeasureValueType.*; +import static org.sonar.server.computation.measure.BatchReportMeasureUtils.checkMeasure; +import static org.sonar.server.computation.measure.BatchReportMeasureUtils.valueAsDouble; + +public class BatchReportMeasureUtilsTest { + + @Test(expected = IllegalStateException.class) + public void fail_when_no_metric_key() throws Exception { + BatchReport.Measure measure = BatchReport.Measure.newBuilder() + .setValueType(STRING) + .setStringValue("string-value") + .build(); + + checkMeasure(measure); + } + + @Test(expected = IllegalStateException.class) + public void fail_when_no_value() throws Exception { + BatchReport.Measure measure = BatchReport.Measure.newBuilder() + .setMetricKey("repo:metric-key") + .build(); + + checkMeasure(measure); + } + + @Test(expected = IllegalStateException.class) + public void fail_when_no_consistency_between_string_value_and_numerical_value_type() throws Exception { + BatchReport.Measure measure = BatchReport.Measure.newBuilder() + .setValueType(DOUBLE) + .setStringValue("string-value") + .build(); + + checkMeasure(measure); + } + + @Test(expected = IllegalStateException.class) + public void fail_when_no_consistence_between_numerical_value_types() throws Exception { + BatchReport.Measure measure = BatchReport.Measure.newBuilder() + .setValueType(DOUBLE) + .setIntValue(3) + .build(); + + checkMeasure(measure); + } + + @Test + public void validate_all_value_type_without_exception_thrown() throws Exception { + checkMeasure(newBuilder().setValueType(STRING).setStringValue("string-value").build()); + checkMeasure(newBuilder().setValueType(DOUBLE).setDoubleValue(1.0d).build()); + checkMeasure(newBuilder().setValueType(Constants.MeasureValueType.INT).setIntValue(1).build()); + checkMeasure(newBuilder().setValueType(Constants.MeasureValueType.LONG).setLongValue(2L).build()); + checkMeasure(newBuilder().setValueType(BOOLEAN).setBooleanValue(true).build()); + } + + @Test + public void value_type_as_double_correct_for_all_numerical_types() throws Exception { + assertThat(valueAsDouble(newBuilder().setBooleanValue(true).setValueType(BOOLEAN).build())).isEqualTo(1.0d); + assertThat(valueAsDouble(newBuilder().setIntValue(2).setValueType(INT).build())).isEqualTo(2.0d); + assertThat(valueAsDouble(newBuilder().setLongValue(3L).setValueType(LONG).build())).isEqualTo(3.0d); + assertThat(valueAsDouble(newBuilder().setDoubleValue(4.4d).setValueType(DOUBLE).build())).isEqualTo(4.4d); + } + + private BatchReport.Measure.Builder newBuilder() { + return BatchReport.Measure.newBuilder().setMetricKey("repo:metric-key"); + } +} \ No newline at end of file diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MetricCacheTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MetricCacheTest.java new file mode 100644 index 000000000000..38f61abee62d --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MetricCacheTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.computation.measure; + +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.sonar.core.persistence.DbTester; +import org.sonar.server.db.DbClient; +import org.sonar.server.exceptions.NotFoundException; +import org.sonar.server.measure.persistence.MetricDao; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MetricCacheTest { + + @ClassRule + public static DbTester db = new DbTester(); + + MetricCache sut; + + @Before + public void setUp() throws Exception { + db.prepareDbUnit(getClass(), "metrics.xml"); + sut = new MetricCache(new DbClient(db.database(), db.myBatis(), new MetricDao())); + } + + @Test + public void cache_give_access_to_enabled_metrics() throws Exception { + assertThat(sut.get("ncloc").getId()).isEqualTo(1); + assertThat(sut.get("coverage").getId()).isEqualTo(2); + } + + @Test(expected = NotFoundException.class) + public void fail_when_metric_not_found() throws Exception { + sut.get("complexity"); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java index 696ce5e65554..06f7580a42c7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java @@ -44,12 +44,13 @@ public void ordered_steps() throws Exception { mock(SendIssueNotificationsStep.class), mock(IndexComponentsStep.class), mock(PersistComponentLinksStep.class), + mock(PersistMeasuresStep.class), mock(PersistEventsStep.class) ); - assertThat(registry.orderedSteps()).hasSize(13); + assertThat(registry.orderedSteps()).hasSize(14); assertThat(registry.orderedSteps().get(0)).isInstanceOf(ParseReportStep.class); - assertThat(registry.orderedSteps().get(12)).isInstanceOf(SendIssueNotificationsStep.class); + assertThat(registry.orderedSteps().get(13)).isInstanceOf(SendIssueNotificationsStep.class); } @Test 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 new file mode 100644 index 000000000000..0e5aea549c77 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java @@ -0,0 +1,234 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.sonar.server.computation.step; + +import org.assertj.core.data.Offset; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +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.batch.protocol.output.BatchReportReader; +import org.sonar.batch.protocol.output.BatchReportWriter; +import org.sonar.core.component.ComponentDto; +import org.sonar.core.measure.db.MeasureDto; +import org.sonar.core.persistence.DbSession; +import org.sonar.server.computation.ComputationContext; +import org.sonar.server.computation.issue.RuleCache; +import org.sonar.server.computation.measure.MetricCache; +import org.sonar.server.db.DbClient; +import org.sonar.server.measure.persistence.MeasureDao; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.*; + +public class PersistMeasuresStepTest extends BaseStepTest { + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + DbClient dbClient; + RuleCache ruleCache; + MetricCache metricCache; + MeasureDao measureDao; + + PersistMeasuresStep sut; + + @Before + public void setUp() throws Exception { + dbClient = mock(DbClient.class, Mockito.RETURNS_DEEP_STUBS); + ruleCache = mock(RuleCache.class, Mockito.RETURNS_DEEP_STUBS); + metricCache = mock(MetricCache.class, Mockito.RETURNS_DEEP_STUBS); + when(metricCache.get("metric-key").getId()).thenReturn(654); + measureDao = mock(MeasureDao.class); + when(ruleCache.get(any(RuleKey.class)).getId()).thenReturn(987); + + sut = new PersistMeasuresStep(dbClient, ruleCache, metricCache); + } + + @Test + public void insert_measures_from_report() throws Exception { + File dir = temp.newFolder(); + BatchReportWriter report = new BatchReportWriter(dir); + + when(dbClient.measureDao()).thenReturn(measureDao); + + report.writeMetadata(BatchReport.Metadata.newBuilder() + .setAnalysisDate(new Date().getTime()) + .setRootComponentRef(1) + .setProjectKey("project-key") + .setSnapshotId(3) + .build()); + + report.writeComponent(defaultComponent() + .addChildRef(2) + .build()); + report.writeComponent( + defaultComponent() + .setRef(2) + .build()); + + report.writeComponentMeasures(1, Arrays.asList( + BatchReport.Measure.newBuilder() + .setValueType(Constants.MeasureValueType.STRING) + .setStringValue("measure-data") + .setTendency(2) + .setVariationValue1(1.1d) + .setVariationValue2(2.2d) + .setVariationValue3(3.3d) + .setVariationValue4(4.4d) + .setVariationValue5(5.5d) + .setAlertStatus("measure-alert-status") + .setAlertText("measure-alert-text") + .setDescription("measure-description") + .setSeverity(Constants.Severity.INFO) + .setMetricKey("metric-key") + .setRuleKey("repo:rule-key") + .setCharactericId(123456) + .build())); + + report.writeComponentMeasures(2, Arrays.asList( + BatchReport.Measure.newBuilder() + .setValueType(Constants.MeasureValueType.DOUBLE) + .setDoubleValue(123.123d) + .setTendency(2) + .setVariationValue1(1.1d) + .setVariationValue2(2.2d) + .setVariationValue3(3.3d) + .setVariationValue4(4.4d) + .setVariationValue5(5.5d) + .setAlertStatus("measure-alert-status") + .setAlertText("measure-alert-text") + .setDescription("measure-description") + .setSeverity(Constants.Severity.BLOCKER) + .setMetricKey("metric-key") + .setRuleKey("repo:rule-key") + .setCharactericId(123456) + .build())); + + sut.execute(new ComputationContext(new BatchReportReader(dir), mock(ComponentDto.class))); + + ArgumentCaptor argument = ArgumentCaptor.forClass(MeasureDto.class); + verify(measureDao, times(2)).insert(any(DbSession.class), argument.capture()); + assertThat(argument.getValue().getValue()).isEqualTo(123.123d, Offset.offset(0.0001d)); + assertThat(argument.getValue().getMetricId()).isEqualTo(654); + assertThat(argument.getValue().getRuleId()).isEqualTo(987); + assertThat(argument.getValue().getSeverity()).isEqualTo(Severity.BLOCKER); + } + + private BatchReport.Component.Builder defaultComponent() { + return BatchReport.Component.newBuilder() + .setRef(1) + .setId(2) + .setSnapshotId(3); + } + + @Test + public void map_full_batch_measure() throws Exception { + BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + .setValueType(Constants.MeasureValueType.DOUBLE) + .setDoubleValue(123.123d) + .setTendency(2) + .setVariationValue1(1.1d) + .setVariationValue2(2.2d) + .setVariationValue3(3.3d) + .setVariationValue4(4.4d) + .setVariationValue5(5.5d) + .setAlertStatus("measure-alert-status") + .setAlertText("measure-alert-text") + .setDescription("measure-description") + .setSeverity(Constants.Severity.CRITICAL) + .setMetricKey("metric-key") + .setRuleKey("repo:rule-key") + .setCharactericId(123456) + .build(); + + BatchReport.Component component = defaultComponent().build(); + + MeasureDto measure = sut.toMeasureDto(batchMeasure, component); + + assertThat(measure).isEqualToComparingFieldByField(expectedFullMeasure()); + } + + @Test + public void map_minimal_batch_measure() throws Exception { + BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() + .setValueType(Constants.MeasureValueType.INT) + .setIntValue(123) + .setSeverity(Constants.Severity.INFO) + .setMetricKey("metric-key") + .setRuleKey("repo:rule-key") + .build(); + + BatchReport.Component component = defaultComponent() + .build(); + + MeasureDto measure = sut.toMeasureDto(batchMeasure, component); + + assertThat(measure).isEqualToComparingFieldByField(expectedMinimalistMeasure()); + } + + private MeasureDto expectedFullMeasure() { + return new MeasureDto() + .setComponentId(2L) + .setSnapshotId(3L) + .setCharacteristicId(123456) + .setValue(123.123d) + .setTendency(2) + .setVariation(1, 1.1d) + .setVariation(2, 2.2d) + .setVariation(3, 3.3d) + .setVariation(4, 4.4d) + .setVariation(5, 5.5d) + .setAlertStatus("measure-alert-status") + .setAlertText("measure-alert-text") + .setDescription("measure-description") + .setSeverity(Severity.CRITICAL) + .setMetricId(654) + .setRuleId(987); + } + + private MeasureDto expectedMinimalistMeasure() { + return new MeasureDto() + .setComponentId(2L) + .setSnapshotId(3L) + .setValue(123d) + .setSeverity(Severity.INFO) + .setMetricId(654) + .setRuleId(987); + } + + @Override + protected ComputationStep step() throws IOException { + return sut; + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java index 7fc53c3acc0a..db137bb750e9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java @@ -31,7 +31,6 @@ import org.sonar.api.web.UserRole; import org.sonar.core.component.ComponentDto; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.server.component.db.ComponentDao; import org.sonar.server.db.DbClient; @@ -86,10 +85,9 @@ public void show_duplications() throws Exception { when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto); String data = "{duplications}"; - MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY); - when(measureDao.getNullableByKey(session, measureKey)).thenReturn( - MeasureDto.createFor(measureKey).setTextValue("{duplications}") - ); + when(measureDao.findByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn( + new MeasureDto().setComponentKey(componentKey).setMetricKey(CoreMetrics.DUPLICATIONS_DATA_KEY).setData("{duplications}") + ); List blocks = newArrayList(new DuplicationsParser.Block(newArrayList(new DuplicationsParser.Duplication(componentDto, 1, 2)))); when(parser.parse(componentDto, data, session)).thenReturn(blocks); @@ -112,9 +110,8 @@ public void show_duplications_by_uuid() throws Exception { when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto); String data = "{duplications}"; - MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY); - when(measureDao.getNullableByKey(session, measureKey)).thenReturn( - MeasureDto.createFor(measureKey).setTextValue("{duplications}") + when(measureDao.findByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn( + new MeasureDto().setComponentKey(componentKey).setMetricKey(CoreMetrics.DUPLICATIONS_DATA_KEY).setData("{duplications}") ); List blocks = newArrayList(new DuplicationsParser.Block(newArrayList(new DuplicationsParser.Duplication(componentDto, 1, 2)))); @@ -134,8 +131,7 @@ public void no_duplications_when_no_data() throws Exception { ComponentDto componentDto = new ComponentDto().setId(10L); when(componentDao.getNullableByKey(session, componentKey)).thenReturn(componentDto); - MeasureKey measureKey = MeasureKey.of(componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY); - when(measureDao.getNullableByKey(session, measureKey)).thenReturn(null); + when(measureDao.findByComponentKeyAndMetricKey(session, componentKey, CoreMetrics.DUPLICATIONS_DATA_KEY)).thenReturn(null); WsTester.TestRequest request = tester.newGetRequest("api/duplications", "show").setParam("key", componentKey); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java index 4f1260a0ad8e..d37060f1b1a2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java @@ -22,28 +22,33 @@ import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -import org.sonar.api.utils.System2; +import org.junit.experimental.categories.Category; +import org.sonar.api.rule.Severity; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; -import org.sonar.core.persistence.AbstractDaoTestCase; import org.sonar.core.persistence.DbSession; +import org.sonar.core.persistence.DbTester; +import org.sonar.test.DbTests; import java.util.List; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; -public class MeasureDaoTest extends AbstractDaoTestCase { +@Category(DbTests.class) +public class MeasureDaoTest { - DbSession session; + @Rule + public DbTester db = new DbTester(); - MeasureDao dao; + DbSession session; + MeasureDao sut; @Before - public void createDao() { - session = getMyBatis().openSession(false); - dao = new MeasureDao(System2.INSTANCE); + public void setUp() { + session = db.myBatis().openSession(false); + sut = new MeasureDao(); } @After @@ -53,46 +58,48 @@ public void tearDown() throws Exception { @Test public void get_value_by_key() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = dao.getNullableByKey(session, MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")); + MeasureDto result = sut.findByComponentKeyAndMetricKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); } @Test + // TODO the string must be longer than 4000 char to be persisted in the data field public void get_data_by_key() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = dao.getNullableByKey(session, MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line")); + MeasureDto result = sut.findByComponentKeyAndMetricKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "authors_by_line"); assertThat(result.getId()).isEqualTo(20); assertThat(result.getData()).isEqualTo("0123456789012345678901234567890123456789"); } @Test public void get_text_value_by_key() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = dao.getNullableByKey(session, MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data")); + MeasureDto result = sut.findByComponentKeyAndMetricKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "coverage_line_hits_data"); assertThat(result.getId()).isEqualTo(21); assertThat(result.getData()).isEqualTo("36=1;37=1;38=1;39=1;43=1;48=1;53=1"); } @Test public void find_by_component_key_and_metrics() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); - List results = dao.findByComponentKeyAndMetricKeys("org.struts:struts-core:src/org/struts/RequestContext.java", - newArrayList("ncloc", "authors_by_line"), session); + List results = sut.findByComponentKeyAndMetricKeys(session, "org.struts:struts-core:src/org/struts/RequestContext.java", + newArrayList("ncloc", "authors_by_line")); assertThat(results).hasSize(2); - results = dao.findByComponentKeyAndMetricKeys("org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc"), session); + results = sut.findByComponentKeyAndMetricKeys(session, "org.struts:struts-core:src/org/struts/RequestContext.java", newArrayList("ncloc")); assertThat(results).hasSize(1); MeasureDto result = results.get(0); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); - assertThat(result.getKey()).isEqualTo(MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")); + assertThat(result.getComponentKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); + assertThat(result.getMetricKey()).isEqualTo("ncloc"); assertThat(result.getVariation(1)).isEqualTo(1d); assertThat(result.getVariation(2)).isEqualTo(2d); assertThat(result.getVariation(3)).isEqualTo(3d); @@ -102,31 +109,55 @@ public void find_by_component_key_and_metrics() throws Exception { @Test public void find_by_component_key_and_metric() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); - MeasureDto result = dao.findByComponentKeyAndMetricKey("org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc", session); + MeasureDto result = sut.findByComponentKeyAndMetricKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"); assertThat(result.getId()).isEqualTo(22); assertThat(result.getValue()).isEqualTo(10d); - assertThat(result.getKey()).isEqualTo(MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")); + assertThat(result.getMetricKey()).isEqualTo("ncloc"); + assertThat(result.getComponentKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(result.getVariation(1)).isEqualTo(1d); assertThat(result.getVariation(2)).isEqualTo(2d); assertThat(result.getVariation(3)).isEqualTo(3d); assertThat(result.getVariation(4)).isEqualTo(4d); assertThat(result.getVariation(5)).isEqualTo(-5d); - assertThat(dao.findByComponentKeyAndMetricKey("org.struts:struts-core:src/org/struts/RequestContext.java", "unknown", session)).isNull(); + assertThat(sut.findByComponentKeyAndMetricKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isNull(); } @Test public void exists_by_key() throws Exception { - setupData("shared"); + db.prepareDbUnit(getClass(), "shared.xml"); - assertThat(dao.existsByKey(MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"), session)).isTrue(); - assertThat(dao.existsByKey(MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "unknown"), session)).isFalse(); + assertThat(sut.existsByKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc")).isTrue(); + assertThat(sut.existsByKey(session, "org.struts:struts-core:src/org/struts/RequestContext.java", "unknown")).isFalse(); } - @Test(expected = IllegalStateException.class) + @Test public void insert() throws Exception { - dao.insert(session, MeasureDto.createFor(MeasureKey.of("org.struts:struts-core:src/org/struts/RequestContext.java", "ncloc"))); + db.prepareDbUnit(getClass(), "empty.xml"); + + sut.insert(session, new MeasureDto() + .setSnapshotId(2L) + .setMetricId(3) + .setCharacteristicId(4) + .setRuleId(5) + .setComponentId(6L) + .setValue(2.0d) + .setData("measure-value") + .setTendency(42) + .setSeverity(Severity.INFO) + .setVariation(1, 1.0d) + .setVariation(2, 2.0d) + .setVariation(3, 3.0d) + .setVariation(4, 4.0d) + .setVariation(5, 5.0d) + .setAlertStatus("alert") + .setAlertText("alert-text") + .setDescription("measure-description") + ); + session.commit(); + + db.assertDbUnit(getClass(), "insert-result.xml", "project_measures"); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/SourceServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/SourceServiceTest.java index 77c359e228c3..468f6cdd89b7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/source/SourceServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/source/SourceServiceTest.java @@ -27,7 +27,6 @@ import org.mockito.runners.MockitoJUnitRunner; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.web.UserRole; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.server.db.DbClient; import org.sonar.server.exceptions.ForbiddenException; @@ -41,31 +40,23 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) public class SourceServiceTest { + static final String PROJECT_KEY = "org.sonar.sample"; + static final String COMPONENT_UUID = "abc123"; @Mock DbSession session; - @Mock HtmlSourceDecorator sourceDecorator; - @Mock MeasureDao measureDao; - @Mock SourceLineIndex sourceLineIndex; - - static final String PROJECT_KEY = "org.sonar.sample"; - static final String COMPONENT_UUID = "abc123"; - SourceService service; @Before @@ -104,7 +95,7 @@ public void get_block_of_lines() throws Exception { @Test public void get_scm_author_data() throws Exception { service.getScmAuthorData(COMPONENT_UUID); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_UUID, CoreMetrics.SCM_AUTHORS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_UUID, CoreMetrics.SCM_AUTHORS_BY_LINE_KEY); } @Test @@ -122,7 +113,7 @@ public void fail_to_get_scm_author_data_if_no_permission() throws Exception { @Test public void not_get_scm_author_data_if_no_data() throws Exception { MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, PROJECT_KEY, COMPONENT_UUID); - when(measureDao.getNullableByKey(eq(session), any(MeasureKey.class))).thenReturn(null); + when(measureDao.findByComponentKeyAndMetricKey(eq(session), anyString(), anyString())).thenReturn(null); assertThat(service.getScmAuthorData(COMPONENT_UUID)).isNull(); } @@ -130,13 +121,13 @@ public void not_get_scm_author_data_if_no_data() throws Exception { public void get_scm_date_data() throws Exception { MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, PROJECT_KEY, COMPONENT_UUID); service.getScmDateData(COMPONENT_UUID); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_UUID, CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_UUID, CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY); } @Test public void not_get_scm_date_data_if_no_data() throws Exception { MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, PROJECT_KEY, COMPONENT_UUID); - when(measureDao.getNullableByKey(eq(session), any(MeasureKey.class))).thenReturn(null); + when(measureDao.findByComponentKeyAndMetricKey(eq(session), anyString(), anyString())).thenReturn(null); assertThat(service.getScmDateData(COMPONENT_UUID)).isNull(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java index 7bf569fe196d..e514c411f6bf 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/test/CoverageServiceTest.java @@ -30,7 +30,6 @@ import org.sonar.api.test.MutableTestable; import org.sonar.api.web.UserRole; import org.sonar.core.component.SnapshotPerspectives; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.MyBatis; import org.sonar.server.measure.persistence.MeasureDao; @@ -45,20 +44,15 @@ @RunWith(MockitoJUnitRunner.class) public class CoverageServiceTest { + static final String COMPONENT_KEY = "org.sonar.sample:Sample"; @org.junit.Rule public ExpectedException thrown = ExpectedException.none(); - @Mock DbSession session; - @Mock MeasureDao measureDao; - @Mock SnapshotPerspectives snapshotPerspectives; - - static final String COMPONENT_KEY = "org.sonar.sample:Sample"; - CoverageService service; @Before @@ -79,43 +73,43 @@ public void check_permission() throws Exception { @Test public void get_hits_data() throws Exception { service.getHits(COMPONENT_KEY, CoverageService.TYPE.UT); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY); service.getHits(COMPONENT_KEY, CoverageService.TYPE.IT); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY); service.getHits(COMPONENT_KEY, CoverageService.TYPE.OVERALL); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA_KEY); } @Test public void not_get_hits_data_if_no_data() throws Exception { - when(measureDao.getNullableByKey(eq(session), any(MeasureKey.class))).thenReturn(null); + when(measureDao.findByComponentKeyAndMetricKey(eq(session), anyString(), anyString())).thenReturn(null); assertThat(service.getHits(COMPONENT_KEY, CoverageService.TYPE.UT)).isEqualTo(Collections.emptyMap()); } @Test public void get_conditions_data() throws Exception { service.getConditions(COMPONENT_KEY, CoverageService.TYPE.UT); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.CONDITIONS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.CONDITIONS_BY_LINE_KEY); service.getConditions(COMPONENT_KEY, CoverageService.TYPE.IT); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY); service.getConditions(COMPONENT_KEY, CoverageService.TYPE.OVERALL); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.OVERALL_CONDITIONS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_CONDITIONS_BY_LINE_KEY); } @Test public void get_covered_conditions_data() throws Exception { service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.UT); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY); service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.IT); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY); service.getCoveredConditions(COMPONENT_KEY, CoverageService.TYPE.OVERALL); - verify(measureDao).getNullableByKey(session, MeasureKey.of(COMPONENT_KEY, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY)); + verify(measureDao).findByComponentKeyAndMetricKey(session, COMPONENT_KEY, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/ws/TestsShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/ws/TestsShowActionTest.java index 9f7648e975a6..0c1117c3fef9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/test/ws/TestsShowActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/test/ws/TestsShowActionTest.java @@ -31,7 +31,6 @@ import org.sonar.api.web.UserRole; import org.sonar.core.component.SnapshotPerspectives; import org.sonar.core.measure.db.MeasureDto; -import org.sonar.core.measure.db.MeasureKey; import org.sonar.core.persistence.DbSession; import org.sonar.server.db.DbClient; import org.sonar.server.measure.persistence.MeasureDao; @@ -96,8 +95,10 @@ public void show() throws Exception { public void show_from_test_data() throws Exception { MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "SonarQube", TEST_PLAN_KEY); - when(measureDao.findByComponentKeyAndMetricKey(TEST_PLAN_KEY, "test_data", session)).thenReturn(MeasureDto.createFor(MeasureKey.of(TEST_PLAN_KEY, "test_data")) - .setTextValue("" + + when(measureDao.findByComponentKeyAndMetricKey(session, TEST_PLAN_KEY, "test_data")).thenReturn(new MeasureDto() + .setComponentKey(TEST_PLAN_KEY) + .setMetricKey("test_data") + .setData("" + "" + "" + "" + @@ -121,10 +122,13 @@ public void show_from_test_data() throws Exception { public void show_from_test_data_with_a_time_in_float() throws Exception { MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "SonarQube", TEST_PLAN_KEY); - when(measureDao.findByComponentKeyAndMetricKey(TEST_PLAN_KEY, "test_data", session)).thenReturn(MeasureDto.createFor(MeasureKey.of(TEST_PLAN_KEY, "test_data")) - .setTextValue("" + - "" + - "")); + when(measureDao.findByComponentKeyAndMetricKey(session, TEST_PLAN_KEY, "test_data")).thenReturn( + new MeasureDto() + .setComponentKey(TEST_PLAN_KEY) + .setMetricKey("test_data") + .setData("" + + "" + + "")); WsTester.TestRequest request = tester.newGetRequest("api/tests", "show").setParam("key", TEST_PLAN_KEY); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MetricCacheTest/metrics.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MetricCacheTest/metrics.xml new file mode 100644 index 000000000000..dcfc8850a1c0 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/measure/MetricCacheTest/metrics.xml @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistMeasuresStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistMeasuresStepTest/shared.xml new file mode 100644 index 000000000000..e9cb4686ecd7 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistMeasuresStepTest/shared.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/empty.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/empty.xml new file mode 100644 index 000000000000..dda188295671 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/empty.xml @@ -0,0 +1,3 @@ + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml new file mode 100644 index 000000000000..6714a2ad41c5 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml @@ -0,0 +1,27 @@ + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/shared.xml index 041ca607f351..a82f76dd7707 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/shared.xml @@ -8,7 +8,7 @@ - diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/Constants.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/Constants.java index 0c5b89652161..fe5456aaf32c 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/Constants.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/Constants.java @@ -235,6 +235,115 @@ private ComponentType(int index, int value) { // @@protoc_insertion_point(enum_scope:ComponentType) } + /** + * Protobuf enum {@code MeasureValueType} + */ + public enum MeasureValueType + implements com.google.protobuf.ProtocolMessageEnum { + /** + * INT = 0; + */ + INT(0, 0), + /** + * LONG = 1; + */ + LONG(1, 1), + /** + * DOUBLE = 2; + */ + DOUBLE(2, 2), + /** + * BOOLEAN = 3; + */ + BOOLEAN(3, 3), + /** + * STRING = 4; + */ + STRING(4, 4), + ; + + /** + * INT = 0; + */ + public static final int INT_VALUE = 0; + /** + * LONG = 1; + */ + public static final int LONG_VALUE = 1; + /** + * DOUBLE = 2; + */ + public static final int DOUBLE_VALUE = 2; + /** + * BOOLEAN = 3; + */ + public static final int BOOLEAN_VALUE = 3; + /** + * STRING = 4; + */ + public static final int STRING_VALUE = 4; + + + public final int getNumber() { return value; } + + public static MeasureValueType valueOf(int value) { + switch (value) { + case 0: return INT; + case 1: return LONG; + case 2: return DOUBLE; + case 3: return BOOLEAN; + case 4: return STRING; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public MeasureValueType findValueByNumber(int number) { + return MeasureValueType.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return org.sonar.batch.protocol.Constants.getDescriptor().getEnumTypes().get(2); + } + + private static final MeasureValueType[] VALUES = values(); + + public static MeasureValueType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private MeasureValueType(int index, int value) { + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:MeasureValueType) + } + /** * Protobuf enum {@code EventCategory} * @@ -296,7 +405,7 @@ public EventCategory findValueByNumber(int number) { } public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return org.sonar.batch.protocol.Constants.getDescriptor().getEnumTypes().get(2); + return org.sonar.batch.protocol.Constants.getDescriptor().getEnumTypes().get(3); } private static final EventCategory[] VALUES = values(); @@ -405,7 +514,7 @@ public ComponentLinkType findValueByNumber(int number) { } public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return org.sonar.batch.protocol.Constants.getDescriptor().getEnumTypes().get(3); + return org.sonar.batch.protocol.Constants.getDescriptor().getEnumTypes().get(4); } private static final ComponentLinkType[] VALUES = values(); @@ -443,20 +552,21 @@ private ComponentLinkType(int index, int value) { "\t\n\005MINOR\020\001\022\t\n\005MAJOR\020\002\022\014\n\010CRITICAL\020\003\022\013\n\007B" + "LOCKER\020\004*X\n\rComponentType\022\013\n\007PROJECT\020\000\022\n" + "\n\006MODULE\020\001\022\r\n\tDIRECTORY\020\002\022\010\n\004FILE\020\003\022\010\n\004V" + - "IEW\020\004\022\013\n\007SUBVIEW\020\005*\'\n\rEventCategory\022\t\n\005A" + - "LERT\020\000\022\013\n\007PROFILE\020\001*F\n\021ComponentLinkType" + - "\022\010\n\004HOME\020\000\022\007\n\003SCM\020\001\022\013\n\007SCM_DEV\020\002\022\t\n\005ISSU" + - "E\020\003\022\006\n\002CI\020\004B\034\n\030org.sonar.batch.protocolH" + - "\001" + "IEW\020\004\022\013\n\007SUBVIEW\020\005*J\n\020MeasureValueType\022\007" + + "\n\003INT\020\000\022\010\n\004LONG\020\001\022\n\n\006DOUBLE\020\002\022\013\n\007BOOLEAN" + + "\020\003\022\n\n\006STRING\020\004*\'\n\rEventCategory\022\t\n\005ALERT" + + "\020\000\022\013\n\007PROFILE\020\001*F\n\021ComponentLinkType\022\010\n\004" + + "HOME\020\000\022\007\n\003SCM\020\001\022\013\n\007SCM_DEV\020\002\022\t\n\005ISSUE\020\003\022" + + "\006\n\002CI\020\004B\034\n\030org.sonar.batch.protocolH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/input/BatchInput.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/input/BatchInput.java index 6ecbcc83d312..464e4d9bb03a 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/input/BatchInput.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/input/BatchInput.java @@ -8,10 +8,10 @@ private BatchInput() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { } - public interface ServerIssueOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface ServerIssueOrBuilder extends + // @@protoc_insertion_point(interface_extends:ServerIssue) + com.google.protobuf.MessageOrBuilder { - // optional string key = 1; /** * optional string key = 1; */ @@ -26,7 +26,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getKeyBytes(); - // optional string module_key = 2; /** * optional string module_key = 2; */ @@ -41,7 +40,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getModuleKeyBytes(); - // optional string path = 3; /** * optional string path = 3; */ @@ -56,7 +54,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getPathBytes(); - // optional string rule_repository = 4; /** * optional string rule_repository = 4; */ @@ -71,7 +68,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getRuleRepositoryBytes(); - // optional string rule_key = 5; /** * optional string rule_key = 5; */ @@ -86,7 +82,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getRuleKeyBytes(); - // optional int32 line = 6; /** * optional int32 line = 6; */ @@ -96,7 +91,6 @@ public interface ServerIssueOrBuilder */ int getLine(); - // optional string msg = 7; /** * optional string msg = 7; */ @@ -111,7 +105,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getMsgBytes(); - // optional .Severity severity = 8; /** * optional .Severity severity = 8; */ @@ -121,7 +114,6 @@ public interface ServerIssueOrBuilder */ org.sonar.batch.protocol.Constants.Severity getSeverity(); - // optional bool manual_severity = 9; /** * optional bool manual_severity = 9; */ @@ -131,7 +123,6 @@ public interface ServerIssueOrBuilder */ boolean getManualSeverity(); - // optional string resolution = 10; /** * optional string resolution = 10; */ @@ -146,7 +137,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getResolutionBytes(); - // optional string status = 11; /** * optional string status = 11; */ @@ -161,7 +151,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getStatusBytes(); - // optional string checksum = 12; /** * optional string checksum = 12; */ @@ -176,7 +165,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getChecksumBytes(); - // optional string assignee_login = 13; /** * optional string assignee_login = 13; */ @@ -191,7 +179,6 @@ public interface ServerIssueOrBuilder com.google.protobuf.ByteString getAssigneeLoginBytes(); - // optional int64 creation_date = 14; /** * optional int64 creation_date = 14; */ @@ -205,8 +192,9 @@ public interface ServerIssueOrBuilder * Protobuf type {@code ServerIssue} */ public static final class ServerIssue extends - com.google.protobuf.GeneratedMessage - implements ServerIssueOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:ServerIssue) + ServerIssueOrBuilder { // Use ServerIssue.newBuilder() to construct. private ServerIssue(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -253,28 +241,33 @@ private ServerIssue( break; } case 10: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000001; - key_ = input.readBytes(); + key_ = bs; break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - moduleKey_ = input.readBytes(); + moduleKey_ = bs; break; } case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000004; - path_ = input.readBytes(); + path_ = bs; break; } case 34: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000008; - ruleRepository_ = input.readBytes(); + ruleRepository_ = bs; break; } case 42: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000010; - ruleKey_ = input.readBytes(); + ruleKey_ = bs; break; } case 48: { @@ -283,8 +276,9 @@ private ServerIssue( break; } case 58: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000040; - msg_ = input.readBytes(); + msg_ = bs; break; } case 64: { @@ -304,23 +298,27 @@ private ServerIssue( break; } case 82: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000200; - resolution_ = input.readBytes(); + resolution_ = bs; break; } case 90: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000400; - status_ = input.readBytes(); + status_ = bs; break; } case 98: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000800; - checksum_ = input.readBytes(); + checksum_ = bs; break; } case 106: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00001000; - assigneeLogin_ = input.readBytes(); + assigneeLogin_ = bs; break; } case 112: { @@ -368,7 +366,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional string key = 1; public static final int KEY_FIELD_NUMBER = 1; private java.lang.Object key_; /** @@ -411,7 +408,6 @@ public java.lang.String getKey() { } } - // optional string module_key = 2; public static final int MODULE_KEY_FIELD_NUMBER = 2; private java.lang.Object moduleKey_; /** @@ -454,7 +450,6 @@ public java.lang.String getModuleKey() { } } - // optional string path = 3; public static final int PATH_FIELD_NUMBER = 3; private java.lang.Object path_; /** @@ -497,7 +492,6 @@ public java.lang.String getPath() { } } - // optional string rule_repository = 4; public static final int RULE_REPOSITORY_FIELD_NUMBER = 4; private java.lang.Object ruleRepository_; /** @@ -540,7 +534,6 @@ public java.lang.String getRuleRepository() { } } - // optional string rule_key = 5; public static final int RULE_KEY_FIELD_NUMBER = 5; private java.lang.Object ruleKey_; /** @@ -583,7 +576,6 @@ public java.lang.String getRuleKey() { } } - // optional int32 line = 6; public static final int LINE_FIELD_NUMBER = 6; private int line_; /** @@ -599,7 +591,6 @@ public int getLine() { return line_; } - // optional string msg = 7; public static final int MSG_FIELD_NUMBER = 7; private java.lang.Object msg_; /** @@ -642,7 +633,6 @@ public java.lang.String getMsg() { } } - // optional .Severity severity = 8; public static final int SEVERITY_FIELD_NUMBER = 8; private org.sonar.batch.protocol.Constants.Severity severity_; /** @@ -658,7 +648,6 @@ public org.sonar.batch.protocol.Constants.Severity getSeverity() { return severity_; } - // optional bool manual_severity = 9; public static final int MANUAL_SEVERITY_FIELD_NUMBER = 9; private boolean manualSeverity_; /** @@ -674,7 +663,6 @@ public boolean getManualSeverity() { return manualSeverity_; } - // optional string resolution = 10; public static final int RESOLUTION_FIELD_NUMBER = 10; private java.lang.Object resolution_; /** @@ -717,7 +705,6 @@ public java.lang.String getResolution() { } } - // optional string status = 11; public static final int STATUS_FIELD_NUMBER = 11; private java.lang.Object status_; /** @@ -760,7 +747,6 @@ public java.lang.String getStatus() { } } - // optional string checksum = 12; public static final int CHECKSUM_FIELD_NUMBER = 12; private java.lang.Object checksum_; /** @@ -803,7 +789,6 @@ public java.lang.String getChecksum() { } } - // optional string assignee_login = 13; public static final int ASSIGNEE_LOGIN_FIELD_NUMBER = 13; private java.lang.Object assigneeLogin_; /** @@ -846,7 +831,6 @@ public java.lang.String getAssigneeLogin() { } } - // optional int64 creation_date = 14; public static final int CREATION_DATE_FIELD_NUMBER = 14; private long creationDate_; /** @@ -881,7 +865,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -1079,8 +1064,9 @@ protected Builder newBuilderForType( * Protobuf type {@code ServerIssue} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.input.BatchInput.ServerIssueOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:ServerIssue) + org.sonar.batch.protocol.input.BatchInput.ServerIssueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.input.BatchInput.internal_static_ServerIssue_descriptor; @@ -1330,7 +1316,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional string key = 1; private java.lang.Object key_ = ""; /** * optional string key = 1; @@ -1344,9 +1329,12 @@ public boolean hasKey() { public java.lang.String getKey() { java.lang.Object ref = key_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - key_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1404,7 +1392,6 @@ public Builder setKeyBytes( return this; } - // optional string module_key = 2; private java.lang.Object moduleKey_ = ""; /** * optional string module_key = 2; @@ -1418,9 +1405,12 @@ public boolean hasModuleKey() { public java.lang.String getModuleKey() { java.lang.Object ref = moduleKey_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - moduleKey_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + moduleKey_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1478,7 +1468,6 @@ public Builder setModuleKeyBytes( return this; } - // optional string path = 3; private java.lang.Object path_ = ""; /** * optional string path = 3; @@ -1492,9 +1481,12 @@ public boolean hasPath() { public java.lang.String getPath() { java.lang.Object ref = path_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - path_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + path_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1552,7 +1544,6 @@ public Builder setPathBytes( return this; } - // optional string rule_repository = 4; private java.lang.Object ruleRepository_ = ""; /** * optional string rule_repository = 4; @@ -1566,9 +1557,12 @@ public boolean hasRuleRepository() { public java.lang.String getRuleRepository() { java.lang.Object ref = ruleRepository_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - ruleRepository_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ruleRepository_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1626,7 +1620,6 @@ public Builder setRuleRepositoryBytes( return this; } - // optional string rule_key = 5; private java.lang.Object ruleKey_ = ""; /** * optional string rule_key = 5; @@ -1640,9 +1633,12 @@ public boolean hasRuleKey() { public java.lang.String getRuleKey() { java.lang.Object ref = ruleKey_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - ruleKey_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ruleKey_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1700,7 +1696,6 @@ public Builder setRuleKeyBytes( return this; } - // optional int32 line = 6; private int line_ ; /** * optional int32 line = 6; @@ -1733,7 +1728,6 @@ public Builder clearLine() { return this; } - // optional string msg = 7; private java.lang.Object msg_ = ""; /** * optional string msg = 7; @@ -1747,9 +1741,12 @@ public boolean hasMsg() { public java.lang.String getMsg() { java.lang.Object ref = msg_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - msg_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + msg_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1807,7 +1804,6 @@ public Builder setMsgBytes( return this; } - // optional .Severity severity = 8; private org.sonar.batch.protocol.Constants.Severity severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; /** * optional .Severity severity = 8; @@ -1843,7 +1839,6 @@ public Builder clearSeverity() { return this; } - // optional bool manual_severity = 9; private boolean manualSeverity_ ; /** * optional bool manual_severity = 9; @@ -1876,7 +1871,6 @@ public Builder clearManualSeverity() { return this; } - // optional string resolution = 10; private java.lang.Object resolution_ = ""; /** * optional string resolution = 10; @@ -1890,9 +1884,12 @@ public boolean hasResolution() { public java.lang.String getResolution() { java.lang.Object ref = resolution_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - resolution_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + resolution_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1950,7 +1947,6 @@ public Builder setResolutionBytes( return this; } - // optional string status = 11; private java.lang.Object status_ = ""; /** * optional string status = 11; @@ -1964,9 +1960,12 @@ public boolean hasStatus() { public java.lang.String getStatus() { java.lang.Object ref = status_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - status_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + status_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2024,7 +2023,6 @@ public Builder setStatusBytes( return this; } - // optional string checksum = 12; private java.lang.Object checksum_ = ""; /** * optional string checksum = 12; @@ -2038,9 +2036,12 @@ public boolean hasChecksum() { public java.lang.String getChecksum() { java.lang.Object ref = checksum_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - checksum_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + checksum_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2098,7 +2099,6 @@ public Builder setChecksumBytes( return this; } - // optional string assignee_login = 13; private java.lang.Object assigneeLogin_ = ""; /** * optional string assignee_login = 13; @@ -2112,9 +2112,12 @@ public boolean hasAssigneeLogin() { public java.lang.String getAssigneeLogin() { java.lang.Object ref = assigneeLogin_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - assigneeLogin_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + assigneeLogin_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2172,7 +2175,6 @@ public Builder setAssigneeLoginBytes( return this; } - // optional int64 creation_date = 14; private long creationDate_ ; /** * optional int64 creation_date = 14; @@ -2216,7 +2218,7 @@ public Builder clearCreationDate() { // @@protoc_insertion_point(class_scope:ServerIssue) } - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_ServerIssue_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable @@ -2241,24 +2243,25 @@ public Builder clearCreationDate() { " \001(\003B\"\n\036org.sonar.batch.protocol.inputH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_ServerIssue_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_ServerIssue_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_ServerIssue_descriptor, - new java.lang.String[] { "Key", "ModuleKey", "Path", "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "ManualSeverity", "Resolution", "Status", "Checksum", "AssigneeLogin", "CreationDate", }); - return null; - } - }; + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { org.sonar.batch.protocol.Constants.getDescriptor(), }, assigner); + internal_static_ServerIssue_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_ServerIssue_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_ServerIssue_descriptor, + new java.lang.String[] { "Key", "ModuleKey", "Path", "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "ManualSeverity", "Resolution", "Status", "Checksum", "AssigneeLogin", "CreationDate", }); + org.sonar.batch.protocol.Constants.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) 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 194512a355f1..3cb6acd48be4 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 @@ -8,10 +8,10 @@ private BatchReport() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { } - public interface MetadataOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface MetadataOrBuilder extends + // @@protoc_insertion_point(interface_extends:Metadata) + com.google.protobuf.MessageOrBuilder { - // optional int64 analysis_date = 1; /** * optional int64 analysis_date = 1; */ @@ -21,7 +21,6 @@ public interface MetadataOrBuilder */ long getAnalysisDate(); - // optional string project_key = 2; /** * optional string project_key = 2; */ @@ -36,7 +35,6 @@ public interface MetadataOrBuilder com.google.protobuf.ByteString getProjectKeyBytes(); - // optional int32 root_component_ref = 3; /** * optional int32 root_component_ref = 3; */ @@ -46,7 +44,6 @@ public interface MetadataOrBuilder */ int getRootComponentRef(); - // optional int64 snapshot_id = 4; /** * optional int64 snapshot_id = 4; * @@ -64,7 +61,6 @@ public interface MetadataOrBuilder */ long getSnapshotId(); - // optional int32 deleted_components_count = 5; /** * optional int32 deleted_components_count = 5; */ @@ -78,8 +74,9 @@ public interface MetadataOrBuilder * Protobuf type {@code Metadata} */ public static final class Metadata extends - com.google.protobuf.GeneratedMessage - implements MetadataOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Metadata) + MetadataOrBuilder { // Use Metadata.newBuilder() to construct. private Metadata(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -131,8 +128,9 @@ private Metadata( break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - projectKey_ = input.readBytes(); + projectKey_ = bs; break; } case 24: { @@ -190,7 +188,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional int64 analysis_date = 1; public static final int ANALYSIS_DATE_FIELD_NUMBER = 1; private long analysisDate_; /** @@ -206,7 +203,6 @@ public long getAnalysisDate() { return analysisDate_; } - // optional string project_key = 2; public static final int PROJECT_KEY_FIELD_NUMBER = 2; private java.lang.Object projectKey_; /** @@ -249,7 +245,6 @@ public java.lang.String getProjectKey() { } } - // optional int32 root_component_ref = 3; public static final int ROOT_COMPONENT_REF_FIELD_NUMBER = 3; private int rootComponentRef_; /** @@ -265,7 +260,6 @@ public int getRootComponentRef() { return rootComponentRef_; } - // optional int64 snapshot_id = 4; public static final int SNAPSHOT_ID_FIELD_NUMBER = 4; private long snapshotId_; /** @@ -289,7 +283,6 @@ public long getSnapshotId() { return snapshotId_; } - // optional int32 deleted_components_count = 5; public static final int DELETED_COMPONENTS_COUNT_FIELD_NUMBER = 5; private int deletedComponentsCount_; /** @@ -315,7 +308,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -450,8 +444,9 @@ protected Builder newBuilderForType( * Protobuf type {@code Metadata} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.output.BatchReport.MetadataOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Metadata) + org.sonar.batch.protocol.output.BatchReport.MetadataOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.output.BatchReport.internal_static_Metadata_descriptor; @@ -602,7 +597,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional int64 analysis_date = 1; private long analysisDate_ ; /** * optional int64 analysis_date = 1; @@ -635,7 +629,6 @@ public Builder clearAnalysisDate() { return this; } - // optional string project_key = 2; private java.lang.Object projectKey_ = ""; /** * optional string project_key = 2; @@ -649,9 +642,12 @@ public boolean hasProjectKey() { public java.lang.String getProjectKey() { java.lang.Object ref = projectKey_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - projectKey_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + projectKey_ = s; + } return s; } else { return (java.lang.String) ref; @@ -709,7 +705,6 @@ public Builder setProjectKeyBytes( return this; } - // optional int32 root_component_ref = 3; private int rootComponentRef_ ; /** * optional int32 root_component_ref = 3; @@ -742,7 +737,6 @@ public Builder clearRootComponentRef() { return this; } - // optional int64 snapshot_id = 4; private long snapshotId_ ; /** * optional int64 snapshot_id = 4; @@ -791,7 +785,6 @@ public Builder clearSnapshotId() { return this; } - // optional int32 deleted_components_count = 5; private int deletedComponentsCount_ ; /** * optional int32 deleted_components_count = 5; @@ -835,10 +828,10 @@ public Builder clearDeletedComponentsCount() { // @@protoc_insertion_point(class_scope:Metadata) } - public interface ComponentLinkOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface ComponentLinkOrBuilder extends + // @@protoc_insertion_point(interface_extends:ComponentLink) + com.google.protobuf.MessageOrBuilder { - // optional .ComponentLinkType type = 1; /** * optional .ComponentLinkType type = 1; */ @@ -848,7 +841,6 @@ public interface ComponentLinkOrBuilder */ org.sonar.batch.protocol.Constants.ComponentLinkType getType(); - // optional string href = 2; /** * optional string href = 2; */ @@ -867,8 +859,9 @@ public interface ComponentLinkOrBuilder * Protobuf type {@code ComponentLink} */ public static final class ComponentLink extends - com.google.protobuf.GeneratedMessage - implements ComponentLinkOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:ComponentLink) + ComponentLinkOrBuilder { // Use ComponentLink.newBuilder() to construct. private ComponentLink(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -926,8 +919,9 @@ private ComponentLink( break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - href_ = input.readBytes(); + href_ = bs; break; } } @@ -970,7 +964,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional .ComponentLinkType type = 1; public static final int TYPE_FIELD_NUMBER = 1; private org.sonar.batch.protocol.Constants.ComponentLinkType type_; /** @@ -986,7 +979,6 @@ public org.sonar.batch.protocol.Constants.ComponentLinkType getType() { return type_; } - // optional string href = 2; public static final int HREF_FIELD_NUMBER = 2; private java.lang.Object href_; /** @@ -1036,7 +1028,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -1150,8 +1143,9 @@ protected Builder newBuilderForType( * Protobuf type {@code ComponentLink} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:ComponentLink) + org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.output.BatchReport.internal_static_ComponentLink_descriptor; @@ -1275,7 +1269,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional .ComponentLinkType type = 1; private org.sonar.batch.protocol.Constants.ComponentLinkType type_ = org.sonar.batch.protocol.Constants.ComponentLinkType.HOME; /** * optional .ComponentLinkType type = 1; @@ -1311,7 +1304,6 @@ public Builder clearType() { return this; } - // optional string href = 2; private java.lang.Object href_ = ""; /** * optional string href = 2; @@ -1325,9 +1317,12 @@ public boolean hasHref() { public java.lang.String getHref() { java.lang.Object ref = href_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - href_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + href_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1396,10 +1391,10 @@ public Builder setHrefBytes( // @@protoc_insertion_point(class_scope:ComponentLink) } - public interface EventOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface EventOrBuilder extends + // @@protoc_insertion_point(interface_extends:Event) + com.google.protobuf.MessageOrBuilder { - // optional int32 component_ref = 1; /** * optional int32 component_ref = 1; */ @@ -1409,7 +1404,6 @@ public interface EventOrBuilder */ int getComponentRef(); - // optional string name = 2; /** * optional string name = 2; */ @@ -1424,7 +1418,6 @@ public interface EventOrBuilder com.google.protobuf.ByteString getNameBytes(); - // optional string description = 3; /** * optional string description = 3; */ @@ -1439,7 +1432,6 @@ public interface EventOrBuilder com.google.protobuf.ByteString getDescriptionBytes(); - // optional .EventCategory category = 4; /** * optional .EventCategory category = 4; */ @@ -1449,7 +1441,6 @@ public interface EventOrBuilder */ org.sonar.batch.protocol.Constants.EventCategory getCategory(); - // optional string event_data = 5; /** * optional string event_data = 5; */ @@ -1472,8 +1463,9 @@ public interface EventOrBuilder * */ public static final class Event extends - com.google.protobuf.GeneratedMessage - implements EventOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Event) + EventOrBuilder { // Use Event.newBuilder() to construct. private Event(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -1525,13 +1517,15 @@ private Event( break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - name_ = input.readBytes(); + name_ = bs; break; } case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000004; - description_ = input.readBytes(); + description_ = bs; break; } case 32: { @@ -1546,8 +1540,9 @@ private Event( break; } case 42: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000010; - eventData_ = input.readBytes(); + eventData_ = bs; break; } } @@ -1590,7 +1585,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional int32 component_ref = 1; public static final int COMPONENT_REF_FIELD_NUMBER = 1; private int componentRef_; /** @@ -1606,7 +1600,6 @@ public int getComponentRef() { return componentRef_; } - // optional string name = 2; public static final int NAME_FIELD_NUMBER = 2; private java.lang.Object name_; /** @@ -1649,7 +1642,6 @@ public java.lang.String getName() { } } - // optional string description = 3; public static final int DESCRIPTION_FIELD_NUMBER = 3; private java.lang.Object description_; /** @@ -1692,7 +1684,6 @@ public java.lang.String getDescription() { } } - // optional .EventCategory category = 4; public static final int CATEGORY_FIELD_NUMBER = 4; private org.sonar.batch.protocol.Constants.EventCategory category_; /** @@ -1708,7 +1699,6 @@ public org.sonar.batch.protocol.Constants.EventCategory getCategory() { return category_; } - // optional string event_data = 5; public static final int EVENT_DATA_FIELD_NUMBER = 5; private java.lang.Object eventData_; /** @@ -1761,7 +1751,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -1900,8 +1891,9 @@ protected Builder newBuilderForType( * */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.output.BatchReport.EventOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Event) + org.sonar.batch.protocol.output.BatchReport.EventOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.output.BatchReport.internal_static_Event_descriptor; @@ -2056,7 +2048,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional int32 component_ref = 1; private int componentRef_ ; /** * optional int32 component_ref = 1; @@ -2089,7 +2080,6 @@ public Builder clearComponentRef() { return this; } - // optional string name = 2; private java.lang.Object name_ = ""; /** * optional string name = 2; @@ -2103,9 +2093,12 @@ public boolean hasName() { public java.lang.String getName() { java.lang.Object ref = name_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2163,7 +2156,6 @@ public Builder setNameBytes( return this; } - // optional string description = 3; private java.lang.Object description_ = ""; /** * optional string description = 3; @@ -2177,9 +2169,12 @@ public boolean hasDescription() { public java.lang.String getDescription() { java.lang.Object ref = description_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - description_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + description_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2237,7 +2232,6 @@ public Builder setDescriptionBytes( return this; } - // optional .EventCategory category = 4; private org.sonar.batch.protocol.Constants.EventCategory category_ = org.sonar.batch.protocol.Constants.EventCategory.ALERT; /** * optional .EventCategory category = 4; @@ -2273,7 +2267,6 @@ public Builder clearCategory() { return this; } - // optional string event_data = 5; private java.lang.Object eventData_ = ""; /** * optional string event_data = 5; @@ -2287,9 +2280,12 @@ public boolean hasEventData() { public java.lang.String getEventData() { java.lang.Object ref = eventData_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - eventData_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + eventData_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2358,10 +2354,10 @@ public Builder setEventDataBytes( // @@protoc_insertion_point(class_scope:Event) } - public interface ComponentOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface ComponentOrBuilder extends + // @@protoc_insertion_point(interface_extends:Component) + com.google.protobuf.MessageOrBuilder { - // optional int32 ref = 1; /** * optional int32 ref = 1; */ @@ -2371,7 +2367,6 @@ public interface ComponentOrBuilder */ int getRef(); - // optional string path = 2; /** * optional string path = 2; */ @@ -2386,7 +2381,6 @@ public interface ComponentOrBuilder com.google.protobuf.ByteString getPathBytes(); - // optional string name = 3; /** * optional string name = 3; */ @@ -2401,7 +2395,6 @@ public interface ComponentOrBuilder com.google.protobuf.ByteString getNameBytes(); - // optional .ComponentType type = 4; /** * optional .ComponentType type = 4; */ @@ -2411,7 +2404,6 @@ public interface ComponentOrBuilder */ org.sonar.batch.protocol.Constants.ComponentType getType(); - // optional bool is_test = 5; /** * optional bool is_test = 5; */ @@ -2421,7 +2413,6 @@ public interface ComponentOrBuilder */ boolean getIsTest(); - // optional string language = 6; /** * optional string language = 6; */ @@ -2436,7 +2427,6 @@ public interface ComponentOrBuilder com.google.protobuf.ByteString getLanguageBytes(); - // repeated int32 child_ref = 7 [packed = true]; /** * repeated int32 child_ref = 7 [packed = true]; */ @@ -2450,7 +2440,6 @@ public interface ComponentOrBuilder */ int getChildRef(int index); - // repeated .ComponentLink link = 10; /** * repeated .ComponentLink link = 10; */ @@ -2475,7 +2464,6 @@ public interface ComponentOrBuilder org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder getLinkOrBuilder( int index); - // optional string version = 12; /** * optional string version = 12; * @@ -2502,25 +2490,32 @@ org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder getLinkOrBuil com.google.protobuf.ByteString getVersionBytes(); - // optional int64 snapshot_id = 8; /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
      * temporary fields during development of computation stack
      * 
*/ - boolean hasSnapshotId(); + boolean hasId(); /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
      * temporary fields during development of computation stack
      * 
*/ + long getId(); + + /** + * optional int64 snapshot_id = 8; + */ + boolean hasSnapshotId(); + /** + * optional int64 snapshot_id = 8; + */ long getSnapshotId(); - // optional string uuid = 9; /** * optional string uuid = 9; */ @@ -2535,7 +2530,6 @@ org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder getLinkOrBuil com.google.protobuf.ByteString getUuidBytes(); - // repeated .Event event = 11; /** * repeated .Event event = 11; */ @@ -2564,8 +2558,9 @@ org.sonar.batch.protocol.output.BatchReport.EventOrBuilder getEventOrBuilder( * Protobuf type {@code Component} */ public static final class Component extends - com.google.protobuf.GeneratedMessage - implements ComponentOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Component) + ComponentOrBuilder { // Use Component.newBuilder() to construct. private Component(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -2617,13 +2612,15 @@ private Component( break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - path_ = input.readBytes(); + path_ = bs; break; } case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000004; - name_ = input.readBytes(); + name_ = bs; break; } case 32: { @@ -2643,8 +2640,9 @@ private Component( break; } case 50: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000020; - language_ = input.readBytes(); + language_ = bs; break; } case 56: { @@ -2669,13 +2667,14 @@ private Component( break; } case 64: { - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000100; snapshotId_ = input.readInt64(); break; } case 74: { - bitField0_ |= 0x00000100; - uuid_ = input.readBytes(); + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000200; + uuid_ = bs; break; } case 82: { @@ -2687,16 +2686,22 @@ private Component( break; } case 90: { - if (!((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + if (!((mutable_bitField0_ & 0x00001000) == 0x00001000)) { event_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000800; + mutable_bitField0_ |= 0x00001000; } event_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Event.PARSER, extensionRegistry)); break; } case 98: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000040; - version_ = input.readBytes(); + version_ = bs; + break; + } + case 104: { + bitField0_ |= 0x00000080; + id_ = input.readInt64(); break; } } @@ -2713,7 +2718,7 @@ private Component( if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) { link_ = java.util.Collections.unmodifiableList(link_); } - if (((mutable_bitField0_ & 0x00000800) == 0x00000800)) { + if (((mutable_bitField0_ & 0x00001000) == 0x00001000)) { event_ = java.util.Collections.unmodifiableList(event_); } this.unknownFields = unknownFields.build(); @@ -2748,7 +2753,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional int32 ref = 1; public static final int REF_FIELD_NUMBER = 1; private int ref_; /** @@ -2764,7 +2768,6 @@ public int getRef() { return ref_; } - // optional string path = 2; public static final int PATH_FIELD_NUMBER = 2; private java.lang.Object path_; /** @@ -2807,7 +2810,6 @@ public java.lang.String getPath() { } } - // optional string name = 3; public static final int NAME_FIELD_NUMBER = 3; private java.lang.Object name_; /** @@ -2850,7 +2852,6 @@ public java.lang.String getName() { } } - // optional .ComponentType type = 4; public static final int TYPE_FIELD_NUMBER = 4; private org.sonar.batch.protocol.Constants.ComponentType type_; /** @@ -2866,7 +2867,6 @@ public org.sonar.batch.protocol.Constants.ComponentType getType() { return type_; } - // optional bool is_test = 5; public static final int IS_TEST_FIELD_NUMBER = 5; private boolean isTest_; /** @@ -2882,7 +2882,6 @@ public boolean getIsTest() { return isTest_; } - // optional string language = 6; public static final int LANGUAGE_FIELD_NUMBER = 6; private java.lang.Object language_; /** @@ -2925,7 +2924,6 @@ public java.lang.String getLanguage() { } } - // repeated int32 child_ref = 7 [packed = true]; public static final int CHILD_REF_FIELD_NUMBER = 7; private java.util.List childRef_; /** @@ -2949,7 +2947,6 @@ public int getChildRef(int index) { } private int childRefMemoizedSerializedSize = -1; - // repeated .ComponentLink link = 10; public static final int LINK_FIELD_NUMBER = 10; private java.util.List link_; /** @@ -2985,7 +2982,6 @@ public org.sonar.batch.protocol.output.BatchReport.ComponentLinkOrBuilder getLin return link_.get(index); } - // optional string version = 12; public static final int VERSION_FIELD_NUMBER = 12; private java.lang.Object version_; /** @@ -3040,38 +3036,51 @@ public java.lang.String getVersion() { } } - // optional int64 snapshot_id = 8; - public static final int SNAPSHOT_ID_FIELD_NUMBER = 8; - private long snapshotId_; + public static final int ID_FIELD_NUMBER = 13; + private long id_; /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
      * temporary fields during development of computation stack
      * 
*/ - public boolean hasSnapshotId() { + public boolean hasId() { return ((bitField0_ & 0x00000080) == 0x00000080); } /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
      * temporary fields during development of computation stack
      * 
*/ + public long getId() { + return id_; + } + + public static final int SNAPSHOT_ID_FIELD_NUMBER = 8; + private long snapshotId_; + /** + * optional int64 snapshot_id = 8; + */ + public boolean hasSnapshotId() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional int64 snapshot_id = 8; + */ public long getSnapshotId() { return snapshotId_; } - // optional string uuid = 9; public static final int UUID_FIELD_NUMBER = 9; private java.lang.Object uuid_; /** * optional string uuid = 9; */ public boolean hasUuid() { - return ((bitField0_ & 0x00000100) == 0x00000100); + return ((bitField0_ & 0x00000200) == 0x00000200); } /** * optional string uuid = 9; @@ -3107,7 +3116,6 @@ public java.lang.String getUuid() { } } - // repeated .Event event = 11; public static final int EVENT_FIELD_NUMBER = 11; private java.util.List event_; /** @@ -3153,6 +3161,7 @@ private void initFields() { childRef_ = java.util.Collections.emptyList(); link_ = java.util.Collections.emptyList(); version_ = ""; + id_ = 0L; snapshotId_ = 0L; uuid_ = ""; event_ = java.util.Collections.emptyList(); @@ -3160,7 +3169,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -3194,10 +3204,10 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < childRef_.size(); i++) { output.writeInt32NoTag(childRef_.get(i)); } - if (((bitField0_ & 0x00000080) == 0x00000080)) { + if (((bitField0_ & 0x00000100) == 0x00000100)) { output.writeInt64(8, snapshotId_); } - if (((bitField0_ & 0x00000100) == 0x00000100)) { + if (((bitField0_ & 0x00000200) == 0x00000200)) { output.writeBytes(9, getUuidBytes()); } for (int i = 0; i < link_.size(); i++) { @@ -3209,6 +3219,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (((bitField0_ & 0x00000040) == 0x00000040)) { output.writeBytes(12, getVersionBytes()); } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + output.writeInt64(13, id_); + } getUnknownFields().writeTo(output); } @@ -3256,11 +3269,11 @@ public int getSerializedSize() { } childRefMemoizedSerializedSize = dataSize; } - if (((bitField0_ & 0x00000080) == 0x00000080)) { + if (((bitField0_ & 0x00000100) == 0x00000100)) { size += com.google.protobuf.CodedOutputStream .computeInt64Size(8, snapshotId_); } - if (((bitField0_ & 0x00000100) == 0x00000100)) { + if (((bitField0_ & 0x00000200) == 0x00000200)) { size += com.google.protobuf.CodedOutputStream .computeBytesSize(9, getUuidBytes()); } @@ -3276,6 +3289,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeBytesSize(12, getVersionBytes()); } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(13, id_); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -3358,8 +3375,9 @@ protected Builder newBuilderForType( * Protobuf type {@code Component} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.output.BatchReport.ComponentOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Component) + org.sonar.batch.protocol.output.BatchReport.ComponentOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.output.BatchReport.internal_static_Component_descriptor; @@ -3416,13 +3434,15 @@ public Builder clear() { } version_ = ""; bitField0_ = (bitField0_ & ~0x00000100); - snapshotId_ = 0L; + id_ = 0L; bitField0_ = (bitField0_ & ~0x00000200); - uuid_ = ""; + snapshotId_ = 0L; bitField0_ = (bitField0_ & ~0x00000400); + uuid_ = ""; + bitField0_ = (bitField0_ & ~0x00000800); if (eventBuilder_ == null) { event_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00001000); } else { eventBuilder_.clear(); } @@ -3499,15 +3519,19 @@ public org.sonar.batch.protocol.output.BatchReport.Component buildPartial() { if (((from_bitField0_ & 0x00000200) == 0x00000200)) { to_bitField0_ |= 0x00000080; } - result.snapshotId_ = snapshotId_; + result.id_ = id_; if (((from_bitField0_ & 0x00000400) == 0x00000400)) { to_bitField0_ |= 0x00000100; } + result.snapshotId_ = snapshotId_; + if (((from_bitField0_ & 0x00000800) == 0x00000800)) { + to_bitField0_ |= 0x00000200; + } result.uuid_ = uuid_; if (eventBuilder_ == null) { - if (((bitField0_ & 0x00000800) == 0x00000800)) { + if (((bitField0_ & 0x00001000) == 0x00001000)) { event_ = java.util.Collections.unmodifiableList(event_); - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00001000); } result.event_ = event_; } else { @@ -3594,11 +3618,14 @@ public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Component o version_ = other.version_; onChanged(); } + if (other.hasId()) { + setId(other.getId()); + } if (other.hasSnapshotId()) { setSnapshotId(other.getSnapshotId()); } if (other.hasUuid()) { - bitField0_ |= 0x00000400; + bitField0_ |= 0x00000800; uuid_ = other.uuid_; onChanged(); } @@ -3606,7 +3633,7 @@ public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Component o if (!other.event_.isEmpty()) { if (event_.isEmpty()) { event_ = other.event_; - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00001000); } else { ensureEventIsMutable(); event_.addAll(other.event_); @@ -3619,7 +3646,7 @@ public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Component o eventBuilder_.dispose(); eventBuilder_ = null; event_ = other.event_; - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00001000); eventBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getEventFieldBuilder() : null; @@ -3655,7 +3682,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional int32 ref = 1; private int ref_ ; /** * optional int32 ref = 1; @@ -3688,7 +3714,6 @@ public Builder clearRef() { return this; } - // optional string path = 2; private java.lang.Object path_ = ""; /** * optional string path = 2; @@ -3702,9 +3727,12 @@ public boolean hasPath() { public java.lang.String getPath() { java.lang.Object ref = path_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - path_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + path_ = s; + } return s; } else { return (java.lang.String) ref; @@ -3762,7 +3790,6 @@ public Builder setPathBytes( return this; } - // optional string name = 3; private java.lang.Object name_ = ""; /** * optional string name = 3; @@ -3776,9 +3803,12 @@ public boolean hasName() { public java.lang.String getName() { java.lang.Object ref = name_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + name_ = s; + } return s; } else { return (java.lang.String) ref; @@ -3836,7 +3866,6 @@ public Builder setNameBytes( return this; } - // optional .ComponentType type = 4; private org.sonar.batch.protocol.Constants.ComponentType type_ = org.sonar.batch.protocol.Constants.ComponentType.PROJECT; /** * optional .ComponentType type = 4; @@ -3872,7 +3901,6 @@ public Builder clearType() { return this; } - // optional bool is_test = 5; private boolean isTest_ ; /** * optional bool is_test = 5; @@ -3905,7 +3933,6 @@ public Builder clearIsTest() { return this; } - // optional string language = 6; private java.lang.Object language_ = ""; /** * optional string language = 6; @@ -3919,9 +3946,12 @@ public boolean hasLanguage() { public java.lang.String getLanguage() { java.lang.Object ref = language_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - language_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + language_ = s; + } return s; } else { return (java.lang.String) ref; @@ -3979,7 +4009,6 @@ public Builder setLanguageBytes( return this; } - // repeated int32 child_ref = 7 [packed = true]; private java.util.List childRef_ = java.util.Collections.emptyList(); private void ensureChildRefIsMutable() { if (!((bitField0_ & 0x00000040) == 0x00000040)) { @@ -4031,7 +4060,8 @@ public Builder addChildRef(int value) { public Builder addAllChildRef( java.lang.Iterable values) { ensureChildRefIsMutable(); - super.addAll(values, childRef_); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, childRef_); onChanged(); return this; } @@ -4045,7 +4075,6 @@ public Builder clearChildRef() { return this; } - // repeated .ComponentLink link = 10; private java.util.List link_ = java.util.Collections.emptyList(); private void ensureLinkIsMutable() { @@ -4187,7 +4216,8 @@ public Builder addAllLink( java.lang.Iterable values) { if (linkBuilder_ == null) { ensureLinkIsMutable(); - super.addAll(values, link_); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, link_); onChanged(); } else { linkBuilder_.addAllMessages(values); @@ -4285,7 +4315,6 @@ public org.sonar.batch.protocol.output.BatchReport.ComponentLink.Builder addLink return linkBuilder_; } - // optional string version = 12; private java.lang.Object version_ = ""; /** * optional string version = 12; @@ -4307,9 +4336,12 @@ public boolean hasVersion() { public java.lang.String getVersion() { java.lang.Object ref = version_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - version_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + version_ = s; + } return s; } else { return (java.lang.String) ref; @@ -4383,384 +4415,3515 @@ public Builder setVersionBytes( return this; } - // optional int64 snapshot_id = 8; - private long snapshotId_ ; + private long id_ ; /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
        * temporary fields during development of computation stack
        * 
*/ - public boolean hasSnapshotId() { + public boolean hasId() { return ((bitField0_ & 0x00000200) == 0x00000200); } /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
        * temporary fields during development of computation stack
        * 
*/ - public long getSnapshotId() { - return snapshotId_; + public long getId() { + return id_; } /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
        * temporary fields during development of computation stack
        * 
*/ - public Builder setSnapshotId(long value) { + public Builder setId(long value) { bitField0_ |= 0x00000200; - snapshotId_ = value; + id_ = value; onChanged(); return this; } /** - * optional int64 snapshot_id = 8; + * optional int64 id = 13; * *
        * temporary fields during development of computation stack
        * 
*/ - public Builder clearSnapshotId() { + public Builder clearId() { bitField0_ = (bitField0_ & ~0x00000200); + id_ = 0L; + onChanged(); + return this; + } + + private long snapshotId_ ; + /** + * optional int64 snapshot_id = 8; + */ + public boolean hasSnapshotId() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + /** + * optional int64 snapshot_id = 8; + */ + public long getSnapshotId() { + return snapshotId_; + } + /** + * optional int64 snapshot_id = 8; + */ + public Builder setSnapshotId(long value) { + bitField0_ |= 0x00000400; + snapshotId_ = value; + onChanged(); + return this; + } + /** + * optional int64 snapshot_id = 8; + */ + public Builder clearSnapshotId() { + bitField0_ = (bitField0_ & ~0x00000400); snapshotId_ = 0L; onChanged(); return this; } - // optional string uuid = 9; - private java.lang.Object uuid_ = ""; - /** - * optional string uuid = 9; - */ - public boolean hasUuid() { - return ((bitField0_ & 0x00000400) == 0x00000400); + private java.lang.Object uuid_ = ""; + /** + * optional string uuid = 9; + */ + public boolean hasUuid() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + /** + * optional string uuid = 9; + */ + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + uuid_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string uuid = 9; + */ + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string uuid = 9; + */ + public Builder setUuid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000800; + uuid_ = value; + onChanged(); + return this; + } + /** + * optional string uuid = 9; + */ + public Builder clearUuid() { + bitField0_ = (bitField0_ & ~0x00000800); + uuid_ = getDefaultInstance().getUuid(); + onChanged(); + return this; + } + /** + * optional string uuid = 9; + */ + public Builder setUuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000800; + uuid_ = value; + onChanged(); + return this; + } + + private java.util.List event_ = + java.util.Collections.emptyList(); + private void ensureEventIsMutable() { + if (!((bitField0_ & 0x00001000) == 0x00001000)) { + event_ = new java.util.ArrayList(event_); + bitField0_ |= 0x00001000; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder> eventBuilder_; + + /** + * repeated .Event event = 11; + */ + public java.util.List getEventList() { + if (eventBuilder_ == null) { + return java.util.Collections.unmodifiableList(event_); + } else { + return eventBuilder_.getMessageList(); + } + } + /** + * repeated .Event event = 11; + */ + public int getEventCount() { + if (eventBuilder_ == null) { + return event_.size(); + } else { + return eventBuilder_.getCount(); + } + } + /** + * repeated .Event event = 11; + */ + public org.sonar.batch.protocol.output.BatchReport.Event getEvent(int index) { + if (eventBuilder_ == null) { + return event_.get(index); + } else { + return eventBuilder_.getMessage(index); + } + } + /** + * repeated .Event event = 11; + */ + public Builder setEvent( + int index, org.sonar.batch.protocol.output.BatchReport.Event value) { + if (eventBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventIsMutable(); + event_.set(index, value); + onChanged(); + } else { + eventBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder setEvent( + int index, org.sonar.batch.protocol.output.BatchReport.Event.Builder builderForValue) { + if (eventBuilder_ == null) { + ensureEventIsMutable(); + event_.set(index, builderForValue.build()); + onChanged(); + } else { + eventBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder addEvent(org.sonar.batch.protocol.output.BatchReport.Event value) { + if (eventBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventIsMutable(); + event_.add(value); + onChanged(); + } else { + eventBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder addEvent( + int index, org.sonar.batch.protocol.output.BatchReport.Event value) { + if (eventBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventIsMutable(); + event_.add(index, value); + onChanged(); + } else { + eventBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder addEvent( + org.sonar.batch.protocol.output.BatchReport.Event.Builder builderForValue) { + if (eventBuilder_ == null) { + ensureEventIsMutable(); + event_.add(builderForValue.build()); + onChanged(); + } else { + eventBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder addEvent( + int index, org.sonar.batch.protocol.output.BatchReport.Event.Builder builderForValue) { + if (eventBuilder_ == null) { + ensureEventIsMutable(); + event_.add(index, builderForValue.build()); + onChanged(); + } else { + eventBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder addAllEvent( + java.lang.Iterable values) { + if (eventBuilder_ == null) { + ensureEventIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, event_); + onChanged(); + } else { + eventBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder clearEvent() { + if (eventBuilder_ == null) { + event_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00001000); + onChanged(); + } else { + eventBuilder_.clear(); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public Builder removeEvent(int index) { + if (eventBuilder_ == null) { + ensureEventIsMutable(); + event_.remove(index); + onChanged(); + } else { + eventBuilder_.remove(index); + } + return this; + } + /** + * repeated .Event event = 11; + */ + public org.sonar.batch.protocol.output.BatchReport.Event.Builder getEventBuilder( + int index) { + return getEventFieldBuilder().getBuilder(index); + } + /** + * repeated .Event event = 11; + */ + public org.sonar.batch.protocol.output.BatchReport.EventOrBuilder getEventOrBuilder( + int index) { + if (eventBuilder_ == null) { + return event_.get(index); } else { + return eventBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .Event event = 11; + */ + public java.util.List + getEventOrBuilderList() { + if (eventBuilder_ != null) { + return eventBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(event_); + } + } + /** + * repeated .Event event = 11; + */ + public org.sonar.batch.protocol.output.BatchReport.Event.Builder addEventBuilder() { + return getEventFieldBuilder().addBuilder( + org.sonar.batch.protocol.output.BatchReport.Event.getDefaultInstance()); + } + /** + * repeated .Event event = 11; + */ + public org.sonar.batch.protocol.output.BatchReport.Event.Builder addEventBuilder( + int index) { + return getEventFieldBuilder().addBuilder( + index, org.sonar.batch.protocol.output.BatchReport.Event.getDefaultInstance()); + } + /** + * repeated .Event event = 11; + */ + public java.util.List + getEventBuilderList() { + return getEventFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder> + getEventFieldBuilder() { + if (eventBuilder_ == null) { + eventBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder>( + event_, + ((bitField0_ & 0x00001000) == 0x00001000), + getParentForChildren(), + isClean()); + event_ = null; + } + return eventBuilder_; + } + + // @@protoc_insertion_point(builder_scope:Component) + } + + static { + defaultInstance = new Component(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:Component) + } + + public interface MeasureOrBuilder extends + // @@protoc_insertion_point(interface_extends:Measure) + com.google.protobuf.MessageOrBuilder { + + /** + * optional .MeasureValueType value_type = 1; + */ + boolean hasValueType(); + /** + * optional .MeasureValueType value_type = 1; + */ + org.sonar.batch.protocol.Constants.MeasureValueType getValueType(); + + /** + * optional bool boolean_value = 2; + */ + boolean hasBooleanValue(); + /** + * optional bool boolean_value = 2; + */ + boolean getBooleanValue(); + + /** + * optional int32 int_value = 3; + */ + boolean hasIntValue(); + /** + * optional int32 int_value = 3; + */ + int getIntValue(); + + /** + * optional int64 long_value = 4; + */ + boolean hasLongValue(); + /** + * optional int64 long_value = 4; + */ + long getLongValue(); + + /** + * optional double double_value = 5; + */ + boolean hasDoubleValue(); + /** + * optional double double_value = 5; + */ + double getDoubleValue(); + + /** + * optional string string_value = 6; + */ + boolean hasStringValue(); + /** + * optional string string_value = 6; + */ + java.lang.String getStringValue(); + /** + * optional string string_value = 6; + */ + com.google.protobuf.ByteString + getStringValueBytes(); + + /** + * optional string metric_key = 7; + */ + boolean hasMetricKey(); + /** + * optional string metric_key = 7; + */ + java.lang.String getMetricKey(); + /** + * optional string metric_key = 7; + */ + com.google.protobuf.ByteString + getMetricKeyBytes(); + + /** + * optional string description = 9; + * + *
+     * temporary fields during development of computation stack
+     * 
+ */ + boolean hasDescription(); + /** + * optional string description = 9; + * + *
+     * temporary fields during development of computation stack
+     * 
+ */ + java.lang.String getDescription(); + /** + * optional string description = 9; + * + *
+     * temporary fields during development of computation stack
+     * 
+ */ + com.google.protobuf.ByteString + getDescriptionBytes(); + + /** + * optional string rule_key = 10; + */ + boolean hasRuleKey(); + /** + * optional string rule_key = 10; + */ + java.lang.String getRuleKey(); + /** + * optional string rule_key = 10; + */ + com.google.protobuf.ByteString + getRuleKeyBytes(); + + /** + * optional .Severity severity = 11; + */ + boolean hasSeverity(); + /** + * optional .Severity severity = 11; + */ + org.sonar.batch.protocol.Constants.Severity getSeverity(); + + /** + * optional string alert_status = 12; + */ + boolean hasAlertStatus(); + /** + * optional string alert_status = 12; + */ + java.lang.String getAlertStatus(); + /** + * optional string alert_status = 12; + */ + com.google.protobuf.ByteString + getAlertStatusBytes(); + + /** + * optional string alert_text = 13; + */ + boolean hasAlertText(); + /** + * optional string alert_text = 13; + */ + java.lang.String getAlertText(); + /** + * optional string alert_text = 13; + */ + com.google.protobuf.ByteString + getAlertTextBytes(); + + /** + * optional double variation_value_1 = 14; + */ + boolean hasVariationValue1(); + /** + * optional double variation_value_1 = 14; + */ + double getVariationValue1(); + + /** + * optional double variation_value_2 = 15; + */ + boolean hasVariationValue2(); + /** + * optional double variation_value_2 = 15; + */ + double getVariationValue2(); + + /** + * optional double variation_value_3 = 16; + */ + boolean hasVariationValue3(); + /** + * optional double variation_value_3 = 16; + */ + double getVariationValue3(); + + /** + * optional double variation_value_4 = 17; + */ + boolean hasVariationValue4(); + /** + * optional double variation_value_4 = 17; + */ + double getVariationValue4(); + + /** + * optional double variation_value_5 = 18; + */ + boolean hasVariationValue5(); + /** + * optional double variation_value_5 = 18; + */ + double getVariationValue5(); + + /** + * optional int32 tendency = 19; + */ + boolean hasTendency(); + /** + * optional int32 tendency = 19; + */ + int getTendency(); + + /** + * optional int32 characteric_id = 20; + */ + boolean hasCharactericId(); + /** + * optional int32 characteric_id = 20; + */ + int getCharactericId(); + } + /** + * Protobuf type {@code Measure} + */ + public static final class Measure extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Measure) + MeasureOrBuilder { + // Use Measure.newBuilder() to construct. + private Measure(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Measure(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Measure defaultInstance; + public static Measure getDefaultInstance() { + return defaultInstance; + } + + public Measure getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Measure( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + org.sonar.batch.protocol.Constants.MeasureValueType value = org.sonar.batch.protocol.Constants.MeasureValueType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(1, rawValue); + } else { + bitField0_ |= 0x00000001; + valueType_ = value; + } + break; + } + case 16: { + bitField0_ |= 0x00000002; + booleanValue_ = input.readBool(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + intValue_ = input.readInt32(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + longValue_ = input.readInt64(); + break; + } + case 41: { + bitField0_ |= 0x00000010; + doubleValue_ = input.readDouble(); + break; + } + case 50: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000020; + stringValue_ = bs; + break; + } + case 58: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000040; + metricKey_ = bs; + break; + } + case 74: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000080; + description_ = bs; + break; + } + case 82: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000100; + ruleKey_ = bs; + break; + } + case 88: { + int rawValue = input.readEnum(); + org.sonar.batch.protocol.Constants.Severity value = org.sonar.batch.protocol.Constants.Severity.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(11, rawValue); + } else { + bitField0_ |= 0x00000200; + severity_ = value; + } + break; + } + case 98: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000400; + alertStatus_ = bs; + break; + } + case 106: { + com.google.protobuf.ByteString bs = input.readBytes(); + bitField0_ |= 0x00000800; + alertText_ = bs; + break; + } + case 113: { + bitField0_ |= 0x00001000; + variationValue1_ = input.readDouble(); + break; + } + case 121: { + bitField0_ |= 0x00002000; + variationValue2_ = input.readDouble(); + break; + } + case 129: { + bitField0_ |= 0x00004000; + variationValue3_ = input.readDouble(); + break; + } + case 137: { + bitField0_ |= 0x00008000; + variationValue4_ = input.readDouble(); + break; + } + case 145: { + bitField0_ |= 0x00010000; + variationValue5_ = input.readDouble(); + break; + } + case 152: { + bitField0_ |= 0x00020000; + tendency_ = input.readInt32(); + break; + } + case 160: { + bitField0_ |= 0x00040000; + charactericId_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measure_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measure_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.sonar.batch.protocol.output.BatchReport.Measure.class, org.sonar.batch.protocol.output.BatchReport.Measure.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Measure parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Measure(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int VALUE_TYPE_FIELD_NUMBER = 1; + private org.sonar.batch.protocol.Constants.MeasureValueType valueType_; + /** + * optional .MeasureValueType value_type = 1; + */ + public boolean hasValueType() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional .MeasureValueType value_type = 1; + */ + public org.sonar.batch.protocol.Constants.MeasureValueType getValueType() { + return valueType_; + } + + public static final int BOOLEAN_VALUE_FIELD_NUMBER = 2; + private boolean booleanValue_; + /** + * optional bool boolean_value = 2; + */ + public boolean hasBooleanValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bool boolean_value = 2; + */ + public boolean getBooleanValue() { + return booleanValue_; + } + + public static final int INT_VALUE_FIELD_NUMBER = 3; + private int intValue_; + /** + * optional int32 int_value = 3; + */ + public boolean hasIntValue() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int32 int_value = 3; + */ + public int getIntValue() { + return intValue_; + } + + public static final int LONG_VALUE_FIELD_NUMBER = 4; + private long longValue_; + /** + * optional int64 long_value = 4; + */ + public boolean hasLongValue() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 long_value = 4; + */ + public long getLongValue() { + return longValue_; + } + + public static final int DOUBLE_VALUE_FIELD_NUMBER = 5; + private double doubleValue_; + /** + * optional double double_value = 5; + */ + public boolean hasDoubleValue() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional double double_value = 5; + */ + public double getDoubleValue() { + return doubleValue_; + } + + public static final int STRING_VALUE_FIELD_NUMBER = 6; + private java.lang.Object stringValue_; + /** + * optional string string_value = 6; + */ + public boolean hasStringValue() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional string string_value = 6; + */ + public java.lang.String getStringValue() { + java.lang.Object ref = stringValue_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + stringValue_ = s; + } + return s; + } + } + /** + * optional string string_value = 6; + */ + public com.google.protobuf.ByteString + getStringValueBytes() { + java.lang.Object ref = stringValue_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + stringValue_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int METRIC_KEY_FIELD_NUMBER = 7; + private java.lang.Object metricKey_; + /** + * optional string metric_key = 7; + */ + public boolean hasMetricKey() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** + * optional string metric_key = 7; + */ + public java.lang.String getMetricKey() { + java.lang.Object ref = metricKey_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + metricKey_ = s; + } + return s; + } + } + /** + * optional string metric_key = 7; + */ + public com.google.protobuf.ByteString + getMetricKeyBytes() { + java.lang.Object ref = metricKey_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + metricKey_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESCRIPTION_FIELD_NUMBER = 9; + private java.lang.Object description_; + /** + * optional string description = 9; + * + *
+     * temporary fields during development of computation stack
+     * 
+ */ + public boolean hasDescription() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional string description = 9; + * + *
+     * temporary fields during development of computation stack
+     * 
+ */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + description_ = s; + } + return s; + } + } + /** + * optional string description = 9; + * + *
+     * temporary fields during development of computation stack
+     * 
+ */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RULE_KEY_FIELD_NUMBER = 10; + private java.lang.Object ruleKey_; + /** + * optional string rule_key = 10; + */ + public boolean hasRuleKey() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional string rule_key = 10; + */ + public java.lang.String getRuleKey() { + java.lang.Object ref = ruleKey_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ruleKey_ = s; + } + return s; + } + } + /** + * optional string rule_key = 10; + */ + public com.google.protobuf.ByteString + getRuleKeyBytes() { + java.lang.Object ref = ruleKey_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + ruleKey_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SEVERITY_FIELD_NUMBER = 11; + private org.sonar.batch.protocol.Constants.Severity severity_; + /** + * optional .Severity severity = 11; + */ + public boolean hasSeverity() { + return ((bitField0_ & 0x00000200) == 0x00000200); + } + /** + * optional .Severity severity = 11; + */ + public org.sonar.batch.protocol.Constants.Severity getSeverity() { + return severity_; + } + + public static final int ALERT_STATUS_FIELD_NUMBER = 12; + private java.lang.Object alertStatus_; + /** + * optional string alert_status = 12; + */ + public boolean hasAlertStatus() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + /** + * optional string alert_status = 12; + */ + public java.lang.String getAlertStatus() { + java.lang.Object ref = alertStatus_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + alertStatus_ = s; + } + return s; + } + } + /** + * optional string alert_status = 12; + */ + public com.google.protobuf.ByteString + getAlertStatusBytes() { + java.lang.Object ref = alertStatus_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + alertStatus_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ALERT_TEXT_FIELD_NUMBER = 13; + private java.lang.Object alertText_; + /** + * optional string alert_text = 13; + */ + public boolean hasAlertText() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + /** + * optional string alert_text = 13; + */ + public java.lang.String getAlertText() { + java.lang.Object ref = alertText_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + alertText_ = s; + } + return s; + } + } + /** + * optional string alert_text = 13; + */ + public com.google.protobuf.ByteString + getAlertTextBytes() { + java.lang.Object ref = alertText_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + alertText_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VARIATION_VALUE_1_FIELD_NUMBER = 14; + private double variationValue1_; + /** + * optional double variation_value_1 = 14; + */ + public boolean hasVariationValue1() { + return ((bitField0_ & 0x00001000) == 0x00001000); + } + /** + * optional double variation_value_1 = 14; + */ + public double getVariationValue1() { + return variationValue1_; + } + + public static final int VARIATION_VALUE_2_FIELD_NUMBER = 15; + private double variationValue2_; + /** + * optional double variation_value_2 = 15; + */ + public boolean hasVariationValue2() { + return ((bitField0_ & 0x00002000) == 0x00002000); + } + /** + * optional double variation_value_2 = 15; + */ + public double getVariationValue2() { + return variationValue2_; + } + + public static final int VARIATION_VALUE_3_FIELD_NUMBER = 16; + private double variationValue3_; + /** + * optional double variation_value_3 = 16; + */ + public boolean hasVariationValue3() { + return ((bitField0_ & 0x00004000) == 0x00004000); + } + /** + * optional double variation_value_3 = 16; + */ + public double getVariationValue3() { + return variationValue3_; + } + + public static final int VARIATION_VALUE_4_FIELD_NUMBER = 17; + private double variationValue4_; + /** + * optional double variation_value_4 = 17; + */ + public boolean hasVariationValue4() { + return ((bitField0_ & 0x00008000) == 0x00008000); + } + /** + * optional double variation_value_4 = 17; + */ + public double getVariationValue4() { + return variationValue4_; + } + + public static final int VARIATION_VALUE_5_FIELD_NUMBER = 18; + private double variationValue5_; + /** + * optional double variation_value_5 = 18; + */ + public boolean hasVariationValue5() { + return ((bitField0_ & 0x00010000) == 0x00010000); + } + /** + * optional double variation_value_5 = 18; + */ + public double getVariationValue5() { + return variationValue5_; + } + + public static final int TENDENCY_FIELD_NUMBER = 19; + private int tendency_; + /** + * optional int32 tendency = 19; + */ + public boolean hasTendency() { + return ((bitField0_ & 0x00020000) == 0x00020000); + } + /** + * optional int32 tendency = 19; + */ + public int getTendency() { + return tendency_; + } + + public static final int CHARACTERIC_ID_FIELD_NUMBER = 20; + private int charactericId_; + /** + * optional int32 characteric_id = 20; + */ + public boolean hasCharactericId() { + return ((bitField0_ & 0x00040000) == 0x00040000); + } + /** + * optional int32 characteric_id = 20; + */ + public int getCharactericId() { + return charactericId_; + } + + private void initFields() { + valueType_ = org.sonar.batch.protocol.Constants.MeasureValueType.INT; + booleanValue_ = false; + intValue_ = 0; + longValue_ = 0L; + doubleValue_ = 0D; + stringValue_ = ""; + metricKey_ = ""; + description_ = ""; + ruleKey_ = ""; + severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; + alertStatus_ = ""; + alertText_ = ""; + variationValue1_ = 0D; + variationValue2_ = 0D; + variationValue3_ = 0D; + variationValue4_ = 0D; + variationValue5_ = 0D; + tendency_ = 0; + charactericId_ = 0; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeEnum(1, valueType_.getNumber()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBool(2, booleanValue_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeInt32(3, intValue_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt64(4, longValue_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeDouble(5, doubleValue_); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + output.writeBytes(6, getStringValueBytes()); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + output.writeBytes(7, getMetricKeyBytes()); + } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + output.writeBytes(9, getDescriptionBytes()); + } + if (((bitField0_ & 0x00000100) == 0x00000100)) { + output.writeBytes(10, getRuleKeyBytes()); + } + if (((bitField0_ & 0x00000200) == 0x00000200)) { + output.writeEnum(11, severity_.getNumber()); + } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + output.writeBytes(12, getAlertStatusBytes()); + } + if (((bitField0_ & 0x00000800) == 0x00000800)) { + output.writeBytes(13, getAlertTextBytes()); + } + if (((bitField0_ & 0x00001000) == 0x00001000)) { + output.writeDouble(14, variationValue1_); + } + if (((bitField0_ & 0x00002000) == 0x00002000)) { + output.writeDouble(15, variationValue2_); + } + if (((bitField0_ & 0x00004000) == 0x00004000)) { + output.writeDouble(16, variationValue3_); + } + if (((bitField0_ & 0x00008000) == 0x00008000)) { + output.writeDouble(17, variationValue4_); + } + if (((bitField0_ & 0x00010000) == 0x00010000)) { + output.writeDouble(18, variationValue5_); + } + if (((bitField0_ & 0x00020000) == 0x00020000)) { + output.writeInt32(19, tendency_); + } + if (((bitField0_ & 0x00040000) == 0x00040000)) { + output.writeInt32(20, charactericId_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, valueType_.getNumber()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, booleanValue_); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, intValue_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, longValue_); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(5, doubleValue_); + } + if (((bitField0_ & 0x00000020) == 0x00000020)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(6, getStringValueBytes()); + } + if (((bitField0_ & 0x00000040) == 0x00000040)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(7, getMetricKeyBytes()); + } + if (((bitField0_ & 0x00000080) == 0x00000080)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(9, getDescriptionBytes()); + } + if (((bitField0_ & 0x00000100) == 0x00000100)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(10, getRuleKeyBytes()); + } + if (((bitField0_ & 0x00000200) == 0x00000200)) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(11, severity_.getNumber()); + } + if (((bitField0_ & 0x00000400) == 0x00000400)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(12, getAlertStatusBytes()); + } + if (((bitField0_ & 0x00000800) == 0x00000800)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(13, getAlertTextBytes()); + } + if (((bitField0_ & 0x00001000) == 0x00001000)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(14, variationValue1_); + } + if (((bitField0_ & 0x00002000) == 0x00002000)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(15, variationValue2_); + } + if (((bitField0_ & 0x00004000) == 0x00004000)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(16, variationValue3_); + } + if (((bitField0_ & 0x00008000) == 0x00008000)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(17, variationValue4_); + } + if (((bitField0_ & 0x00010000) == 0x00010000)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(18, variationValue5_); + } + if (((bitField0_ & 0x00020000) == 0x00020000)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(19, tendency_); + } + if (((bitField0_ & 0x00040000) == 0x00040000)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(20, charactericId_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.sonar.batch.protocol.output.BatchReport.Measure parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Measure prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Measure} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Measure) + org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measure_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measure_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.sonar.batch.protocol.output.BatchReport.Measure.class, org.sonar.batch.protocol.output.BatchReport.Measure.Builder.class); + } + + // Construct using org.sonar.batch.protocol.output.BatchReport.Measure.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + valueType_ = org.sonar.batch.protocol.Constants.MeasureValueType.INT; + bitField0_ = (bitField0_ & ~0x00000001); + booleanValue_ = false; + bitField0_ = (bitField0_ & ~0x00000002); + intValue_ = 0; + bitField0_ = (bitField0_ & ~0x00000004); + longValue_ = 0L; + bitField0_ = (bitField0_ & ~0x00000008); + doubleValue_ = 0D; + bitField0_ = (bitField0_ & ~0x00000010); + stringValue_ = ""; + bitField0_ = (bitField0_ & ~0x00000020); + metricKey_ = ""; + bitField0_ = (bitField0_ & ~0x00000040); + description_ = ""; + bitField0_ = (bitField0_ & ~0x00000080); + ruleKey_ = ""; + bitField0_ = (bitField0_ & ~0x00000100); + severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; + bitField0_ = (bitField0_ & ~0x00000200); + alertStatus_ = ""; + bitField0_ = (bitField0_ & ~0x00000400); + alertText_ = ""; + bitField0_ = (bitField0_ & ~0x00000800); + variationValue1_ = 0D; + bitField0_ = (bitField0_ & ~0x00001000); + variationValue2_ = 0D; + bitField0_ = (bitField0_ & ~0x00002000); + variationValue3_ = 0D; + bitField0_ = (bitField0_ & ~0x00004000); + variationValue4_ = 0D; + bitField0_ = (bitField0_ & ~0x00008000); + variationValue5_ = 0D; + bitField0_ = (bitField0_ & ~0x00010000); + tendency_ = 0; + bitField0_ = (bitField0_ & ~0x00020000); + charactericId_ = 0; + bitField0_ = (bitField0_ & ~0x00040000); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measure_descriptor; + } + + public org.sonar.batch.protocol.output.BatchReport.Measure getDefaultInstanceForType() { + return org.sonar.batch.protocol.output.BatchReport.Measure.getDefaultInstance(); + } + + public org.sonar.batch.protocol.output.BatchReport.Measure build() { + org.sonar.batch.protocol.output.BatchReport.Measure result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.sonar.batch.protocol.output.BatchReport.Measure buildPartial() { + org.sonar.batch.protocol.output.BatchReport.Measure result = new org.sonar.batch.protocol.output.BatchReport.Measure(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.valueType_ = valueType_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.booleanValue_ = booleanValue_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.intValue_ = intValue_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.longValue_ = longValue_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.doubleValue_ = doubleValue_; + if (((from_bitField0_ & 0x00000020) == 0x00000020)) { + to_bitField0_ |= 0x00000020; + } + result.stringValue_ = stringValue_; + if (((from_bitField0_ & 0x00000040) == 0x00000040)) { + to_bitField0_ |= 0x00000040; + } + result.metricKey_ = metricKey_; + if (((from_bitField0_ & 0x00000080) == 0x00000080)) { + to_bitField0_ |= 0x00000080; + } + result.description_ = description_; + if (((from_bitField0_ & 0x00000100) == 0x00000100)) { + to_bitField0_ |= 0x00000100; + } + result.ruleKey_ = ruleKey_; + if (((from_bitField0_ & 0x00000200) == 0x00000200)) { + to_bitField0_ |= 0x00000200; + } + result.severity_ = severity_; + if (((from_bitField0_ & 0x00000400) == 0x00000400)) { + to_bitField0_ |= 0x00000400; + } + result.alertStatus_ = alertStatus_; + if (((from_bitField0_ & 0x00000800) == 0x00000800)) { + to_bitField0_ |= 0x00000800; + } + result.alertText_ = alertText_; + if (((from_bitField0_ & 0x00001000) == 0x00001000)) { + to_bitField0_ |= 0x00001000; + } + result.variationValue1_ = variationValue1_; + if (((from_bitField0_ & 0x00002000) == 0x00002000)) { + to_bitField0_ |= 0x00002000; + } + result.variationValue2_ = variationValue2_; + if (((from_bitField0_ & 0x00004000) == 0x00004000)) { + to_bitField0_ |= 0x00004000; + } + result.variationValue3_ = variationValue3_; + if (((from_bitField0_ & 0x00008000) == 0x00008000)) { + to_bitField0_ |= 0x00008000; + } + result.variationValue4_ = variationValue4_; + if (((from_bitField0_ & 0x00010000) == 0x00010000)) { + to_bitField0_ |= 0x00010000; + } + result.variationValue5_ = variationValue5_; + if (((from_bitField0_ & 0x00020000) == 0x00020000)) { + to_bitField0_ |= 0x00020000; + } + result.tendency_ = tendency_; + if (((from_bitField0_ & 0x00040000) == 0x00040000)) { + to_bitField0_ |= 0x00040000; + } + result.charactericId_ = charactericId_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.sonar.batch.protocol.output.BatchReport.Measure) { + return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Measure)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Measure other) { + if (other == org.sonar.batch.protocol.output.BatchReport.Measure.getDefaultInstance()) return this; + if (other.hasValueType()) { + setValueType(other.getValueType()); + } + if (other.hasBooleanValue()) { + setBooleanValue(other.getBooleanValue()); + } + if (other.hasIntValue()) { + setIntValue(other.getIntValue()); + } + if (other.hasLongValue()) { + setLongValue(other.getLongValue()); + } + if (other.hasDoubleValue()) { + setDoubleValue(other.getDoubleValue()); + } + if (other.hasStringValue()) { + bitField0_ |= 0x00000020; + stringValue_ = other.stringValue_; + onChanged(); + } + if (other.hasMetricKey()) { + bitField0_ |= 0x00000040; + metricKey_ = other.metricKey_; + onChanged(); + } + if (other.hasDescription()) { + bitField0_ |= 0x00000080; + description_ = other.description_; + onChanged(); + } + if (other.hasRuleKey()) { + bitField0_ |= 0x00000100; + ruleKey_ = other.ruleKey_; + onChanged(); + } + if (other.hasSeverity()) { + setSeverity(other.getSeverity()); + } + if (other.hasAlertStatus()) { + bitField0_ |= 0x00000400; + alertStatus_ = other.alertStatus_; + onChanged(); + } + if (other.hasAlertText()) { + bitField0_ |= 0x00000800; + alertText_ = other.alertText_; + onChanged(); + } + if (other.hasVariationValue1()) { + setVariationValue1(other.getVariationValue1()); + } + if (other.hasVariationValue2()) { + setVariationValue2(other.getVariationValue2()); + } + if (other.hasVariationValue3()) { + setVariationValue3(other.getVariationValue3()); + } + if (other.hasVariationValue4()) { + setVariationValue4(other.getVariationValue4()); + } + if (other.hasVariationValue5()) { + setVariationValue5(other.getVariationValue5()); + } + if (other.hasTendency()) { + setTendency(other.getTendency()); + } + if (other.hasCharactericId()) { + setCharactericId(other.getCharactericId()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.sonar.batch.protocol.output.BatchReport.Measure parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Measure) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private org.sonar.batch.protocol.Constants.MeasureValueType valueType_ = org.sonar.batch.protocol.Constants.MeasureValueType.INT; + /** + * optional .MeasureValueType value_type = 1; + */ + public boolean hasValueType() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional .MeasureValueType value_type = 1; + */ + public org.sonar.batch.protocol.Constants.MeasureValueType getValueType() { + return valueType_; + } + /** + * optional .MeasureValueType value_type = 1; + */ + public Builder setValueType(org.sonar.batch.protocol.Constants.MeasureValueType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + valueType_ = value; + onChanged(); + return this; + } + /** + * optional .MeasureValueType value_type = 1; + */ + public Builder clearValueType() { + bitField0_ = (bitField0_ & ~0x00000001); + valueType_ = org.sonar.batch.protocol.Constants.MeasureValueType.INT; + onChanged(); + return this; + } + + private boolean booleanValue_ ; + /** + * optional bool boolean_value = 2; + */ + public boolean hasBooleanValue() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * optional bool boolean_value = 2; + */ + public boolean getBooleanValue() { + return booleanValue_; + } + /** + * optional bool boolean_value = 2; + */ + public Builder setBooleanValue(boolean value) { + bitField0_ |= 0x00000002; + booleanValue_ = value; + onChanged(); + return this; + } + /** + * optional bool boolean_value = 2; + */ + public Builder clearBooleanValue() { + bitField0_ = (bitField0_ & ~0x00000002); + booleanValue_ = false; + onChanged(); + return this; + } + + private int intValue_ ; + /** + * optional int32 int_value = 3; + */ + public boolean hasIntValue() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * optional int32 int_value = 3; + */ + public int getIntValue() { + return intValue_; + } + /** + * optional int32 int_value = 3; + */ + public Builder setIntValue(int value) { + bitField0_ |= 0x00000004; + intValue_ = value; + onChanged(); + return this; + } + /** + * optional int32 int_value = 3; + */ + public Builder clearIntValue() { + bitField0_ = (bitField0_ & ~0x00000004); + intValue_ = 0; + onChanged(); + return this; + } + + private long longValue_ ; + /** + * optional int64 long_value = 4; + */ + public boolean hasLongValue() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int64 long_value = 4; + */ + public long getLongValue() { + return longValue_; + } + /** + * optional int64 long_value = 4; + */ + public Builder setLongValue(long value) { + bitField0_ |= 0x00000008; + longValue_ = value; + onChanged(); + return this; + } + /** + * optional int64 long_value = 4; + */ + public Builder clearLongValue() { + bitField0_ = (bitField0_ & ~0x00000008); + longValue_ = 0L; + onChanged(); + return this; + } + + private double doubleValue_ ; + /** + * optional double double_value = 5; + */ + public boolean hasDoubleValue() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional double double_value = 5; + */ + public double getDoubleValue() { + return doubleValue_; + } + /** + * optional double double_value = 5; + */ + public Builder setDoubleValue(double value) { + bitField0_ |= 0x00000010; + doubleValue_ = value; + onChanged(); + return this; + } + /** + * optional double double_value = 5; + */ + public Builder clearDoubleValue() { + bitField0_ = (bitField0_ & ~0x00000010); + doubleValue_ = 0D; + onChanged(); + return this; + } + + private java.lang.Object stringValue_ = ""; + /** + * optional string string_value = 6; + */ + public boolean hasStringValue() { + return ((bitField0_ & 0x00000020) == 0x00000020); + } + /** + * optional string string_value = 6; + */ + public java.lang.String getStringValue() { + java.lang.Object ref = stringValue_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + stringValue_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string string_value = 6; + */ + public com.google.protobuf.ByteString + getStringValueBytes() { + java.lang.Object ref = stringValue_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + stringValue_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string string_value = 6; + */ + public Builder setStringValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + stringValue_ = value; + onChanged(); + return this; + } + /** + * optional string string_value = 6; + */ + public Builder clearStringValue() { + bitField0_ = (bitField0_ & ~0x00000020); + stringValue_ = getDefaultInstance().getStringValue(); + onChanged(); + return this; + } + /** + * optional string string_value = 6; + */ + public Builder setStringValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + stringValue_ = value; + onChanged(); + return this; + } + + private java.lang.Object metricKey_ = ""; + /** + * optional string metric_key = 7; + */ + public boolean hasMetricKey() { + return ((bitField0_ & 0x00000040) == 0x00000040); + } + /** + * optional string metric_key = 7; + */ + public java.lang.String getMetricKey() { + java.lang.Object ref = metricKey_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + metricKey_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string metric_key = 7; + */ + public com.google.protobuf.ByteString + getMetricKeyBytes() { + java.lang.Object ref = metricKey_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + metricKey_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string metric_key = 7; + */ + public Builder setMetricKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + metricKey_ = value; + onChanged(); + return this; + } + /** + * optional string metric_key = 7; + */ + public Builder clearMetricKey() { + bitField0_ = (bitField0_ & ~0x00000040); + metricKey_ = getDefaultInstance().getMetricKey(); + onChanged(); + return this; + } + /** + * optional string metric_key = 7; + */ + public Builder setMetricKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + metricKey_ = value; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * optional string description = 9; + * + *
+       * temporary fields during development of computation stack
+       * 
+ */ + public boolean hasDescription() { + return ((bitField0_ & 0x00000080) == 0x00000080); + } + /** + * optional string description = 9; + * + *
+       * temporary fields during development of computation stack
+       * 
+ */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + description_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string description = 9; + * + *
+       * temporary fields during development of computation stack
+       * 
+ */ + public com.google.protobuf.ByteString + getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string description = 9; + * + *
+       * temporary fields during development of computation stack
+       * 
+ */ + public Builder setDescription( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + description_ = value; + onChanged(); + return this; + } + /** + * optional string description = 9; + * + *
+       * temporary fields during development of computation stack
+       * 
+ */ + public Builder clearDescription() { + bitField0_ = (bitField0_ & ~0x00000080); + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * optional string description = 9; + * + *
+       * temporary fields during development of computation stack
+       * 
+ */ + public Builder setDescriptionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + description_ = value; + onChanged(); + return this; + } + + private java.lang.Object ruleKey_ = ""; + /** + * optional string rule_key = 10; + */ + public boolean hasRuleKey() { + return ((bitField0_ & 0x00000100) == 0x00000100); + } + /** + * optional string rule_key = 10; + */ + public java.lang.String getRuleKey() { + java.lang.Object ref = ruleKey_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ruleKey_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string rule_key = 10; + */ + public com.google.protobuf.ByteString + getRuleKeyBytes() { + java.lang.Object ref = ruleKey_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + ruleKey_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string rule_key = 10; + */ + public Builder setRuleKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + ruleKey_ = value; + onChanged(); + return this; + } + /** + * optional string rule_key = 10; + */ + public Builder clearRuleKey() { + bitField0_ = (bitField0_ & ~0x00000100); + ruleKey_ = getDefaultInstance().getRuleKey(); + onChanged(); + return this; + } + /** + * optional string rule_key = 10; + */ + public Builder setRuleKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + ruleKey_ = value; + onChanged(); + return this; + } + + private org.sonar.batch.protocol.Constants.Severity severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; + /** + * optional .Severity severity = 11; + */ + public boolean hasSeverity() { + return ((bitField0_ & 0x00000200) == 0x00000200); + } + /** + * optional .Severity severity = 11; + */ + public org.sonar.batch.protocol.Constants.Severity getSeverity() { + return severity_; + } + /** + * optional .Severity severity = 11; + */ + public Builder setSeverity(org.sonar.batch.protocol.Constants.Severity value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000200; + severity_ = value; + onChanged(); + return this; + } + /** + * optional .Severity severity = 11; + */ + public Builder clearSeverity() { + bitField0_ = (bitField0_ & ~0x00000200); + severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; + onChanged(); + return this; + } + + private java.lang.Object alertStatus_ = ""; + /** + * optional string alert_status = 12; + */ + public boolean hasAlertStatus() { + return ((bitField0_ & 0x00000400) == 0x00000400); + } + /** + * optional string alert_status = 12; + */ + public java.lang.String getAlertStatus() { + java.lang.Object ref = alertStatus_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + alertStatus_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string alert_status = 12; + */ + public com.google.protobuf.ByteString + getAlertStatusBytes() { + java.lang.Object ref = alertStatus_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + alertStatus_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string alert_status = 12; + */ + public Builder setAlertStatus( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000400; + alertStatus_ = value; + onChanged(); + return this; + } + /** + * optional string alert_status = 12; + */ + public Builder clearAlertStatus() { + bitField0_ = (bitField0_ & ~0x00000400); + alertStatus_ = getDefaultInstance().getAlertStatus(); + onChanged(); + return this; + } + /** + * optional string alert_status = 12; + */ + public Builder setAlertStatusBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000400; + alertStatus_ = value; + onChanged(); + return this; + } + + private java.lang.Object alertText_ = ""; + /** + * optional string alert_text = 13; + */ + public boolean hasAlertText() { + return ((bitField0_ & 0x00000800) == 0x00000800); + } + /** + * optional string alert_text = 13; + */ + public java.lang.String getAlertText() { + java.lang.Object ref = alertText_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + alertText_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string alert_text = 13; + */ + public com.google.protobuf.ByteString + getAlertTextBytes() { + java.lang.Object ref = alertText_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + alertText_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string alert_text = 13; + */ + public Builder setAlertText( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000800; + alertText_ = value; + onChanged(); + return this; + } + /** + * optional string alert_text = 13; + */ + public Builder clearAlertText() { + bitField0_ = (bitField0_ & ~0x00000800); + alertText_ = getDefaultInstance().getAlertText(); + onChanged(); + return this; + } + /** + * optional string alert_text = 13; + */ + public Builder setAlertTextBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000800; + alertText_ = value; + onChanged(); + return this; + } + + private double variationValue1_ ; + /** + * optional double variation_value_1 = 14; + */ + public boolean hasVariationValue1() { + return ((bitField0_ & 0x00001000) == 0x00001000); + } + /** + * optional double variation_value_1 = 14; + */ + public double getVariationValue1() { + return variationValue1_; + } + /** + * optional double variation_value_1 = 14; + */ + public Builder setVariationValue1(double value) { + bitField0_ |= 0x00001000; + variationValue1_ = value; + onChanged(); + return this; + } + /** + * optional double variation_value_1 = 14; + */ + public Builder clearVariationValue1() { + bitField0_ = (bitField0_ & ~0x00001000); + variationValue1_ = 0D; + onChanged(); + return this; + } + + private double variationValue2_ ; + /** + * optional double variation_value_2 = 15; + */ + public boolean hasVariationValue2() { + return ((bitField0_ & 0x00002000) == 0x00002000); + } + /** + * optional double variation_value_2 = 15; + */ + public double getVariationValue2() { + return variationValue2_; + } + /** + * optional double variation_value_2 = 15; + */ + public Builder setVariationValue2(double value) { + bitField0_ |= 0x00002000; + variationValue2_ = value; + onChanged(); + return this; + } + /** + * optional double variation_value_2 = 15; + */ + public Builder clearVariationValue2() { + bitField0_ = (bitField0_ & ~0x00002000); + variationValue2_ = 0D; + onChanged(); + return this; + } + + private double variationValue3_ ; + /** + * optional double variation_value_3 = 16; + */ + public boolean hasVariationValue3() { + return ((bitField0_ & 0x00004000) == 0x00004000); + } + /** + * optional double variation_value_3 = 16; + */ + public double getVariationValue3() { + return variationValue3_; + } + /** + * optional double variation_value_3 = 16; + */ + public Builder setVariationValue3(double value) { + bitField0_ |= 0x00004000; + variationValue3_ = value; + onChanged(); + return this; + } + /** + * optional double variation_value_3 = 16; + */ + public Builder clearVariationValue3() { + bitField0_ = (bitField0_ & ~0x00004000); + variationValue3_ = 0D; + onChanged(); + return this; + } + + private double variationValue4_ ; + /** + * optional double variation_value_4 = 17; + */ + public boolean hasVariationValue4() { + return ((bitField0_ & 0x00008000) == 0x00008000); + } + /** + * optional double variation_value_4 = 17; + */ + public double getVariationValue4() { + return variationValue4_; + } + /** + * optional double variation_value_4 = 17; + */ + public Builder setVariationValue4(double value) { + bitField0_ |= 0x00008000; + variationValue4_ = value; + onChanged(); + return this; + } + /** + * optional double variation_value_4 = 17; + */ + public Builder clearVariationValue4() { + bitField0_ = (bitField0_ & ~0x00008000); + variationValue4_ = 0D; + onChanged(); + return this; + } + + private double variationValue5_ ; + /** + * optional double variation_value_5 = 18; + */ + public boolean hasVariationValue5() { + return ((bitField0_ & 0x00010000) == 0x00010000); + } + /** + * optional double variation_value_5 = 18; + */ + public double getVariationValue5() { + return variationValue5_; + } + /** + * optional double variation_value_5 = 18; + */ + public Builder setVariationValue5(double value) { + bitField0_ |= 0x00010000; + variationValue5_ = value; + onChanged(); + return this; + } + /** + * optional double variation_value_5 = 18; + */ + public Builder clearVariationValue5() { + bitField0_ = (bitField0_ & ~0x00010000); + variationValue5_ = 0D; + onChanged(); + return this; + } + + private int tendency_ ; + /** + * optional int32 tendency = 19; + */ + public boolean hasTendency() { + return ((bitField0_ & 0x00020000) == 0x00020000); + } + /** + * optional int32 tendency = 19; + */ + public int getTendency() { + return tendency_; + } + /** + * optional int32 tendency = 19; + */ + public Builder setTendency(int value) { + bitField0_ |= 0x00020000; + tendency_ = value; + onChanged(); + return this; + } + /** + * optional int32 tendency = 19; + */ + public Builder clearTendency() { + bitField0_ = (bitField0_ & ~0x00020000); + tendency_ = 0; + onChanged(); + return this; + } + + private int charactericId_ ; + /** + * optional int32 characteric_id = 20; + */ + public boolean hasCharactericId() { + return ((bitField0_ & 0x00040000) == 0x00040000); + } + /** + * optional int32 characteric_id = 20; + */ + public int getCharactericId() { + return charactericId_; + } + /** + * optional int32 characteric_id = 20; + */ + public Builder setCharactericId(int value) { + bitField0_ |= 0x00040000; + charactericId_ = value; + onChanged(); + return this; + } + /** + * optional int32 characteric_id = 20; + */ + public Builder clearCharactericId() { + bitField0_ = (bitField0_ & ~0x00040000); + charactericId_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:Measure) + } + + static { + defaultInstance = new Measure(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:Measure) + } + + public interface MeasuresOrBuilder extends + // @@protoc_insertion_point(interface_extends:Measures) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 component_ref = 1; + */ + boolean hasComponentRef(); + /** + * optional int32 component_ref = 1; + */ + int getComponentRef(); + + /** + * repeated .Measure measure = 2; + */ + java.util.List + getMeasureList(); + /** + * repeated .Measure measure = 2; + */ + org.sonar.batch.protocol.output.BatchReport.Measure getMeasure(int index); + /** + * repeated .Measure measure = 2; + */ + int getMeasureCount(); + /** + * repeated .Measure measure = 2; + */ + java.util.List + getMeasureOrBuilderList(); + /** + * repeated .Measure measure = 2; + */ + org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder getMeasureOrBuilder( + int index); + } + /** + * Protobuf type {@code Measures} + */ + public static final class Measures extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Measures) + MeasuresOrBuilder { + // Use Measures.newBuilder() to construct. + private Measures(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Measures(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Measures defaultInstance; + public static Measures getDefaultInstance() { + return defaultInstance; + } + + public Measures getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Measures( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + componentRef_ = input.readInt32(); + break; + } + case 18: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + measure_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + measure_.add(input.readMessage(org.sonar.batch.protocol.output.BatchReport.Measure.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + measure_ = java.util.Collections.unmodifiableList(measure_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.sonar.batch.protocol.output.BatchReport.Measures.class, org.sonar.batch.protocol.output.BatchReport.Measures.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Measures parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Measures(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + public static final int COMPONENT_REF_FIELD_NUMBER = 1; + private int componentRef_; + /** + * optional int32 component_ref = 1; + */ + public boolean hasComponentRef() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * optional int32 component_ref = 1; + */ + public int getComponentRef() { + return componentRef_; + } + + public static final int MEASURE_FIELD_NUMBER = 2; + private java.util.List measure_; + /** + * repeated .Measure measure = 2; + */ + public java.util.List getMeasureList() { + return measure_; + } + /** + * repeated .Measure measure = 2; + */ + public java.util.List + getMeasureOrBuilderList() { + return measure_; + } + /** + * repeated .Measure measure = 2; + */ + public int getMeasureCount() { + return measure_.size(); + } + /** + * repeated .Measure measure = 2; + */ + public org.sonar.batch.protocol.output.BatchReport.Measure getMeasure(int index) { + return measure_.get(index); + } + /** + * repeated .Measure measure = 2; + */ + public org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder getMeasureOrBuilder( + int index) { + return measure_.get(index); + } + + private void initFields() { + componentRef_ = 0; + measure_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeInt32(1, componentRef_); + } + for (int i = 0; i < measure_.size(); i++) { + output.writeMessage(2, measure_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, componentRef_); + } + for (int i = 0; i < measure_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, measure_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.sonar.batch.protocol.output.BatchReport.Measures parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.sonar.batch.protocol.output.BatchReport.Measures prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Measures} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Measures) + org.sonar.batch.protocol.output.BatchReport.MeasuresOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.sonar.batch.protocol.output.BatchReport.Measures.class, org.sonar.batch.protocol.output.BatchReport.Measures.Builder.class); + } + + // Construct using org.sonar.batch.protocol.output.BatchReport.Measures.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getMeasureFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + componentRef_ = 0; + bitField0_ = (bitField0_ & ~0x00000001); + if (measureBuilder_ == null) { + measure_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + } else { + measureBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.sonar.batch.protocol.output.BatchReport.internal_static_Measures_descriptor; + } + + public org.sonar.batch.protocol.output.BatchReport.Measures getDefaultInstanceForType() { + return org.sonar.batch.protocol.output.BatchReport.Measures.getDefaultInstance(); + } + + public org.sonar.batch.protocol.output.BatchReport.Measures build() { + org.sonar.batch.protocol.output.BatchReport.Measures result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.sonar.batch.protocol.output.BatchReport.Measures buildPartial() { + org.sonar.batch.protocol.output.BatchReport.Measures result = new org.sonar.batch.protocol.output.BatchReport.Measures(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.componentRef_ = componentRef_; + if (measureBuilder_ == null) { + if (((bitField0_ & 0x00000002) == 0x00000002)) { + measure_ = java.util.Collections.unmodifiableList(measure_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.measure_ = measure_; + } else { + result.measure_ = measureBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.sonar.batch.protocol.output.BatchReport.Measures) { + return mergeFrom((org.sonar.batch.protocol.output.BatchReport.Measures)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.sonar.batch.protocol.output.BatchReport.Measures other) { + if (other == org.sonar.batch.protocol.output.BatchReport.Measures.getDefaultInstance()) return this; + if (other.hasComponentRef()) { + setComponentRef(other.getComponentRef()); + } + if (measureBuilder_ == null) { + if (!other.measure_.isEmpty()) { + if (measure_.isEmpty()) { + measure_ = other.measure_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureMeasureIsMutable(); + measure_.addAll(other.measure_); + } + onChanged(); + } + } else { + if (!other.measure_.isEmpty()) { + if (measureBuilder_.isEmpty()) { + measureBuilder_.dispose(); + measureBuilder_ = null; + measure_ = other.measure_; + bitField0_ = (bitField0_ & ~0x00000002); + measureBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getMeasureFieldBuilder() : null; + } else { + measureBuilder_.addAllMessages(other.measure_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; } - /** - * optional string uuid = 9; - */ - public java.lang.String getUuid() { - java.lang.Object ref = uuid_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - uuid_ = s; - return s; - } else { - return (java.lang.String) ref; + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.sonar.batch.protocol.output.BatchReport.Measures parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.sonar.batch.protocol.output.BatchReport.Measures) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } } + return this; } + private int bitField0_; + + private int componentRef_ ; /** - * optional string uuid = 9; + * optional int32 component_ref = 1; */ - public com.google.protobuf.ByteString - getUuidBytes() { - java.lang.Object ref = uuid_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - uuid_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public boolean hasComponentRef() { + return ((bitField0_ & 0x00000001) == 0x00000001); } /** - * optional string uuid = 9; + * optional int32 component_ref = 1; */ - public Builder setUuid( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000400; - uuid_ = value; - onChanged(); - return this; + public int getComponentRef() { + return componentRef_; } /** - * optional string uuid = 9; + * optional int32 component_ref = 1; */ - public Builder clearUuid() { - bitField0_ = (bitField0_ & ~0x00000400); - uuid_ = getDefaultInstance().getUuid(); + public Builder setComponentRef(int value) { + bitField0_ |= 0x00000001; + componentRef_ = value; onChanged(); return this; } /** - * optional string uuid = 9; + * optional int32 component_ref = 1; */ - public Builder setUuidBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000400; - uuid_ = value; + public Builder clearComponentRef() { + bitField0_ = (bitField0_ & ~0x00000001); + componentRef_ = 0; onChanged(); return this; } - // repeated .Event event = 11; - private java.util.List event_ = + private java.util.List measure_ = java.util.Collections.emptyList(); - private void ensureEventIsMutable() { - if (!((bitField0_ & 0x00000800) == 0x00000800)) { - event_ = new java.util.ArrayList(event_); - bitField0_ |= 0x00000800; + private void ensureMeasureIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + measure_ = new java.util.ArrayList(measure_); + bitField0_ |= 0x00000002; } } private com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder> eventBuilder_; + org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder> measureBuilder_; /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public java.util.List getEventList() { - if (eventBuilder_ == null) { - return java.util.Collections.unmodifiableList(event_); + public java.util.List getMeasureList() { + if (measureBuilder_ == null) { + return java.util.Collections.unmodifiableList(measure_); } else { - return eventBuilder_.getMessageList(); + return measureBuilder_.getMessageList(); } } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public int getEventCount() { - if (eventBuilder_ == null) { - return event_.size(); + public int getMeasureCount() { + if (measureBuilder_ == null) { + return measure_.size(); } else { - return eventBuilder_.getCount(); + return measureBuilder_.getCount(); } } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public org.sonar.batch.protocol.output.BatchReport.Event getEvent(int index) { - if (eventBuilder_ == null) { - return event_.get(index); + public org.sonar.batch.protocol.output.BatchReport.Measure getMeasure(int index) { + if (measureBuilder_ == null) { + return measure_.get(index); } else { - return eventBuilder_.getMessage(index); + return measureBuilder_.getMessage(index); } } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder setEvent( - int index, org.sonar.batch.protocol.output.BatchReport.Event value) { - if (eventBuilder_ == null) { + public Builder setMeasure( + int index, org.sonar.batch.protocol.output.BatchReport.Measure value) { + if (measureBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - ensureEventIsMutable(); - event_.set(index, value); + ensureMeasureIsMutable(); + measure_.set(index, value); onChanged(); } else { - eventBuilder_.setMessage(index, value); + measureBuilder_.setMessage(index, value); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder setEvent( - int index, org.sonar.batch.protocol.output.BatchReport.Event.Builder builderForValue) { - if (eventBuilder_ == null) { - ensureEventIsMutable(); - event_.set(index, builderForValue.build()); + public Builder setMeasure( + int index, org.sonar.batch.protocol.output.BatchReport.Measure.Builder builderForValue) { + if (measureBuilder_ == null) { + ensureMeasureIsMutable(); + measure_.set(index, builderForValue.build()); onChanged(); } else { - eventBuilder_.setMessage(index, builderForValue.build()); + measureBuilder_.setMessage(index, builderForValue.build()); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder addEvent(org.sonar.batch.protocol.output.BatchReport.Event value) { - if (eventBuilder_ == null) { + public Builder addMeasure(org.sonar.batch.protocol.output.BatchReport.Measure value) { + if (measureBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - ensureEventIsMutable(); - event_.add(value); + ensureMeasureIsMutable(); + measure_.add(value); onChanged(); } else { - eventBuilder_.addMessage(value); + measureBuilder_.addMessage(value); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder addEvent( - int index, org.sonar.batch.protocol.output.BatchReport.Event value) { - if (eventBuilder_ == null) { + public Builder addMeasure( + int index, org.sonar.batch.protocol.output.BatchReport.Measure value) { + if (measureBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - ensureEventIsMutable(); - event_.add(index, value); + ensureMeasureIsMutable(); + measure_.add(index, value); onChanged(); } else { - eventBuilder_.addMessage(index, value); + measureBuilder_.addMessage(index, value); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder addEvent( - org.sonar.batch.protocol.output.BatchReport.Event.Builder builderForValue) { - if (eventBuilder_ == null) { - ensureEventIsMutable(); - event_.add(builderForValue.build()); + public Builder addMeasure( + org.sonar.batch.protocol.output.BatchReport.Measure.Builder builderForValue) { + if (measureBuilder_ == null) { + ensureMeasureIsMutable(); + measure_.add(builderForValue.build()); onChanged(); } else { - eventBuilder_.addMessage(builderForValue.build()); + measureBuilder_.addMessage(builderForValue.build()); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder addEvent( - int index, org.sonar.batch.protocol.output.BatchReport.Event.Builder builderForValue) { - if (eventBuilder_ == null) { - ensureEventIsMutable(); - event_.add(index, builderForValue.build()); + public Builder addMeasure( + int index, org.sonar.batch.protocol.output.BatchReport.Measure.Builder builderForValue) { + if (measureBuilder_ == null) { + ensureMeasureIsMutable(); + measure_.add(index, builderForValue.build()); onChanged(); } else { - eventBuilder_.addMessage(index, builderForValue.build()); + measureBuilder_.addMessage(index, builderForValue.build()); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder addAllEvent( - java.lang.Iterable values) { - if (eventBuilder_ == null) { - ensureEventIsMutable(); - super.addAll(values, event_); + public Builder addAllMeasure( + java.lang.Iterable values) { + if (measureBuilder_ == null) { + ensureMeasureIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, measure_); onChanged(); } else { - eventBuilder_.addAllMessages(values); + measureBuilder_.addAllMessages(values); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder clearEvent() { - if (eventBuilder_ == null) { - event_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000800); + public Builder clearMeasure() { + if (measureBuilder_ == null) { + measure_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); onChanged(); } else { - eventBuilder_.clear(); + measureBuilder_.clear(); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public Builder removeEvent(int index) { - if (eventBuilder_ == null) { - ensureEventIsMutable(); - event_.remove(index); + public Builder removeMeasure(int index) { + if (measureBuilder_ == null) { + ensureMeasureIsMutable(); + measure_.remove(index); onChanged(); } else { - eventBuilder_.remove(index); + measureBuilder_.remove(index); } return this; } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public org.sonar.batch.protocol.output.BatchReport.Event.Builder getEventBuilder( + public org.sonar.batch.protocol.output.BatchReport.Measure.Builder getMeasureBuilder( int index) { - return getEventFieldBuilder().getBuilder(index); + return getMeasureFieldBuilder().getBuilder(index); } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public org.sonar.batch.protocol.output.BatchReport.EventOrBuilder getEventOrBuilder( + public org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder getMeasureOrBuilder( int index) { - if (eventBuilder_ == null) { - return event_.get(index); } else { - return eventBuilder_.getMessageOrBuilder(index); + if (measureBuilder_ == null) { + return measure_.get(index); } else { + return measureBuilder_.getMessageOrBuilder(index); } } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public java.util.List - getEventOrBuilderList() { - if (eventBuilder_ != null) { - return eventBuilder_.getMessageOrBuilderList(); + public java.util.List + getMeasureOrBuilderList() { + if (measureBuilder_ != null) { + return measureBuilder_.getMessageOrBuilderList(); } else { - return java.util.Collections.unmodifiableList(event_); + return java.util.Collections.unmodifiableList(measure_); } } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public org.sonar.batch.protocol.output.BatchReport.Event.Builder addEventBuilder() { - return getEventFieldBuilder().addBuilder( - org.sonar.batch.protocol.output.BatchReport.Event.getDefaultInstance()); + public org.sonar.batch.protocol.output.BatchReport.Measure.Builder addMeasureBuilder() { + return getMeasureFieldBuilder().addBuilder( + org.sonar.batch.protocol.output.BatchReport.Measure.getDefaultInstance()); } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public org.sonar.batch.protocol.output.BatchReport.Event.Builder addEventBuilder( + public org.sonar.batch.protocol.output.BatchReport.Measure.Builder addMeasureBuilder( int index) { - return getEventFieldBuilder().addBuilder( - index, org.sonar.batch.protocol.output.BatchReport.Event.getDefaultInstance()); + return getMeasureFieldBuilder().addBuilder( + index, org.sonar.batch.protocol.output.BatchReport.Measure.getDefaultInstance()); } /** - * repeated .Event event = 11; + * repeated .Measure measure = 2; */ - public java.util.List - getEventBuilderList() { - return getEventFieldBuilder().getBuilderList(); + public java.util.List + getMeasureBuilderList() { + return getMeasureFieldBuilder().getBuilderList(); } private com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder> - getEventFieldBuilder() { - if (eventBuilder_ == null) { - eventBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - org.sonar.batch.protocol.output.BatchReport.Event, org.sonar.batch.protocol.output.BatchReport.Event.Builder, org.sonar.batch.protocol.output.BatchReport.EventOrBuilder>( - event_, - ((bitField0_ & 0x00000800) == 0x00000800), + org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder> + getMeasureFieldBuilder() { + if (measureBuilder_ == null) { + measureBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + org.sonar.batch.protocol.output.BatchReport.Measure, org.sonar.batch.protocol.output.BatchReport.Measure.Builder, org.sonar.batch.protocol.output.BatchReport.MeasureOrBuilder>( + measure_, + ((bitField0_ & 0x00000002) == 0x00000002), getParentForChildren(), isClean()); - event_ = null; + measure_ = null; } - return eventBuilder_; + return measureBuilder_; } - // @@protoc_insertion_point(builder_scope:Component) + // @@protoc_insertion_point(builder_scope:Measures) } static { - defaultInstance = new Component(true); + defaultInstance = new Measures(true); defaultInstance.initFields(); } - // @@protoc_insertion_point(class_scope:Component) + // @@protoc_insertion_point(class_scope:Measures) } - public interface IssueOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface IssueOrBuilder extends + // @@protoc_insertion_point(interface_extends:Issue) + com.google.protobuf.MessageOrBuilder { - // optional string rule_repository = 1; /** * optional string rule_repository = 1; */ @@ -4775,7 +7938,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getRuleRepositoryBytes(); - // optional string rule_key = 2; /** * optional string rule_key = 2; */ @@ -4790,7 +7952,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getRuleKeyBytes(); - // optional int32 line = 3; /** * optional int32 line = 3; */ @@ -4800,7 +7961,6 @@ public interface IssueOrBuilder */ int getLine(); - // optional string msg = 4; /** * optional string msg = 4; */ @@ -4815,7 +7975,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getMsgBytes(); - // optional .Severity severity = 5; /** * optional .Severity severity = 5; */ @@ -4825,12 +7984,11 @@ public interface IssueOrBuilder */ org.sonar.batch.protocol.Constants.Severity getSeverity(); - // repeated string tag = 6; /** * repeated string tag = 6; */ - java.util.List - getTagList(); + com.google.protobuf.ProtocolStringList + getTagList(); /** * repeated string tag = 6; */ @@ -4845,7 +8003,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getTagBytes(int index); - // optional double effort_to_fix = 7; /** * optional double effort_to_fix = 7; * @@ -4863,7 +8020,6 @@ public interface IssueOrBuilder */ double getEffortToFix(); - // optional bool is_new = 8; /** * optional bool is_new = 8; */ @@ -4873,7 +8029,6 @@ public interface IssueOrBuilder */ boolean getIsNew(); - // optional string uuid = 9; /** * optional string uuid = 9; */ @@ -4888,7 +8043,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getUuidBytes(); - // optional int64 debt_in_minutes = 10; /** * optional int64 debt_in_minutes = 10; */ @@ -4898,7 +8052,6 @@ public interface IssueOrBuilder */ long getDebtInMinutes(); - // optional string resolution = 11; /** * optional string resolution = 11; */ @@ -4913,7 +8066,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getResolutionBytes(); - // optional string status = 12; /** * optional string status = 12; */ @@ -4928,7 +8080,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getStatusBytes(); - // optional string checksum = 13; /** * optional string checksum = 13; */ @@ -4943,7 +8094,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getChecksumBytes(); - // optional bool manual_severity = 14; /** * optional bool manual_severity = 14; */ @@ -4953,7 +8103,6 @@ public interface IssueOrBuilder */ boolean getManualSeverity(); - // optional string reporter = 15; /** * optional string reporter = 15; */ @@ -4968,7 +8117,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getReporterBytes(); - // optional string assignee = 16; /** * optional string assignee = 16; */ @@ -4983,7 +8131,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getAssigneeBytes(); - // optional string action_plan_key = 17; /** * optional string action_plan_key = 17; */ @@ -4998,7 +8145,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getActionPlanKeyBytes(); - // optional string attributes = 18; /** * optional string attributes = 18; */ @@ -5013,7 +8159,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getAttributesBytes(); - // optional string author_login = 19; /** * optional string author_login = 19; */ @@ -5028,7 +8173,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getAuthorLoginBytes(); - // optional int64 creation_date = 20; /** * optional int64 creation_date = 20; */ @@ -5038,7 +8182,6 @@ public interface IssueOrBuilder */ long getCreationDate(); - // optional int64 close_date = 21; /** * optional int64 close_date = 21; */ @@ -5048,7 +8191,6 @@ public interface IssueOrBuilder */ long getCloseDate(); - // optional int64 update_date = 22; /** * optional int64 update_date = 22; */ @@ -5058,7 +8200,6 @@ public interface IssueOrBuilder */ long getUpdateDate(); - // optional int64 selected_at = 23; /** * optional int64 selected_at = 23; */ @@ -5068,7 +8209,6 @@ public interface IssueOrBuilder */ long getSelectedAt(); - // optional string diff_fields = 24; /** * optional string diff_fields = 24; */ @@ -5083,7 +8223,6 @@ public interface IssueOrBuilder com.google.protobuf.ByteString getDiffFieldsBytes(); - // optional bool is_changed = 25; /** * optional bool is_changed = 25; */ @@ -5093,7 +8232,6 @@ public interface IssueOrBuilder */ boolean getIsChanged(); - // optional bool must_send_notification = 26; /** * optional bool must_send_notification = 26; */ @@ -5107,8 +8245,9 @@ public interface IssueOrBuilder * Protobuf type {@code Issue} */ public static final class Issue extends - com.google.protobuf.GeneratedMessage - implements IssueOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Issue) + IssueOrBuilder { // Use Issue.newBuilder() to construct. private Issue(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -5155,13 +8294,15 @@ private Issue( break; } case 10: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000001; - ruleRepository_ = input.readBytes(); + ruleRepository_ = bs; break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - ruleKey_ = input.readBytes(); + ruleKey_ = bs; break; } case 24: { @@ -5170,8 +8311,9 @@ private Issue( break; } case 34: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000008; - msg_ = input.readBytes(); + msg_ = bs; break; } case 40: { @@ -5186,11 +8328,12 @@ private Issue( break; } case 50: { + com.google.protobuf.ByteString bs = input.readBytes(); if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { tag_ = new com.google.protobuf.LazyStringArrayList(); mutable_bitField0_ |= 0x00000020; } - tag_.add(input.readBytes()); + tag_.add(bs); break; } case 57: { @@ -5204,8 +8347,9 @@ private Issue( break; } case 74: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000080; - uuid_ = input.readBytes(); + uuid_ = bs; break; } case 80: { @@ -5214,18 +8358,21 @@ private Issue( break; } case 90: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000200; - resolution_ = input.readBytes(); + resolution_ = bs; break; } case 98: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000400; - status_ = input.readBytes(); + status_ = bs; break; } case 106: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000800; - checksum_ = input.readBytes(); + checksum_ = bs; break; } case 112: { @@ -5234,28 +8381,33 @@ private Issue( break; } case 122: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00002000; - reporter_ = input.readBytes(); + reporter_ = bs; break; } case 130: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00004000; - assignee_ = input.readBytes(); + assignee_ = bs; break; } case 138: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00008000; - actionPlanKey_ = input.readBytes(); + actionPlanKey_ = bs; break; } case 146: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00010000; - attributes_ = input.readBytes(); + attributes_ = bs; break; } case 154: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00020000; - authorLogin_ = input.readBytes(); + authorLogin_ = bs; break; } case 160: { @@ -5279,8 +8431,9 @@ private Issue( break; } case 194: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00400000; - diffFields_ = input.readBytes(); + diffFields_ = bs; break; } case 200: { @@ -5302,7 +8455,7 @@ private Issue( e.getMessage()).setUnfinishedMessage(this); } finally { if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - tag_ = new com.google.protobuf.UnmodifiableLazyStringList(tag_); + tag_ = tag_.getUnmodifiableView(); } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); @@ -5336,7 +8489,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional string rule_repository = 1; public static final int RULE_REPOSITORY_FIELD_NUMBER = 1; private java.lang.Object ruleRepository_; /** @@ -5379,7 +8531,6 @@ public java.lang.String getRuleRepository() { } } - // optional string rule_key = 2; public static final int RULE_KEY_FIELD_NUMBER = 2; private java.lang.Object ruleKey_; /** @@ -5422,7 +8573,6 @@ public java.lang.String getRuleKey() { } } - // optional int32 line = 3; public static final int LINE_FIELD_NUMBER = 3; private int line_; /** @@ -5438,7 +8588,6 @@ public int getLine() { return line_; } - // optional string msg = 4; public static final int MSG_FIELD_NUMBER = 4; private java.lang.Object msg_; /** @@ -5481,7 +8630,6 @@ public java.lang.String getMsg() { } } - // optional .Severity severity = 5; public static final int SEVERITY_FIELD_NUMBER = 5; private org.sonar.batch.protocol.Constants.Severity severity_; /** @@ -5497,13 +8645,12 @@ public org.sonar.batch.protocol.Constants.Severity getSeverity() { return severity_; } - // repeated string tag = 6; public static final int TAG_FIELD_NUMBER = 6; private com.google.protobuf.LazyStringList tag_; /** * repeated string tag = 6; */ - public java.util.List + public com.google.protobuf.ProtocolStringList getTagList() { return tag_; } @@ -5527,7 +8674,6 @@ public java.lang.String getTag(int index) { return tag_.getByteString(index); } - // optional double effort_to_fix = 7; public static final int EFFORT_TO_FIX_FIELD_NUMBER = 7; private double effortToFix_; /** @@ -5551,7 +8697,6 @@ public double getEffortToFix() { return effortToFix_; } - // optional bool is_new = 8; public static final int IS_NEW_FIELD_NUMBER = 8; private boolean isNew_; /** @@ -5567,7 +8712,6 @@ public boolean getIsNew() { return isNew_; } - // optional string uuid = 9; public static final int UUID_FIELD_NUMBER = 9; private java.lang.Object uuid_; /** @@ -5610,7 +8754,6 @@ public java.lang.String getUuid() { } } - // optional int64 debt_in_minutes = 10; public static final int DEBT_IN_MINUTES_FIELD_NUMBER = 10; private long debtInMinutes_; /** @@ -5626,7 +8769,6 @@ public long getDebtInMinutes() { return debtInMinutes_; } - // optional string resolution = 11; public static final int RESOLUTION_FIELD_NUMBER = 11; private java.lang.Object resolution_; /** @@ -5669,7 +8811,6 @@ public java.lang.String getResolution() { } } - // optional string status = 12; public static final int STATUS_FIELD_NUMBER = 12; private java.lang.Object status_; /** @@ -5712,7 +8853,6 @@ public java.lang.String getStatus() { } } - // optional string checksum = 13; public static final int CHECKSUM_FIELD_NUMBER = 13; private java.lang.Object checksum_; /** @@ -5755,7 +8895,6 @@ public java.lang.String getChecksum() { } } - // optional bool manual_severity = 14; public static final int MANUAL_SEVERITY_FIELD_NUMBER = 14; private boolean manualSeverity_; /** @@ -5771,7 +8910,6 @@ public boolean getManualSeverity() { return manualSeverity_; } - // optional string reporter = 15; public static final int REPORTER_FIELD_NUMBER = 15; private java.lang.Object reporter_; /** @@ -5814,7 +8952,6 @@ public java.lang.String getReporter() { } } - // optional string assignee = 16; public static final int ASSIGNEE_FIELD_NUMBER = 16; private java.lang.Object assignee_; /** @@ -5857,7 +8994,6 @@ public java.lang.String getAssignee() { } } - // optional string action_plan_key = 17; public static final int ACTION_PLAN_KEY_FIELD_NUMBER = 17; private java.lang.Object actionPlanKey_; /** @@ -5900,7 +9036,6 @@ public java.lang.String getActionPlanKey() { } } - // optional string attributes = 18; public static final int ATTRIBUTES_FIELD_NUMBER = 18; private java.lang.Object attributes_; /** @@ -5943,7 +9078,6 @@ public java.lang.String getAttributes() { } } - // optional string author_login = 19; public static final int AUTHOR_LOGIN_FIELD_NUMBER = 19; private java.lang.Object authorLogin_; /** @@ -5986,7 +9120,6 @@ public java.lang.String getAuthorLogin() { } } - // optional int64 creation_date = 20; public static final int CREATION_DATE_FIELD_NUMBER = 20; private long creationDate_; /** @@ -6002,7 +9135,6 @@ public long getCreationDate() { return creationDate_; } - // optional int64 close_date = 21; public static final int CLOSE_DATE_FIELD_NUMBER = 21; private long closeDate_; /** @@ -6018,7 +9150,6 @@ public long getCloseDate() { return closeDate_; } - // optional int64 update_date = 22; public static final int UPDATE_DATE_FIELD_NUMBER = 22; private long updateDate_; /** @@ -6034,7 +9165,6 @@ public long getUpdateDate() { return updateDate_; } - // optional int64 selected_at = 23; public static final int SELECTED_AT_FIELD_NUMBER = 23; private long selectedAt_; /** @@ -6050,7 +9180,6 @@ public long getSelectedAt() { return selectedAt_; } - // optional string diff_fields = 24; public static final int DIFF_FIELDS_FIELD_NUMBER = 24; private java.lang.Object diffFields_; /** @@ -6093,7 +9222,6 @@ public java.lang.String getDiffFields() { } } - // optional bool is_changed = 25; public static final int IS_CHANGED_FIELD_NUMBER = 25; private boolean isChanged_; /** @@ -6109,7 +9237,6 @@ public boolean getIsChanged() { return isChanged_; } - // optional bool must_send_notification = 26; public static final int MUST_SEND_NOTIFICATION_FIELD_NUMBER = 26; private boolean mustSendNotification_; /** @@ -6156,7 +9283,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -6443,8 +9571,9 @@ protected Builder newBuilderForType( * Protobuf type {@code Issue} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Issue) + org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.output.BatchReport.internal_static_Issue_descriptor; @@ -6578,8 +9707,7 @@ public org.sonar.batch.protocol.output.BatchReport.Issue buildPartial() { } result.severity_ = severity_; if (((bitField0_ & 0x00000020) == 0x00000020)) { - tag_ = new com.google.protobuf.UnmodifiableLazyStringList( - tag_); + tag_ = tag_.getUnmodifiableView(); bitField0_ = (bitField0_ & ~0x00000020); } result.tag_ = tag_; @@ -6817,7 +9945,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional string rule_repository = 1; private java.lang.Object ruleRepository_ = ""; /** * optional string rule_repository = 1; @@ -6831,9 +9958,12 @@ public boolean hasRuleRepository() { public java.lang.String getRuleRepository() { java.lang.Object ref = ruleRepository_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - ruleRepository_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ruleRepository_ = s; + } return s; } else { return (java.lang.String) ref; @@ -6891,7 +10021,6 @@ public Builder setRuleRepositoryBytes( return this; } - // optional string rule_key = 2; private java.lang.Object ruleKey_ = ""; /** * optional string rule_key = 2; @@ -6905,9 +10034,12 @@ public boolean hasRuleKey() { public java.lang.String getRuleKey() { java.lang.Object ref = ruleKey_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - ruleKey_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + ruleKey_ = s; + } return s; } else { return (java.lang.String) ref; @@ -6965,7 +10097,6 @@ public Builder setRuleKeyBytes( return this; } - // optional int32 line = 3; private int line_ ; /** * optional int32 line = 3; @@ -6998,7 +10129,6 @@ public Builder clearLine() { return this; } - // optional string msg = 4; private java.lang.Object msg_ = ""; /** * optional string msg = 4; @@ -7012,9 +10142,12 @@ public boolean hasMsg() { public java.lang.String getMsg() { java.lang.Object ref = msg_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - msg_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + msg_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7072,7 +10205,6 @@ public Builder setMsgBytes( return this; } - // optional .Severity severity = 5; private org.sonar.batch.protocol.Constants.Severity severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; /** * optional .Severity severity = 5; @@ -7108,7 +10240,6 @@ public Builder clearSeverity() { return this; } - // repeated string tag = 6; private com.google.protobuf.LazyStringList tag_ = com.google.protobuf.LazyStringArrayList.EMPTY; private void ensureTagIsMutable() { if (!((bitField0_ & 0x00000020) == 0x00000020)) { @@ -7119,9 +10250,9 @@ private void ensureTagIsMutable() { /** * repeated string tag = 6; */ - public java.util.List + public com.google.protobuf.ProtocolStringList getTagList() { - return java.util.Collections.unmodifiableList(tag_); + return tag_.getUnmodifiableView(); } /** * repeated string tag = 6; @@ -7174,7 +10305,8 @@ public Builder addTag( public Builder addAllTag( java.lang.Iterable values) { ensureTagIsMutable(); - super.addAll(values, tag_); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, tag_); onChanged(); return this; } @@ -7201,7 +10333,6 @@ public Builder addTagBytes( return this; } - // optional double effort_to_fix = 7; private double effortToFix_ ; /** * optional double effort_to_fix = 7; @@ -7250,7 +10381,6 @@ public Builder clearEffortToFix() { return this; } - // optional bool is_new = 8; private boolean isNew_ ; /** * optional bool is_new = 8; @@ -7283,7 +10413,6 @@ public Builder clearIsNew() { return this; } - // optional string uuid = 9; private java.lang.Object uuid_ = ""; /** * optional string uuid = 9; @@ -7297,9 +10426,12 @@ public boolean hasUuid() { public java.lang.String getUuid() { java.lang.Object ref = uuid_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - uuid_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + uuid_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7357,7 +10489,6 @@ public Builder setUuidBytes( return this; } - // optional int64 debt_in_minutes = 10; private long debtInMinutes_ ; /** * optional int64 debt_in_minutes = 10; @@ -7390,7 +10521,6 @@ public Builder clearDebtInMinutes() { return this; } - // optional string resolution = 11; private java.lang.Object resolution_ = ""; /** * optional string resolution = 11; @@ -7404,9 +10534,12 @@ public boolean hasResolution() { public java.lang.String getResolution() { java.lang.Object ref = resolution_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - resolution_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + resolution_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7464,7 +10597,6 @@ public Builder setResolutionBytes( return this; } - // optional string status = 12; private java.lang.Object status_ = ""; /** * optional string status = 12; @@ -7478,9 +10610,12 @@ public boolean hasStatus() { public java.lang.String getStatus() { java.lang.Object ref = status_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - status_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + status_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7538,7 +10673,6 @@ public Builder setStatusBytes( return this; } - // optional string checksum = 13; private java.lang.Object checksum_ = ""; /** * optional string checksum = 13; @@ -7552,9 +10686,12 @@ public boolean hasChecksum() { public java.lang.String getChecksum() { java.lang.Object ref = checksum_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - checksum_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + checksum_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7612,7 +10749,6 @@ public Builder setChecksumBytes( return this; } - // optional bool manual_severity = 14; private boolean manualSeverity_ ; /** * optional bool manual_severity = 14; @@ -7645,7 +10781,6 @@ public Builder clearManualSeverity() { return this; } - // optional string reporter = 15; private java.lang.Object reporter_ = ""; /** * optional string reporter = 15; @@ -7659,9 +10794,12 @@ public boolean hasReporter() { public java.lang.String getReporter() { java.lang.Object ref = reporter_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - reporter_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + reporter_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7719,7 +10857,6 @@ public Builder setReporterBytes( return this; } - // optional string assignee = 16; private java.lang.Object assignee_ = ""; /** * optional string assignee = 16; @@ -7733,9 +10870,12 @@ public boolean hasAssignee() { public java.lang.String getAssignee() { java.lang.Object ref = assignee_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - assignee_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + assignee_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7793,7 +10933,6 @@ public Builder setAssigneeBytes( return this; } - // optional string action_plan_key = 17; private java.lang.Object actionPlanKey_ = ""; /** * optional string action_plan_key = 17; @@ -7807,9 +10946,12 @@ public boolean hasActionPlanKey() { public java.lang.String getActionPlanKey() { java.lang.Object ref = actionPlanKey_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - actionPlanKey_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + actionPlanKey_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7867,7 +11009,6 @@ public Builder setActionPlanKeyBytes( return this; } - // optional string attributes = 18; private java.lang.Object attributes_ = ""; /** * optional string attributes = 18; @@ -7881,9 +11022,12 @@ public boolean hasAttributes() { public java.lang.String getAttributes() { java.lang.Object ref = attributes_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - attributes_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + attributes_ = s; + } return s; } else { return (java.lang.String) ref; @@ -7941,7 +11085,6 @@ public Builder setAttributesBytes( return this; } - // optional string author_login = 19; private java.lang.Object authorLogin_ = ""; /** * optional string author_login = 19; @@ -7955,9 +11098,12 @@ public boolean hasAuthorLogin() { public java.lang.String getAuthorLogin() { java.lang.Object ref = authorLogin_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - authorLogin_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + authorLogin_ = s; + } return s; } else { return (java.lang.String) ref; @@ -8015,7 +11161,6 @@ public Builder setAuthorLoginBytes( return this; } - // optional int64 creation_date = 20; private long creationDate_ ; /** * optional int64 creation_date = 20; @@ -8048,7 +11193,6 @@ public Builder clearCreationDate() { return this; } - // optional int64 close_date = 21; private long closeDate_ ; /** * optional int64 close_date = 21; @@ -8081,7 +11225,6 @@ public Builder clearCloseDate() { return this; } - // optional int64 update_date = 22; private long updateDate_ ; /** * optional int64 update_date = 22; @@ -8114,7 +11257,6 @@ public Builder clearUpdateDate() { return this; } - // optional int64 selected_at = 23; private long selectedAt_ ; /** * optional int64 selected_at = 23; @@ -8147,7 +11289,6 @@ public Builder clearSelectedAt() { return this; } - // optional string diff_fields = 24; private java.lang.Object diffFields_ = ""; /** * optional string diff_fields = 24; @@ -8161,9 +11302,12 @@ public boolean hasDiffFields() { public java.lang.String getDiffFields() { java.lang.Object ref = diffFields_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - diffFields_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + diffFields_ = s; + } return s; } else { return (java.lang.String) ref; @@ -8221,7 +11365,6 @@ public Builder setDiffFieldsBytes( return this; } - // optional bool is_changed = 25; private boolean isChanged_ ; /** * optional bool is_changed = 25; @@ -8254,7 +11397,6 @@ public Builder clearIsChanged() { return this; } - // optional bool must_send_notification = 26; private boolean mustSendNotification_ ; /** * optional bool must_send_notification = 26; @@ -8298,10 +11440,10 @@ public Builder clearMustSendNotification() { // @@protoc_insertion_point(class_scope:Issue) } - public interface IssuesOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface IssuesOrBuilder extends + // @@protoc_insertion_point(interface_extends:Issues) + com.google.protobuf.MessageOrBuilder { - // optional int32 component_ref = 1; /** * optional int32 component_ref = 1; */ @@ -8311,7 +11453,6 @@ public interface IssuesOrBuilder */ int getComponentRef(); - // repeated .Issue issue = 2; /** * repeated .Issue issue = 2; */ @@ -8336,7 +11477,6 @@ public interface IssuesOrBuilder org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder getIssueOrBuilder( int index); - // optional string component_uuid = 3; /** * optional string component_uuid = 3; * @@ -8367,8 +11507,9 @@ org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder getIssueOrBuilder( * Protobuf type {@code Issues} */ public static final class Issues extends - com.google.protobuf.GeneratedMessage - implements IssuesOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:Issues) + IssuesOrBuilder { // Use Issues.newBuilder() to construct. private Issues(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -8428,8 +11569,9 @@ private Issues( break; } case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - componentUuid_ = input.readBytes(); + componentUuid_ = bs; break; } } @@ -8475,7 +11617,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional int32 component_ref = 1; public static final int COMPONENT_REF_FIELD_NUMBER = 1; private int componentRef_; /** @@ -8491,7 +11632,6 @@ public int getComponentRef() { return componentRef_; } - // repeated .Issue issue = 2; public static final int ISSUE_FIELD_NUMBER = 2; private java.util.List issue_; /** @@ -8527,7 +11667,6 @@ public org.sonar.batch.protocol.output.BatchReport.IssueOrBuilder getIssueOrBuil return issue_.get(index); } - // optional string component_uuid = 3; public static final int COMPONENT_UUID_FIELD_NUMBER = 3; private java.lang.Object componentUuid_; /** @@ -8590,7 +11729,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -8711,8 +11851,9 @@ protected Builder newBuilderForType( * Protobuf type {@code Issues} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.batch.protocol.output.BatchReport.IssuesOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:Issues) + org.sonar.batch.protocol.output.BatchReport.IssuesOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.batch.protocol.output.BatchReport.internal_static_Issues_descriptor; @@ -8878,7 +12019,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional int32 component_ref = 1; private int componentRef_ ; /** * optional int32 component_ref = 1; @@ -8911,7 +12051,6 @@ public Builder clearComponentRef() { return this; } - // repeated .Issue issue = 2; private java.util.List issue_ = java.util.Collections.emptyList(); private void ensureIssueIsMutable() { @@ -9053,7 +12192,8 @@ public Builder addAllIssue( java.lang.Iterable values) { if (issueBuilder_ == null) { ensureIssueIsMutable(); - super.addAll(values, issue_); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, issue_); onChanged(); } else { issueBuilder_.addAllMessages(values); @@ -9151,7 +12291,6 @@ public org.sonar.batch.protocol.output.BatchReport.Issue.Builder addIssueBuilder return issueBuilder_; } - // optional string component_uuid = 3; private java.lang.Object componentUuid_ = ""; /** * optional string component_uuid = 3; @@ -9173,9 +12312,12 @@ public boolean hasComponentUuid() { public java.lang.String getComponentUuid() { java.lang.Object ref = componentUuid_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - componentUuid_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + componentUuid_ = s; + } return s; } else { return (java.lang.String) ref; @@ -9260,32 +12402,42 @@ public Builder setComponentUuidBytes( // @@protoc_insertion_point(class_scope:Issues) } - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_Metadata_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_Metadata_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_ComponentLink_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_ComponentLink_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_Event_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_Event_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_Component_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_Component_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Measure_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_Measure_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Measures_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_Measures_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_Issue_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_Issue_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_Issues_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable @@ -9308,79 +12460,106 @@ public Builder setComponentUuidBytes( "(\t\"w\n\005Event\022\025\n\rcomponent_ref\030\001 \001(\005\022\014\n\004na" + "me\030\002 \001(\t\022\023\n\013description\030\003 \001(\t\022 \n\010categor" + "y\030\004 \001(\0162\016.EventCategory\022\022\n\nevent_data\030\005 " + - "\001(\t\"\365\001\n\tComponent\022\013\n\003ref\030\001 \001(\005\022\014\n\004path\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\004type\030\004 \001(\0162\016.Compo" + "nentType\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\n \003(\013" + - "2\016.ComponentLink\022\017\n\007version\030\014 \001(\t\022\023\n\013sna" + - "pshot_id\030\010 \001(\003\022\014\n\004uuid\030\t \001(\t\022\025\n\005event\030\013 " + - "\003(\0132\006.Event\"\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\006" + - "is_new\030\010 \001(\010\022\014\n\004uuid\030\t \001(\t\022\027\n\017debt_in_mi", - "nutes\030\n \001(\003\022\022\n\nresolution\030\013 \001(\t\022\016\n\006statu" + - "s\030\014 \001(\t\022\020\n\010checksum\030\r \001(\t\022\027\n\017manual_seve" + - "rity\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\nattri" + - "butes\030\022 \001(\t\022\024\n\014author_login\030\023 \001(\t\022\025\n\rcre" + - "ation_date\030\024 \001(\003\022\022\n\nclose_date\030\025 \001(\003\022\023\n\013" + - "update_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\026must_send_notification\030\032 \001(\010\"N\n\006Issue" + - "s\022\025\n\rcomponent_ref\030\001 \001(\005\022\025\n\005issue\030\002 \003(\0132", - "\006.Issue\022\026\n\016component_uuid\030\003 \001(\tB#\n\037org.s" + - "onar.batch.protocol.outputH\001" + "2\016.ComponentLink\022\017\n\007version\030\014 \001(\t\022\n\n\002id\030" + + "\r \001(\003\022\023\n\013snapshot_id\030\010 \001(\003\022\014\n\004uuid\030\t \001(\t" + + "\022\025\n\005event\030\013 \003(\0132\006.Event\"\315\003\n\007Measure\022%\n\nv" + + "alue_type\030\001 \001(\0162\021.MeasureValueType\022\025\n\rbo" + + "olean_value\030\002 \001(\010\022\021\n\tint_value\030\003 \001(\005\022\022\n\n" + + "long_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\nmetric_key\030\007 \001(\t", + "\022\023\n\013description\030\t \001(\t\022\020\n\010rule_key\030\n \001(\t\022" + + "\033\n\010severity\030\013 \001(\0162\t.Severity\022\024\n\014alert_st" + + "atus\030\014 \001(\t\022\022\n\nalert_text\030\r \001(\t\022\031\n\021variat" + + "ion_value_1\030\016 \001(\001\022\031\n\021variation_value_2\030\017" + + " \001(\001\022\031\n\021variation_value_3\030\020 \001(\001\022\031\n\021varia" + + "tion_value_4\030\021 \001(\001\022\031\n\021variation_value_5\030" + + "\022 \001(\001\022\020\n\010tendency\030\023 \001(\005\022\026\n\016characteric_i" + + "d\030\024 \001(\005\"<\n\010Measures\022\025\n\rcomponent_ref\030\001 \001" + + "(\005\022\031\n\007measure\030\002 \003(\0132\010.Measure\"\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\010severit" + + "y\030\005 \001(\0162\t.Severity\022\013\n\003tag\030\006 \003(\t\022\025\n\reffor" + + "t_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\nresolut" + + "ion\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\ncl" + + "ose_date\030\025 \001(\003\022\023\n\013update_date\030\026 \001(\003\022\023\n\013s", + "elected_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\026must_send_notificat" + + "ion\030\032 \001(\010\"N\n\006Issues\022\025\n\rcomponent_ref\030\001 \001" + + "(\005\022\025\n\005issue\030\002 \003(\0132\006.Issue\022\026\n\016component_u" + + "uid\030\003 \001(\tB#\n\037org.sonar.batch.protocol.ou" + + "tputH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_Metadata_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_Metadata_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_Metadata_descriptor, - new java.lang.String[] { "AnalysisDate", "ProjectKey", "RootComponentRef", "SnapshotId", "DeletedComponentsCount", }); - internal_static_ComponentLink_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_ComponentLink_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_ComponentLink_descriptor, - new java.lang.String[] { "Type", "Href", }); - internal_static_Event_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_Event_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_Event_descriptor, - new java.lang.String[] { "ComponentRef", "Name", "Description", "Category", "EventData", }); - internal_static_Component_descriptor = - getDescriptor().getMessageTypes().get(3); - 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", "SnapshotId", "Uuid", "Event", }); - internal_static_Issue_descriptor = - getDescriptor().getMessageTypes().get(4); - internal_static_Issue_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_Issue_descriptor, - new java.lang.String[] { "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "Tag", "EffortToFix", "IsNew", "Uuid", "DebtInMinutes", "Resolution", "Status", "Checksum", "ManualSeverity", "Reporter", "Assignee", "ActionPlanKey", "Attributes", "AuthorLogin", "CreationDate", "CloseDate", "UpdateDate", "SelectedAt", "DiffFields", "IsChanged", "MustSendNotification", }); - internal_static_Issues_descriptor = - getDescriptor().getMessageTypes().get(5); - internal_static_Issues_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_Issues_descriptor, - new java.lang.String[] { "ComponentRef", "Issue", "ComponentUuid", }); - return null; - } - }; + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { org.sonar.batch.protocol.Constants.getDescriptor(), }, assigner); + internal_static_Metadata_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Metadata_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Metadata_descriptor, + new java.lang.String[] { "AnalysisDate", "ProjectKey", "RootComponentRef", "SnapshotId", "DeletedComponentsCount", }); + internal_static_ComponentLink_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_ComponentLink_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_ComponentLink_descriptor, + new java.lang.String[] { "Type", "Href", }); + internal_static_Event_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_Event_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Event_descriptor, + new java.lang.String[] { "ComponentRef", "Name", "Description", "Category", "EventData", }); + internal_static_Component_descriptor = + getDescriptor().getMessageTypes().get(3); + 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", "Id", "SnapshotId", "Uuid", "Event", }); + internal_static_Measure_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_Measure_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Measure_descriptor, + new java.lang.String[] { "ValueType", "BooleanValue", "IntValue", "LongValue", "DoubleValue", "StringValue", "MetricKey", "Description", "RuleKey", "Severity", "AlertStatus", "AlertText", "VariationValue1", "VariationValue2", "VariationValue3", "VariationValue4", "VariationValue5", "Tendency", "CharactericId", }); + internal_static_Measures_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_Measures_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Measures_descriptor, + new java.lang.String[] { "ComponentRef", "Measure", }); + internal_static_Issue_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_Issue_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Issue_descriptor, + new java.lang.String[] { "RuleRepository", "RuleKey", "Line", "Msg", "Severity", "Tag", "EffortToFix", "IsNew", "Uuid", "DebtInMinutes", "Resolution", "Status", "Checksum", "ManualSeverity", "Reporter", "Assignee", "ActionPlanKey", "Attributes", "AuthorLogin", "CreationDate", "CloseDate", "UpdateDate", "SelectedAt", "DiffFields", "IsChanged", "MustSendNotification", }); + internal_static_Issues_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_Issues_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Issues_descriptor, + new java.lang.String[] { "ComponentRef", "Issue", "ComponentUuid", }); + org.sonar.batch.protocol.Constants.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java index 6603bc8ef050..8dad4b4b2b6a 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/server/source/db/FileSourceDb.java @@ -8,10 +8,10 @@ private FileSourceDb() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { } - public interface LineOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface LineOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.sonar.server.source.db.Line) + com.google.protobuf.MessageOrBuilder { - // optional int32 line = 1; /** * optional int32 line = 1; */ @@ -21,7 +21,6 @@ public interface LineOrBuilder */ int getLine(); - // optional string source = 2; /** * optional string source = 2; */ @@ -36,7 +35,6 @@ public interface LineOrBuilder com.google.protobuf.ByteString getSourceBytes(); - // optional string scm_revision = 3; /** * optional string scm_revision = 3; * @@ -63,7 +61,6 @@ public interface LineOrBuilder com.google.protobuf.ByteString getScmRevisionBytes(); - // optional string scm_author = 4; /** * optional string scm_author = 4; */ @@ -78,7 +75,6 @@ public interface LineOrBuilder com.google.protobuf.ByteString getScmAuthorBytes(); - // optional int64 scm_date = 5; /** * optional int64 scm_date = 5; */ @@ -88,7 +84,6 @@ public interface LineOrBuilder */ long getScmDate(); - // optional int32 ut_line_hits = 6; /** * optional int32 ut_line_hits = 6; * @@ -106,7 +101,6 @@ public interface LineOrBuilder */ int getUtLineHits(); - // optional int32 ut_conditions = 7; /** * optional int32 ut_conditions = 7; */ @@ -116,7 +110,6 @@ public interface LineOrBuilder */ int getUtConditions(); - // optional int32 ut_covered_conditions = 8; /** * optional int32 ut_covered_conditions = 8; */ @@ -126,7 +119,6 @@ public interface LineOrBuilder */ int getUtCoveredConditions(); - // optional int32 it_line_hits = 9; /** * optional int32 it_line_hits = 9; * @@ -144,7 +136,6 @@ public interface LineOrBuilder */ int getItLineHits(); - // optional int32 it_conditions = 10; /** * optional int32 it_conditions = 10; */ @@ -154,7 +145,6 @@ public interface LineOrBuilder */ int getItConditions(); - // optional int32 it_covered_conditions = 11; /** * optional int32 it_covered_conditions = 11; */ @@ -164,7 +154,6 @@ public interface LineOrBuilder */ int getItCoveredConditions(); - // optional int32 overall_line_hits = 12; /** * optional int32 overall_line_hits = 12; * @@ -182,7 +171,6 @@ public interface LineOrBuilder */ int getOverallLineHits(); - // optional int32 overall_conditions = 13; /** * optional int32 overall_conditions = 13; */ @@ -192,7 +180,6 @@ public interface LineOrBuilder */ int getOverallConditions(); - // optional int32 overall_covered_conditions = 14; /** * optional int32 overall_covered_conditions = 14; */ @@ -202,7 +189,6 @@ public interface LineOrBuilder */ int getOverallCoveredConditions(); - // optional string highlighting = 15; /** * optional string highlighting = 15; */ @@ -217,7 +203,6 @@ public interface LineOrBuilder com.google.protobuf.ByteString getHighlightingBytes(); - // optional string symbols = 16; /** * optional string symbols = 16; */ @@ -232,7 +217,6 @@ public interface LineOrBuilder com.google.protobuf.ByteString getSymbolsBytes(); - // repeated int32 duplication = 17 [packed = true]; /** * repeated int32 duplication = 17 [packed = true]; */ @@ -250,8 +234,9 @@ public interface LineOrBuilder * Protobuf type {@code org.sonar.server.source.db.Line} */ public static final class Line extends - com.google.protobuf.GeneratedMessage - implements LineOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:org.sonar.server.source.db.Line) + LineOrBuilder { // Use Line.newBuilder() to construct. private Line(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -303,18 +288,21 @@ private Line( break; } case 18: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000002; - source_ = input.readBytes(); + source_ = bs; break; } case 26: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000004; - scmRevision_ = input.readBytes(); + scmRevision_ = bs; break; } case 34: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00000008; - scmAuthor_ = input.readBytes(); + scmAuthor_ = bs; break; } case 40: { @@ -368,13 +356,15 @@ private Line( break; } case 122: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00004000; - highlighting_ = input.readBytes(); + highlighting_ = bs; break; } case 130: { + com.google.protobuf.ByteString bs = input.readBytes(); bitField0_ |= 0x00008000; - symbols_ = input.readBytes(); + symbols_ = bs; break; } case 136: { @@ -441,7 +431,6 @@ public com.google.protobuf.Parser getParserForType() { } private int bitField0_; - // optional int32 line = 1; public static final int LINE_FIELD_NUMBER = 1; private int line_; /** @@ -457,7 +446,6 @@ public int getLine() { return line_; } - // optional string source = 2; public static final int SOURCE_FIELD_NUMBER = 2; private java.lang.Object source_; /** @@ -500,7 +488,6 @@ public java.lang.String getSource() { } } - // optional string scm_revision = 3; public static final int SCM_REVISION_FIELD_NUMBER = 3; private java.lang.Object scmRevision_; /** @@ -555,7 +542,6 @@ public java.lang.String getScmRevision() { } } - // optional string scm_author = 4; public static final int SCM_AUTHOR_FIELD_NUMBER = 4; private java.lang.Object scmAuthor_; /** @@ -598,7 +584,6 @@ public java.lang.String getScmAuthor() { } } - // optional int64 scm_date = 5; public static final int SCM_DATE_FIELD_NUMBER = 5; private long scmDate_; /** @@ -614,7 +599,6 @@ public long getScmDate() { return scmDate_; } - // optional int32 ut_line_hits = 6; public static final int UT_LINE_HITS_FIELD_NUMBER = 6; private int utLineHits_; /** @@ -638,7 +622,6 @@ public int getUtLineHits() { return utLineHits_; } - // optional int32 ut_conditions = 7; public static final int UT_CONDITIONS_FIELD_NUMBER = 7; private int utConditions_; /** @@ -654,7 +637,6 @@ public int getUtConditions() { return utConditions_; } - // optional int32 ut_covered_conditions = 8; public static final int UT_COVERED_CONDITIONS_FIELD_NUMBER = 8; private int utCoveredConditions_; /** @@ -670,7 +652,6 @@ public int getUtCoveredConditions() { return utCoveredConditions_; } - // optional int32 it_line_hits = 9; public static final int IT_LINE_HITS_FIELD_NUMBER = 9; private int itLineHits_; /** @@ -694,7 +675,6 @@ public int getItLineHits() { return itLineHits_; } - // optional int32 it_conditions = 10; public static final int IT_CONDITIONS_FIELD_NUMBER = 10; private int itConditions_; /** @@ -710,7 +690,6 @@ public int getItConditions() { return itConditions_; } - // optional int32 it_covered_conditions = 11; public static final int IT_COVERED_CONDITIONS_FIELD_NUMBER = 11; private int itCoveredConditions_; /** @@ -726,7 +705,6 @@ public int getItCoveredConditions() { return itCoveredConditions_; } - // optional int32 overall_line_hits = 12; public static final int OVERALL_LINE_HITS_FIELD_NUMBER = 12; private int overallLineHits_; /** @@ -750,7 +728,6 @@ public int getOverallLineHits() { return overallLineHits_; } - // optional int32 overall_conditions = 13; public static final int OVERALL_CONDITIONS_FIELD_NUMBER = 13; private int overallConditions_; /** @@ -766,7 +743,6 @@ public int getOverallConditions() { return overallConditions_; } - // optional int32 overall_covered_conditions = 14; public static final int OVERALL_COVERED_CONDITIONS_FIELD_NUMBER = 14; private int overallCoveredConditions_; /** @@ -782,7 +758,6 @@ public int getOverallCoveredConditions() { return overallCoveredConditions_; } - // optional string highlighting = 15; public static final int HIGHLIGHTING_FIELD_NUMBER = 15; private java.lang.Object highlighting_; /** @@ -825,7 +800,6 @@ public java.lang.String getHighlighting() { } } - // optional string symbols = 16; public static final int SYMBOLS_FIELD_NUMBER = 16; private java.lang.Object symbols_; /** @@ -868,7 +842,6 @@ public java.lang.String getSymbols() { } } - // repeated int32 duplication = 17 [packed = true]; public static final int DUPLICATION_FIELD_NUMBER = 17; private java.util.List duplication_; /** @@ -914,7 +887,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -1147,8 +1121,9 @@ protected Builder newBuilderForType( * Protobuf type {@code org.sonar.server.source.db.Line} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.server.source.db.FileSourceDb.LineOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:org.sonar.server.source.db.Line) + org.sonar.server.source.db.FileSourceDb.LineOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.server.source.db.FileSourceDb.internal_static_org_sonar_server_source_db_Line_descriptor; @@ -1423,7 +1398,6 @@ public Builder mergeFrom( } private int bitField0_; - // optional int32 line = 1; private int line_ ; /** * optional int32 line = 1; @@ -1456,7 +1430,6 @@ public Builder clearLine() { return this; } - // optional string source = 2; private java.lang.Object source_ = ""; /** * optional string source = 2; @@ -1470,9 +1443,12 @@ public boolean hasSource() { public java.lang.String getSource() { java.lang.Object ref = source_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - source_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + source_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1530,7 +1506,6 @@ public Builder setSourceBytes( return this; } - // optional string scm_revision = 3; private java.lang.Object scmRevision_ = ""; /** * optional string scm_revision = 3; @@ -1552,9 +1527,12 @@ public boolean hasScmRevision() { public java.lang.String getScmRevision() { java.lang.Object ref = scmRevision_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - scmRevision_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + scmRevision_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1628,7 +1606,6 @@ public Builder setScmRevisionBytes( return this; } - // optional string scm_author = 4; private java.lang.Object scmAuthor_ = ""; /** * optional string scm_author = 4; @@ -1642,9 +1619,12 @@ public boolean hasScmAuthor() { public java.lang.String getScmAuthor() { java.lang.Object ref = scmAuthor_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - scmAuthor_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + scmAuthor_ = s; + } return s; } else { return (java.lang.String) ref; @@ -1702,7 +1682,6 @@ public Builder setScmAuthorBytes( return this; } - // optional int64 scm_date = 5; private long scmDate_ ; /** * optional int64 scm_date = 5; @@ -1735,7 +1714,6 @@ public Builder clearScmDate() { return this; } - // optional int32 ut_line_hits = 6; private int utLineHits_ ; /** * optional int32 ut_line_hits = 6; @@ -1784,7 +1762,6 @@ public Builder clearUtLineHits() { return this; } - // optional int32 ut_conditions = 7; private int utConditions_ ; /** * optional int32 ut_conditions = 7; @@ -1817,7 +1794,6 @@ public Builder clearUtConditions() { return this; } - // optional int32 ut_covered_conditions = 8; private int utCoveredConditions_ ; /** * optional int32 ut_covered_conditions = 8; @@ -1850,7 +1826,6 @@ public Builder clearUtCoveredConditions() { return this; } - // optional int32 it_line_hits = 9; private int itLineHits_ ; /** * optional int32 it_line_hits = 9; @@ -1899,7 +1874,6 @@ public Builder clearItLineHits() { return this; } - // optional int32 it_conditions = 10; private int itConditions_ ; /** * optional int32 it_conditions = 10; @@ -1932,7 +1906,6 @@ public Builder clearItConditions() { return this; } - // optional int32 it_covered_conditions = 11; private int itCoveredConditions_ ; /** * optional int32 it_covered_conditions = 11; @@ -1965,7 +1938,6 @@ public Builder clearItCoveredConditions() { return this; } - // optional int32 overall_line_hits = 12; private int overallLineHits_ ; /** * optional int32 overall_line_hits = 12; @@ -2014,7 +1986,6 @@ public Builder clearOverallLineHits() { return this; } - // optional int32 overall_conditions = 13; private int overallConditions_ ; /** * optional int32 overall_conditions = 13; @@ -2047,7 +2018,6 @@ public Builder clearOverallConditions() { return this; } - // optional int32 overall_covered_conditions = 14; private int overallCoveredConditions_ ; /** * optional int32 overall_covered_conditions = 14; @@ -2080,7 +2050,6 @@ public Builder clearOverallCoveredConditions() { return this; } - // optional string highlighting = 15; private java.lang.Object highlighting_ = ""; /** * optional string highlighting = 15; @@ -2094,9 +2063,12 @@ public boolean hasHighlighting() { public java.lang.String getHighlighting() { java.lang.Object ref = highlighting_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - highlighting_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + highlighting_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2154,7 +2126,6 @@ public Builder setHighlightingBytes( return this; } - // optional string symbols = 16; private java.lang.Object symbols_ = ""; /** * optional string symbols = 16; @@ -2168,9 +2139,12 @@ public boolean hasSymbols() { public java.lang.String getSymbols() { java.lang.Object ref = symbols_; if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - symbols_ = s; + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + symbols_ = s; + } return s; } else { return (java.lang.String) ref; @@ -2228,7 +2202,6 @@ public Builder setSymbolsBytes( return this; } - // repeated int32 duplication = 17 [packed = true]; private java.util.List duplication_ = java.util.Collections.emptyList(); private void ensureDuplicationIsMutable() { if (!((bitField0_ & 0x00010000) == 0x00010000)) { @@ -2280,7 +2253,8 @@ public Builder addDuplication(int value) { public Builder addAllDuplication( java.lang.Iterable values) { ensureDuplicationIsMutable(); - super.addAll(values, duplication_); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, duplication_); onChanged(); return this; } @@ -2305,10 +2279,10 @@ public Builder clearDuplication() { // @@protoc_insertion_point(class_scope:org.sonar.server.source.db.Line) } - public interface DataOrBuilder - extends com.google.protobuf.MessageOrBuilder { + public interface DataOrBuilder extends + // @@protoc_insertion_point(interface_extends:org.sonar.server.source.db.Data) + com.google.protobuf.MessageOrBuilder { - // repeated .org.sonar.server.source.db.Line lines = 1; /** * repeated .org.sonar.server.source.db.Line lines = 1; */ @@ -2337,8 +2311,9 @@ org.sonar.server.source.db.FileSourceDb.LineOrBuilder getLinesOrBuilder( * Protobuf type {@code org.sonar.server.source.db.Data} */ public static final class Data extends - com.google.protobuf.GeneratedMessage - implements DataOrBuilder { + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:org.sonar.server.source.db.Data) + DataOrBuilder { // Use Data.newBuilder() to construct. private Data(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); @@ -2434,7 +2409,6 @@ public com.google.protobuf.Parser getParserForType() { return PARSER; } - // repeated .org.sonar.server.source.db.Line lines = 1; public static final int LINES_FIELD_NUMBER = 1; private java.util.List lines_; /** @@ -2476,7 +2450,8 @@ private void initFields() { private byte memoizedIsInitialized = -1; public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; memoizedIsInitialized = 1; return true; @@ -2583,8 +2558,9 @@ protected Builder newBuilderForType( * Protobuf type {@code org.sonar.server.source.db.Data} */ public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements org.sonar.server.source.db.FileSourceDb.DataOrBuilder { + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:org.sonar.server.source.db.Data) + org.sonar.server.source.db.FileSourceDb.DataOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.sonar.server.source.db.FileSourceDb.internal_static_org_sonar_server_source_db_Data_descriptor; @@ -2728,7 +2704,6 @@ public Builder mergeFrom( } private int bitField0_; - // repeated .org.sonar.server.source.db.Line lines = 1; private java.util.List lines_ = java.util.Collections.emptyList(); private void ensureLinesIsMutable() { @@ -2870,7 +2845,8 @@ public Builder addAllLines( java.lang.Iterable values) { if (linesBuilder_ == null) { ensureLinesIsMutable(); - super.addAll(values, lines_); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, lines_); onChanged(); } else { linesBuilder_.addAllMessages(values); @@ -2979,12 +2955,12 @@ public org.sonar.server.source.db.FileSourceDb.Line.Builder addLinesBuilder( // @@protoc_insertion_point(class_scope:org.sonar.server.source.db.Data) } - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_sonar_server_source_db_Line_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_org_sonar_server_source_db_Line_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor + private static final com.google.protobuf.Descriptors.Descriptor internal_static_org_sonar_server_source_db_Data_descriptor; private static com.google.protobuf.GeneratedMessage.FieldAccessorTable @@ -3013,29 +2989,29 @@ public org.sonar.server.source.db.FileSourceDb.Line.Builder addLinesBuilder( " .org.sonar.server.source.db.LineB\002H\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_org_sonar_server_source_db_Line_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_org_sonar_server_source_db_Line_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_org_sonar_server_source_db_Line_descriptor, - new java.lang.String[] { "Line", "Source", "ScmRevision", "ScmAuthor", "ScmDate", "UtLineHits", "UtConditions", "UtCoveredConditions", "ItLineHits", "ItConditions", "ItCoveredConditions", "OverallLineHits", "OverallConditions", "OverallCoveredConditions", "Highlighting", "Symbols", "Duplication", }); - internal_static_org_sonar_server_source_db_Data_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_org_sonar_server_source_db_Data_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_org_sonar_server_source_db_Data_descriptor, - new java.lang.String[] { "Lines", }); - return null; - } - }; + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { }, assigner); + internal_static_org_sonar_server_source_db_Line_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_sonar_server_source_db_Line_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_sonar_server_source_db_Line_descriptor, + new java.lang.String[] { "Line", "Source", "ScmRevision", "ScmAuthor", "ScmDate", "UtLineHits", "UtConditions", "UtCoveredConditions", "ItLineHits", "ItConditions", "ItCoveredConditions", "OverallLineHits", "OverallConditions", "OverallCoveredConditions", "Highlighting", "Symbols", "Duplication", }); + internal_static_org_sonar_server_source_db_Data_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_sonar_server_source_db_Data_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_sonar_server_source_db_Data_descriptor, + new java.lang.String[] { "Lines", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java index 58807f83d402..819e23a09c1c 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java @@ -36,15 +36,25 @@ public BatchReportReader(File dir) { public BatchReport.Metadata readMetadata() { File file = fileStructure.metadataFile(); - if (!file.exists() || !file.isFile()) { + if (isNotAnExistingFile(file)) { throw new IllegalStateException("Metadata file is missing in analysis report: " + file); } return ProtobufUtil.readFile(file, BatchReport.Metadata.PARSER); } + public List readComponentMeasures(int componentRef) { + File file = fileStructure.fileFor(FileStructure.Domain.MEASURES, componentRef); + if (file.exists() && file.isFile()) { + // all the measures are loaded in memory + BatchReport.Measures measures = ProtobufUtil.readFile(file, BatchReport.Measures.PARSER); + return measures.getMeasureList(); + } + return Collections.emptyList(); + } + public BatchReport.Component readComponent(int componentRef) { File file = fileStructure.fileFor(FileStructure.Domain.COMPONENT, componentRef); - if (!file.exists() || !file.isFile()) { + if (isNotAnExistingFile(file)) { throw new IllegalStateException("Unable to find report for component #" + componentRef + ". File does not exist: " + file); } return ProtobufUtil.readFile(file, BatchReport.Component.PARSER); @@ -62,10 +72,14 @@ public List readComponentIssues(int componentRef) { public Issues readDeletedComponentIssues(int deletedComponentRef) { File file = fileStructure.fileFor(FileStructure.Domain.ISSUES_ON_DELETED, deletedComponentRef); - if (!file.exists() || !file.isFile()) { + if (isNotAnExistingFile(file)) { throw new IllegalStateException("Unable to find report for deleted component #" + deletedComponentRef); } // all the issues are loaded in memory return ProtobufUtil.readFile(file, Issues.PARSER); } + + private boolean isNotAnExistingFile(File file) { + return !file.exists() || !file.isFile(); + } } diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java index 47f62c80b903..7022d1da350f 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportWriter.java @@ -63,6 +63,14 @@ public void writeComponentIssues(int componentRef, Iterable i ProtobufUtil.writeToFile(issuesBuilder.build(), file); } + public void writeComponentMeasures(int componentRef, Iterable measures) { + BatchReport.Measures.Builder measuresBuilder = BatchReport.Measures.newBuilder(); + measuresBuilder.setComponentRef(componentRef); + measuresBuilder.addAllMeasure(measures); + File file = fileStructure.fileFor(FileStructure.Domain.MEASURES, componentRef); + ProtobufUtil.writeToFile(measuresBuilder.build(), file); + } + /** * Issues on components which have been deleted are stored in another location. * Temporary hack, waiting for computation stack diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java index 4f9529d2c3b8..ded4fa227ab3 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/FileStructure.java @@ -27,7 +27,7 @@ public class FileStructure { public static enum Domain { - ISSUES("issues-"), ISSUES_ON_DELETED("issues-deleted-"), COMPONENT("component-"); + ISSUES("issues-"), ISSUES_ON_DELETED("issues-deleted-"), COMPONENT("component-"), MEASURES("measures-"); private final String filePrefix; diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto index b281fd69e570..32ac04440f2e 100644 --- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto +++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto @@ -36,6 +36,7 @@ Notes import "constants.proto"; option java_package = "org.sonar.batch.protocol.output"; + option optimize_for = SPEED; message Metadata { @@ -75,11 +76,41 @@ message Component { optional string version = 12; // temporary fields during development of computation stack + optional int64 id = 13; optional int64 snapshot_id = 8; optional string uuid = 9; repeated Event event = 11; } +message Measure { + optional MeasureValueType value_type = 1; + optional bool boolean_value = 2; + optional int32 int_value = 3; + optional int64 long_value = 4; + optional double double_value = 5; + optional string string_value = 6; + optional string metric_key = 7; + + // temporary fields during development of computation stack + optional string description = 9; + optional string rule_key = 10; + optional Severity severity = 11; + optional string alert_status = 12; + optional string alert_text = 13; + optional double variation_value_1 = 14; + optional double variation_value_2 = 15; + optional double variation_value_3 = 16; + optional double variation_value_4 = 17; + optional double variation_value_5 = 18; + optional int32 tendency = 19; + optional int32 characteric_id = 20; +} + +message Measures { + optional int32 component_ref = 1; + repeated Measure measure = 2; +} + message Issue { optional string rule_repository = 1; optional string rule_key = 2; diff --git a/sonar-batch-protocol/src/main/protobuf/constants.proto b/sonar-batch-protocol/src/main/protobuf/constants.proto index 07c8aaf35408..4955dbaaa701 100644 --- a/sonar-batch-protocol/src/main/protobuf/constants.proto +++ b/sonar-batch-protocol/src/main/protobuf/constants.proto @@ -38,6 +38,14 @@ enum ComponentType { SUBVIEW = 5; } +enum MeasureValueType { + INT = 0; + LONG = 1; + DOUBLE = 2; + BOOLEAN = 3; + STRING = 4; +} + // temporary enum during development of computation stack enum EventCategory { ALERT = 0; diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java index 45117e479998..2766bb2efc59 100644 --- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java +++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportReaderTest.java @@ -19,6 +19,7 @@ */ package org.sonar.batch.protocol.output; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -35,57 +36,59 @@ public class BatchReportReaderTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); + BatchReportReader sut; + + @Before + public void setUp() throws Exception { + sut = new BatchReportReader(temp.newFolder()); + } + @Test public void create_dir_if_does_not_exist() throws Exception { File dir = temp.newFolder(); initFiles(dir); - BatchReportReader reader = new BatchReportReader(dir); - Metadata readMetadata = reader.readMetadata(); + sut = new BatchReportReader(dir); + Metadata readMetadata = sut.readMetadata(); assertThat(readMetadata.getAnalysisDate()).isEqualTo(15000000L); assertThat(readMetadata.getDeletedComponentsCount()).isEqualTo(1); - assertThat(reader.readComponentIssues(1)).hasSize(1); - assertThat(reader.readComponentIssues(200)).isEmpty(); - assertThat(reader.readComponent(1).getUuid()).isEqualTo("UUID_A"); - Issues deletedComponentIssues = reader.readDeletedComponentIssues(1); + assertThat(sut.readComponentIssues(1)).hasSize(1); + assertThat(sut.readComponentIssues(200)).isEmpty(); + assertThat(sut.readComponent(1).getUuid()).isEqualTo("UUID_A"); + Issues deletedComponentIssues = sut.readDeletedComponentIssues(1); assertThat(deletedComponentIssues.getComponentUuid()).isEqualTo("compUuid"); assertThat(deletedComponentIssues.getIssueList()).hasSize(1); + assertThat(sut.readComponentMeasures(1)).hasSize(1); + assertThat(sut.readComponentMeasures(1).get(0).getStringValue()).isEqualTo("value_a"); } @Test(expected = IllegalStateException.class) public void fail_if_missing_metadata_file() throws Exception { - File dir = temp.newFolder(); - - BatchReportReader reader = new BatchReportReader(dir); - reader.readMetadata(); + sut.readMetadata(); } @Test(expected = IllegalStateException.class) - public void fail_if_missing_file_on_deleted_component() throws Exception { - File dir = temp.newFolder(); - - BatchReportReader reader = new BatchReportReader(dir); - reader.readDeletedComponentIssues(666); + public void fail_if_missing_file_on_deleted_component() throws Exception { + sut.readDeletedComponentIssues(666); } @Test(expected = IllegalStateException.class) public void fail_if_missing_file_on_component() throws Exception { - File dir = temp.newFolder(); + sut.readComponent(666); + } - BatchReportReader reader = new BatchReportReader(dir); - reader.readComponent(666); + @Test + public void empty_list_if_no_measure_found() throws Exception { + assertThat(sut.readComponentMeasures(666)).isEmpty(); } /** * no file if no issues */ @Test - public void ignore_missing_file_on_component_issues() throws Exception { - File dir = temp.newFolder(); - - BatchReportReader reader = new BatchReportReader(dir); - assertThat(reader.readComponentIssues(666)).isEmpty(); + public void empty_list_if_no_issue_found() throws Exception { + assertThat(sut.readComponentIssues(666)).isEmpty(); } private void initFiles(File dir) { @@ -111,5 +114,10 @@ private void initFiles(File dir) { writer.writeComponentIssues(1, Arrays.asList(issue)); writer.writeDeletedComponentIssues(1, "compUuid", Arrays.asList(issue)); + + BatchReport.Measure.Builder measure = BatchReport.Measure.newBuilder() + .setStringValue("value_a"); + + writer.writeComponentMeasures(1, Arrays.asList(measure.build())); } } diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java index dd9b619687c1..3bec2d5c6f0f 100644 --- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java +++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/output/BatchReportWriterTest.java @@ -119,6 +119,30 @@ public void write_issues() throws Exception { assertThat(read.getIssueCount()).isEqualTo(1); } + @Test + public void write_measures() throws Exception { + File dir = temp.newFolder(); + BatchReportWriter writer = new BatchReportWriter(dir); + + assertThat(writer.hasComponentData(FileStructure.Domain.MEASURES, 1)).isFalse(); + + BatchReport.Measure measure = BatchReport.Measure.newBuilder() + .setStringValue("text-value") + .setDoubleValue(2.5d) + .setValueType(Constants.MeasureValueType.DOUBLE) + .setDescription("description") + .build(); + + writer.writeComponentMeasures(1, Arrays.asList(measure)); + + assertThat(writer.hasComponentData(FileStructure.Domain.MEASURES, 1)).isTrue(); + File file = writer.getFileStructure().fileFor(FileStructure.Domain.MEASURES, 1); + assertThat(file).exists().isFile(); + BatchReport.Measures measures = ProtobufUtil.readFile(file, BatchReport.Measures.PARSER); + assertThat(measures.getComponentRef()).isEqualTo(1); + assertThat(measures.getMeasureCount()).isEqualTo(1); + } + @Test public void write_issues_of_deleted_component() throws Exception { File dir = temp.newFolder(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java index 460f3a647c4e..c077a0608616 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java @@ -169,7 +169,6 @@ static Measure toMeasure(MeasureModel model, Metric metric, @Nullable Characteri measure.setVariation3(model.getVariationValue3()); measure.setVariation4(model.getVariationValue4()); measure.setVariation5(model.getVariationValue5()); - measure.setUrl(model.getUrl()); measure.setCharacteristic(characteristic); measure.setPersonId(model.getPersonId()); return measure; diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java index c74a8fc5bace..6559b0a7f7f6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java @@ -111,7 +111,6 @@ static MeasureModel model(Measure measure, RuleFinder ruleFinder) { model.setVariationValue3(measure.getVariation3()); model.setVariationValue4(measure.getVariation4()); model.setVariationValue5(measure.getVariation5()); - model.setUrl(measure.getUrl()); Characteristic characteristic = measure.getCharacteristic(); if (characteristic != null) { model.setCharacteristicId(characteristic.id()); diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java index d51a9009ed55..3af2c2358526 100644 --- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java +++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java @@ -21,32 +21,38 @@ package org.sonar.core.measure.db; import com.google.common.base.Charsets; -import org.sonar.core.persistence.Dto; +import org.sonar.api.rule.Severity; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class MeasureDto extends Dto{ +import static com.google.common.base.Preconditions.checkArgument; +public class MeasureDto { private static final String INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5 = "Index should be in range from 1 to 5"; + private static final int MAX_TEXT_VALUE_LENGTH = 4000; private Long id; - - private String metricKey; - - private String componentKey; - private Double value; - private String textValue; + private byte[] dataValue; + private Integer tendency; + private Double variation1, variation2, variation3, variation4, variation5; + private String alertStatus; + private String alertText; + private String description; + private Integer severityIndex; - private byte[] data; - - protected Double variation1, variation2, variation3, variation4, variation5; + private Long projectId; + private Long snapshotId; + private Integer metricId; + private Integer ruleId; + private Integer characteristicId; + private Integer personId; - private MeasureDto(){ - // Nothing here - } + // TODO to delete – not in db + private String metricKey; + private String componentKey; public Long getId() { return id; @@ -57,16 +63,6 @@ public MeasureDto setId(Long id) { return this; } - private MeasureDto setMetricKey(String metricKey) { - this.metricKey = metricKey; - return this; - } - - private MeasureDto setComponentKey(String componentKey) { - this.componentKey = componentKey; - return this; - } - @CheckForNull public Double getValue() { return value; @@ -77,25 +73,30 @@ public MeasureDto setValue(@Nullable Double value) { return this; } - public MeasureDto setTextValue(String textValue) { - this.textValue = textValue; - return this; - } - - @CheckForNull - public MeasureDto setData(@Nullable byte[] data) { - this.data = data; - return this; - } - @CheckForNull public String getData() { - if (data != null) { - return new String(data, Charsets.UTF_8); + if (dataValue != null) { + return new String(dataValue, Charsets.UTF_8); } return textValue; } + public MeasureDto setData(String data) { + if (data == null) { + this.textValue = null; + this.dataValue = null; + } else if (data.length() > MAX_TEXT_VALUE_LENGTH) { + this.textValue = null; + this.dataValue = data.getBytes(Charsets.UTF_8); + } else { + this.textValue = data; + this.dataValue = null; + } + + return this; + } + + @CheckForNull public Double getVariation(int index) { switch (index) { case 1: @@ -113,7 +114,7 @@ public Double getVariation(int index) { } } - public MeasureDto setVariation(int index, Double d) { + public MeasureDto setVariation(int index, @Nullable Double d) { switch (index) { case 1: variation1 = d; @@ -136,14 +137,135 @@ public MeasureDto setVariation(int index, Double d) { return this; } - @Override - public MeasureKey getKey() { - return MeasureKey.of(componentKey, metricKey); + @CheckForNull + public Integer getTendency() { + return tendency; + } + + public MeasureDto setTendency(@Nullable Integer tendency) { + this.tendency = tendency; + return this; + } + + @CheckForNull + public String getAlertStatus() { + return alertStatus; + } + + public MeasureDto setAlertStatus(@Nullable String alertStatus) { + this.alertStatus = alertStatus; + return this; + } + + @CheckForNull + public String getAlertText() { + return alertText; + } + + public MeasureDto setAlertText(@Nullable String alertText) { + this.alertText = alertText; + return this; + } + + @CheckForNull + public String getDescription() { + return description; + } + + public MeasureDto setDescription(@Nullable String description) { + this.description = description; + return this; + } + + public Long getComponentId() { + return projectId; + } + + public MeasureDto setComponentId(Long componentId) { + this.projectId = componentId; + return this; + } + + public Integer getMetricId() { + return metricId; + } + + public MeasureDto setMetricId(Integer metricId) { + this.metricId = metricId; + return this; + } + + public Long getSnapshotId() { + return snapshotId; + } + + public MeasureDto setSnapshotId(Long snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + public Integer getRuleId() { + return ruleId; + } + + public MeasureDto setRuleId(Integer ruleId) { + this.ruleId = ruleId; + return this; + } + + public Integer getCharacteristicId() { + return characteristicId; + } + + public MeasureDto setCharacteristicId(@Nullable Integer characteristicId) { + this.characteristicId = characteristicId; + return this; + } + + public Integer getPersonId() { + return personId; + } + + public MeasureDto setPersonId(Integer personId) { + this.personId = personId; + return this; + } + + public String getMetricKey() { + return metricKey; + } + + public MeasureDto setMetricKey(String metricKey) { + this.metricKey = metricKey; + return this; + } + + public String getComponentKey() { + return componentKey; } - public static MeasureDto createFor(MeasureKey key){ - return new MeasureDto() - .setComponentKey(key.componentKey()) - .setMetricKey(key.metricKey()); + public MeasureDto setComponentKey(String componentKey) { + this.componentKey = componentKey; + return this; + } + + @CheckForNull + public String getSeverity() { + if (severityIndex == null) { + return null; + } + + return Severity.ALL.get(severityIndex); + } + + public MeasureDto setSeverity(@Nullable String severity) { + if (severity == null) { + return this; + } + + checkArgument(Severity.ALL.contains(severity), "Severity must be included in the org.sonar.api.rule.Severity values"); + + this.severityIndex = Severity.ALL.indexOf(severity); + return this; } } diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureKey.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureKey.java deleted file mode 100644 index 2945d9845b35..000000000000 --- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureKey.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.core.measure.db; - -import com.google.common.base.Preconditions; -import com.google.common.base.Strings; - -import java.io.Serializable; - -public class MeasureKey implements Serializable { - - private final String componentKey; - private final String metricKey; - - private MeasureKey(String componentKey, String metricKey) { - this.componentKey = componentKey; - this.metricKey = metricKey; - } - - public String componentKey() { - return componentKey; - } - - public String metricKey() { - return metricKey; - } - - public static MeasureKey of(String componentKey, String metricKey) { - Preconditions.checkArgument(!Strings.isNullOrEmpty(componentKey), "Component key must be set"); - Preconditions.checkArgument(!Strings.isNullOrEmpty(metricKey), "Metric key must be set"); - return new MeasureKey(componentKey, metricKey); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - MeasureKey that = (MeasureKey) o; - - if (!componentKey.equals(that.componentKey)) { - return false; - } - if (!metricKey.equals(that.metricKey)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = componentKey.hashCode(); - result = 31 * result + metricKey.hashCode(); - return result; - } -} diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java index 572d70715cd8..de8df080ea69 100644 --- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureMapper.java @@ -28,13 +28,14 @@ public interface MeasureMapper { - MeasureDto selectByKey(@Param("key") MeasureKey key); + MeasureDto selectByKey(@Param("componentKey") String componentKey, @Param("metricKey") String metricKey); List selectByComponentAndMetrics(@Param("componentKey") String componentKey, @Param("metricKeys") List metricKeys); @CheckForNull MeasureDto selectByComponentAndMetric(@Param("componentKey") String componentKey, @Param("metricKey") String metricKey); - long countByKey(@Param("key") MeasureKey key); + long countByComponentAndMetric(@Param("componentKey") String componentKey, @Param("metricKey") String metricKey); + void insert(MeasureDto measureDto); } diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java index be3805f5661a..9b1fff40e278 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java @@ -33,7 +33,7 @@ import java.util.*; -public final class RuleDto extends Dto { +public class RuleDto extends Dto { public static final Integer DISABLED_CHARACTERISTIC_ID = -1; diff --git a/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml b/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml index 0964ff196f10..288eccb685d0 100644 --- a/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml @@ -8,7 +8,7 @@ pm.snapshot_id as snapshotId, pm.value as value, pm.text_value as textValue, - pm.measure_data as data, + pm.measure_data as dataValue, pm.variation_value_1 as variation1, pm.variation_value_2 as variation2, pm.variation_value_3 as variation3, @@ -18,23 +18,7 @@ metric.name as metricKey - - - SELECT metric.name as metric_name, FROM project_measures pm @@ -43,14 +27,14 @@ INNER JOIN metrics metric ON metric.id=pm.metric_id AND p.kee = #{componentKey} - AND metric.name=#{metricKey} + AND metric.name=#{metricKey} AND pm.rule_id IS NULL AND pm.characteristic_id IS NULL AND pm.person_id IS NULL - SELECT metric.name as metric_name, FROM project_measures pm @@ -59,26 +43,44 @@ INNER JOIN metrics metric ON metric.id=pm.metric_id AND p.kee = #{componentKey} - AND metric.name=#{metricKey} + AND + + metric.name=#{metricKey} + AND pm.rule_id IS NULL AND pm.characteristic_id IS NULL AND pm.person_id IS NULL - SELECT count(pm.id) FROM project_measures pm INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.islast=${_true} INNER JOIN metrics metric ON metric.id=pm.metric_id INNER JOIN projects p ON p.id=s.project_id AND p.enabled=${_true} - AND p.kee = #{key.componentKey} - AND metric.name = #{key.metricKey} + AND p.kee = #{componentKey} + AND metric.name = #{metricKey} AND pm.rule_id IS NULL AND pm.characteristic_id IS NULL AND pm.person_id IS NULL + + INSERT INTO project_measures ( + value, metric_id, snapshot_id, rule_id, text_value, tendency, project_id, alert_status, alert_text, description, + rule_priority, characteristic_id, variation_value_1, variation_value_2, variation_value_3, variation_value_4, + variation_value_5, measure_data) + VALUES ( + #{value, jdbcType=DOUBLE}, #{metricId, jdbcType=INTEGER}, #{snapshotId, jdbcType=INTEGER}, + #{ruleId, jdbcType=INTEGER}, #{textValue, jdbcType=VARCHAR}, #{tendency, jdbcType=INTEGER}, + #{projectId, jdbcType=INTEGER}, #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR}, + #{description, jdbcType=VARCHAR}, #{severityIndex, jdbcType=INTEGER}, #{characteristicId, jdbcType=INTEGER}, + #{variation1, jdbcType=DOUBLE}, #{variation2, jdbcType=DOUBLE}, #{variation3, jdbcType=DOUBLE}, + #{variation4, jdbcType=DOUBLE}, #{variation5, jdbcType=DOUBLE}, #{dataValue, jdbcType=BINARY} + ) + + diff --git a/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureDtoTest.java b/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureDtoTest.java index 81aecce81717..e75676287e87 100644 --- a/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureDtoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureDtoTest.java @@ -20,66 +20,72 @@ package org.sonar.core.measure.db; +import com.google.common.base.Strings; import org.junit.Test; +import org.sonar.api.rule.Severity; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; public class MeasureDtoTest { + MeasureDto sut = new MeasureDto(); + @Test public void test_getter_and_setter() throws Exception { - MeasureDto measureDto = MeasureDto.createFor(MeasureKey.of("component", "metric")) + sut + .setComponentKey("component") + .setMetricKey("metric") .setId(10L) .setValue(2d) - .setTextValue("text value") - .setData(new byte[]{}) + .setData("text value") .setVariation(1, 1d) .setVariation(2, 2d) .setVariation(3, 3d) .setVariation(4, 4d) .setVariation(5, 5d); - assertThat(measureDto.getId()).isEqualTo(10); - assertThat(measureDto.getValue()).isEqualTo(2d); - assertThat(measureDto.getData()).isNotNull(); - assertThat(measureDto.getVariation(1)).isEqualTo(1d); - assertThat(measureDto.getVariation(2)).isEqualTo(2d); - assertThat(measureDto.getVariation(3)).isEqualTo(3d); - assertThat(measureDto.getVariation(4)).isEqualTo(4d); - assertThat(measureDto.getVariation(5)).isEqualTo(5d); + assertThat(sut.getId()).isEqualTo(10); + assertThat(sut.getValue()).isEqualTo(2d); + assertThat(sut.getData()).isNotNull(); + assertThat(sut.getVariation(1)).isEqualTo(1d); + assertThat(sut.getVariation(2)).isEqualTo(2d); + assertThat(sut.getVariation(3)).isEqualTo(3d); + assertThat(sut.getVariation(4)).isEqualTo(4d); + assertThat(sut.getVariation(5)).isEqualTo(5d); } @Test - public void test_data() throws Exception { - assertThat(MeasureDto.createFor(MeasureKey.of("component", "metric")) - .setTextValue("text value") - .setData(null).getData()).isEqualTo("text value"); - - assertThat(MeasureDto.createFor(MeasureKey.of("component", "metric")) - .setTextValue(null) - .setData(new byte[]{}).getData()).isNotNull(); + public void value_with_text_over_4000_characters() throws Exception { + assertThat(sut.setData(Strings.repeat("1", 4001)).getData()).isNotNull(); } @Test + public void text_value_under_4000_characters() throws Exception { + assertThat(sut.setData("text value").getData()).isEqualTo("text value"); + } + + @Test(expected = IndexOutOfBoundsException.class) public void fail_to_set_out_of_bounds_variation() throws Exception { - try { - MeasureDto.createFor(MeasureKey.of("component", "metric")) - .setVariation(6, 1d); - fail(); - } catch (Exception e) { - assertThat(e).isInstanceOf(IndexOutOfBoundsException.class); - } + sut.setVariation(6, 1d); } - @Test + @Test(expected = IndexOutOfBoundsException.class) public void fail_to_get_out_of_bounds_variation() throws Exception { - try { - MeasureDto.createFor(MeasureKey.of("component", "metric")) - .getVariation(6); - fail(); - } catch (Exception e) { - assertThat(e).isInstanceOf(IndexOutOfBoundsException.class); + sut.getVariation(6); + } + + @Test(expected = IllegalArgumentException.class) + public void fail_if_non_existent_severity() throws Exception { + sut.setSeverity("MAYOR"); + } + + @Test + public void severity_values_are_retrieved() throws Exception { + assertThat(sut.getSeverity()).isNull(); + + for (String severity : Severity.ALL) { + sut = new MeasureDto().setSeverity(severity); + assertThat(sut.getSeverity()).isEqualTo(severity); } } } diff --git a/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureKeyTest.java b/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureKeyTest.java deleted file mode 100644 index 342aa6e0b18f..000000000000 --- a/sonar-core/src/test/java/org/sonar/core/measure/db/MeasureKeyTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.core.measure.db; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.fail; - -public class MeasureKeyTest { - - @Test - public void create_key() throws Exception { - MeasureKey key = MeasureKey.of("sample", "ncloc"); - assertThat(key.componentKey()).isEqualTo("sample"); - assertThat(key.metricKey()).isEqualTo("ncloc"); - } - - @Test - public void component_key_must_not_be_null() throws Exception { - try { - MeasureKey.of(null, "ncloc"); - fail(); - } catch (IllegalArgumentException e) { - assertThat(e).hasMessage("Component key must be set"); - } - } - - @Test - public void metric_key_must_not_be_null() throws Exception { - try { - MeasureKey.of("sample", null); - fail(); - } catch (IllegalArgumentException e) { - assertThat(e).hasMessage("Metric key must be set"); - } - } - - @Test - public void test_equals_and_hashcode() throws Exception { - MeasureKey key1 = MeasureKey.of("sample", "ncloc"); - MeasureKey key2 = MeasureKey.of("sample", "ncloc"); - MeasureKey key3 = MeasureKey.of("sample", "coverage"); - MeasureKey key4 = MeasureKey.of("sample2", "coverage"); - - assertThat(key1).isEqualTo(key1); - assertThat(key1).isEqualTo(key2); - assertThat(key1).isNotEqualTo(key3); - assertThat(key3).isNotEqualTo(key4); - assertThat(key1).isNotEqualTo(null); - assertThat(key1.hashCode()).isEqualTo(key1.hashCode()); - assertThat(key1.hashCode()).isEqualTo(key2.hashCode()); - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java b/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java index 39c3a397b781..3d5ff943f92f 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java @@ -19,7 +19,6 @@ */ package org.sonar.core.persistence; -import com.google.common.base.Objects; import com.google.common.collect.Maps; import com.google.common.io.Closeables; import org.apache.commons.io.FileUtils; @@ -31,11 +30,7 @@ import org.dbunit.IDatabaseTester; import org.dbunit.database.DatabaseConfig; import org.dbunit.database.IDatabaseConnection; -import org.dbunit.dataset.CompositeDataSet; -import org.dbunit.dataset.DataSetException; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.ITable; -import org.dbunit.dataset.ReplacementDataSet; +import org.dbunit.dataset.*; import org.dbunit.dataset.filter.DefaultColumnFilter; import org.dbunit.dataset.xml.FlatXmlDataSet; import org.dbunit.ext.mssql.InsertIdentityOperation; @@ -103,12 +98,6 @@ public static void startDatabase() throws Exception { } } - @Before - public void startDbUnit() throws Exception { - databaseCommands.truncateDatabase(database.getDataSource()); - databaseTester = new DataSourceDatabaseTester(database.getDataSource(), databaseCommands.useLoginAsSchema() ? login : null); - } - /** * Orchestrator is the name of a SonarSource close-source library for database and integration testing. */ @@ -142,6 +131,18 @@ private static void loadOrchestratorSettings(Settings settings) throws URISyntax } } + private static RuntimeException translateException(String msg, Exception cause) { + RuntimeException runtimeException = new RuntimeException(String.format("%s: [%s] %s", msg, cause.getClass().getName(), cause.getMessage())); + runtimeException.setStackTrace(cause.getStackTrace()); + return runtimeException; + } + + @Before + public void startDbUnit() throws Exception { + databaseCommands.truncateDatabase(database.getDataSource()); + databaseTester = new DataSourceDatabaseTester(database.getDataSource(), databaseCommands.useLoginAsSchema() ? login : null); + } + protected MyBatis getMyBatis() { return myBatis; } @@ -294,12 +295,6 @@ private IDataSet getData(InputStream stream) { } } - private static RuntimeException translateException(String msg, Exception cause) { - RuntimeException runtimeException = new RuntimeException(String.format("%s: [%s] %s", msg, cause.getClass().getName(), cause.getMessage())); - runtimeException.setStackTrace(cause.getStackTrace()); - return runtimeException; - } - protected Connection getConnection() throws SQLException { return database.getDataSource().getConnection(); }