@@ -183,8 +183,8 @@ public class ComponentAppAction implements RequestHandler { | |||
private Map<String, MeasureDto> measuresByMetricKey(ComponentDto component, DbSession session) { | |||
Map<String, MeasureDto> 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 @@ public class ComponentAppAction implements RequestHandler { | |||
@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; | |||
} |
@@ -21,13 +21,8 @@ package org.sonar.server.computation; | |||
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 @@ import java.util.List; | |||
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 @@ public class ComputationContainer { | |||
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(); | |||
} | |||
} | |||
} |
@@ -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)); | |||
} | |||
} |
@@ -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<String, MetricDto> metrics; | |||
public MetricCache(DbClient dbClient) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
List<MetricDto> metricList = dbClient.metricDao().findEnabled(dbSession); | |||
this.metrics = Maps.uniqueIndex(metricList, new Function<MetricDto, String>() { | |||
@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; | |||
} | |||
} |
@@ -41,6 +41,7 @@ public class ComputationSteps { | |||
ParseReportStep.class, | |||
// Persist data | |||
PersistMeasuresStep.class, | |||
PersistIssuesStep.class, | |||
PersistComponentLinksStep.class, | |||
PersistEventsStep.class, |
@@ -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<BatchReport.Measure> measures = reportReader.readComponentMeasures(componentRef); | |||
persistMeasures(dbSession, measures, component); | |||
for (Integer childRef : component.getChildRefList()) { | |||
recursivelyProcessComponent(dbSession, context, childRef); | |||
} | |||
} | |||
private void persistMeasures(DbSession dbSession, List<BatchReport.Measure> batchReportMeasures, final BatchReport.Component component) { | |||
List<MeasureDto> measures = Lists.transform(batchReportMeasures, new Function<BatchReport.Measure, MeasureDto>() { | |||
@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; | |||
} | |||
} |
@@ -31,7 +31,6 @@ import org.sonar.api.utils.text.JsonWriter; | |||
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.measure.persistence.MeasureDao; | |||
import org.sonar.server.user.UserSession; | |||
import javax.annotation.CheckForNull; | |||
import java.util.List; | |||
public class ShowAction implements RequestHandler { | |||
@@ -105,9 +103,9 @@ public class ShowAction implements RequestHandler { | |||
@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; | |||
} |
@@ -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<MeasureMapper, MeasureDto, MeasureKey> 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<MeasureDto> findByComponentKeyAndMetricKeys(final DbSession session, final String componentKey, List<String> metricKeys) { | |||
return DaoUtils.executeLargeInputs(metricKeys, new Function<List<String>, List<MeasureDto>>() { | |||
@Override | |||
public List<MeasureDto> apply(List<String> keys) { | |||
return mapper(session).selectByComponentAndMetrics(componentKey, keys); | |||
} | |||
}); | |||
} | |||
public List<MeasureDto> findByComponentKeyAndMetricKeys(String componentKey, List<String> metricKeys, DbSession session) { | |||
if (metricKeys.isEmpty()) { | |||
return Collections.emptyList(); | |||
} | |||
List<MeasureDto> dtos = newArrayList(); | |||
List<List<String>> partitions = Lists.partition(newArrayList(metricKeys), 1000); | |||
for (List<String> 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); | |||
} | |||
} |
@@ -26,7 +26,6 @@ import org.sonar.api.ServerComponent; | |||
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 org.sonar.server.user.UserSession; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import java.util.List; | |||
public class SourceService implements ServerComponent { | |||
@@ -97,7 +95,7 @@ public class SourceService implements ServerComponent { | |||
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(); | |||
} |
@@ -29,7 +29,6 @@ import org.sonar.api.utils.KeyValueFormat; | |||
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 class CoverageService implements ServerComponent { | |||
private Map<Integer, Integer> 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); |
@@ -138,7 +138,7 @@ public class TestsShowAction implements RequestHandler { | |||
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(); | |||
} |
@@ -34,7 +34,6 @@ import org.sonar.api.utils.Durations; | |||
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 class ComponentAppActionTest { | |||
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 class ComponentAppActionTest { | |||
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 @@ public class ComponentAppActionTest { | |||
} | |||
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)); | |||
} | |||
} |
@@ -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"); | |||
} | |||
} |
@@ -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"); | |||
} | |||
} |
@@ -44,12 +44,13 @@ public class ComputationStepsTest { | |||
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 |
@@ -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<MeasureDto> 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; | |||
} | |||
} |
@@ -31,7 +31,6 @@ import org.sonar.api.utils.text.JsonWriter; | |||
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 class ShowActionTest { | |||
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<DuplicationsParser.Block> 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 class ShowActionTest { | |||
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<DuplicationsParser.Block> blocks = newArrayList(new DuplicationsParser.Block(newArrayList(new DuplicationsParser.Duplication(componentDto, 1, 2)))); | |||
@@ -134,8 +131,7 @@ public class ShowActionTest { | |||
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(); |
@@ -22,28 +22,33 @@ package org.sonar.server.measure.persistence; | |||
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 class MeasureDaoTest extends AbstractDaoTestCase { | |||
@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<MeasureDto> results = dao.findByComponentKeyAndMetricKeys("org.struts:struts-core:src/org/struts/RequestContext.java", | |||
newArrayList("ncloc", "authors_by_line"), session); | |||
List<MeasureDto> 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 class MeasureDaoTest extends AbstractDaoTestCase { | |||
@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"); | |||
} | |||
} |
@@ -27,7 +27,6 @@ import org.mockito.Mock; | |||
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 java.util.List; | |||
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 class SourceServiceTest { | |||
@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 class SourceServiceTest { | |||
@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 class SourceServiceTest { | |||
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(); | |||
} | |||
@@ -30,7 +30,6 @@ import org.sonar.api.measures.CoreMetrics; | |||
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 @@ import static org.mockito.Mockito.*; | |||
@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 class CoverageServiceTest { | |||
@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 |
@@ -31,7 +31,6 @@ import org.sonar.api.test.TestCase; | |||
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 class TestsShowActionTest { | |||
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("<tests-details>" + | |||
when(measureDao.findByComponentKeyAndMetricKey(session, TEST_PLAN_KEY, "test_data")).thenReturn(new MeasureDto() | |||
.setComponentKey(TEST_PLAN_KEY) | |||
.setMetricKey("test_data") | |||
.setData("<tests-details>" + | |||
"<testcase status=\"ok\" time=\"10\" name=\"test1\"/>" + | |||
"<testcase status=\"error\" time=\"97\" name=\"test2\">" + | |||
"<error message=\"expected:<true> but was:<false>\">" + | |||
@@ -121,10 +122,13 @@ public class TestsShowActionTest { | |||
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("<tests-details>" + | |||
"<testcase status=\"ok\" time=\"12.5\" name=\"test1\"/>" + | |||
"</tests-details>")); | |||
when(measureDao.findByComponentKeyAndMetricKey(session, TEST_PLAN_KEY, "test_data")).thenReturn( | |||
new MeasureDto() | |||
.setComponentKey(TEST_PLAN_KEY) | |||
.setMetricKey("test_data") | |||
.setData("<tests-details>" + | |||
"<testcase status=\"ok\" time=\"12.5\" name=\"test1\"/>" + | |||
"</tests-details>")); | |||
WsTester.TestRequest request = tester.newGetRequest("api/tests", "show").setParam("key", TEST_PLAN_KEY); | |||
@@ -0,0 +1,13 @@ | |||
<dataset> | |||
<!-- enabled metrics --> | |||
<metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" | |||
short_name="" enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" | |||
direction="0" delete_historical_data="[null]" hidden="false"/> | |||
<metrics id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" | |||
short_name="" enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" | |||
delete_historical_data="[null]" hidden="false"/> | |||
<!-- disabled metric --> | |||
<metrics id="3" name="complexity" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" | |||
short_name="" enabled="false" worst_value="0" optimized_best_value="true" best_value="100" direction="1" | |||
delete_historical_data="[null]" hidden="false"/> | |||
</dataset> |
@@ -0,0 +1,5 @@ | |||
<dataset> | |||
<rules id="987" tags="[null]" system_tags="[null]" name="[null]" plugin_rule_key="AvoidCycles" plugin_config_key="[null]" plugin_name="[null]"/> | |||
<metrics id="654" delete_historical_data="[null]" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name="" | |||
enabled="true" worst_value="0" optimized_best_value="true" best_value="100" direction="1" hidden="false"/> | |||
</dataset> |
@@ -0,0 +1,3 @@ | |||
<dataset> | |||
<project_measures/> | |||
</dataset> |
@@ -0,0 +1,27 @@ | |||
<dataset> | |||
<project_measures | |||
id="1" | |||
snapshot_id="2" | |||
metric_id="3" | |||
characteristic_id="4" | |||
rule_id="5" | |||
project_id="6" | |||
person_id="[null]" | |||
value="2.0" | |||
text_value="measure-value" | |||
tendency="42" | |||
rule_priority="0" | |||
measure_date="[null]" | |||
measure_data="[null]" | |||
variation_value_1="1.0" | |||
variation_value_2="2.0" | |||
variation_value_3="3.0" | |||
variation_value_4="4.0" | |||
variation_value_5="5.0" | |||
alert_status="alert" | |||
alert_text="alert-text" | |||
url="[null]" | |||
description="measure-description" | |||
rules_category_id="[null]" | |||
/> | |||
</dataset> |
@@ -8,7 +8,7 @@ | |||
<snapshots id="5" project_id="1" islast="[true]" /> | |||
<project_measures id="20" snapshot_id="5" metric_id="10" value="[null]" text_value="[null]" measure_data="MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OQ==" | |||
<project_measures id="20" snapshot_id="5" metric_id="10" value="[null]" text_value="0123456789012345678901234567890123456789" measure_data="[null]" | |||
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]" /> | |||
<project_measures id="21" snapshot_id="5" metric_id="11" value="[null]" text_value="36=1;37=1;38=1;39=1;43=1;48=1;53=1" measure_data="[null]" | |||
variation_value_1="[null]" variation_value_2="[null]" variation_value_3="[null]" variation_value_4="[null]" variation_value_5="[null]" /> |
@@ -235,6 +235,115 @@ public final class Constants { | |||
// @@protoc_insertion_point(enum_scope:ComponentType) | |||
} | |||
/** | |||
* Protobuf enum {@code MeasureValueType} | |||
*/ | |||
public enum MeasureValueType | |||
implements com.google.protobuf.ProtocolMessageEnum { | |||
/** | |||
* <code>INT = 0;</code> | |||
*/ | |||
INT(0, 0), | |||
/** | |||
* <code>LONG = 1;</code> | |||
*/ | |||
LONG(1, 1), | |||
/** | |||
* <code>DOUBLE = 2;</code> | |||
*/ | |||
DOUBLE(2, 2), | |||
/** | |||
* <code>BOOLEAN = 3;</code> | |||
*/ | |||
BOOLEAN(3, 3), | |||
/** | |||
* <code>STRING = 4;</code> | |||
*/ | |||
STRING(4, 4), | |||
; | |||
/** | |||
* <code>INT = 0;</code> | |||
*/ | |||
public static final int INT_VALUE = 0; | |||
/** | |||
* <code>LONG = 1;</code> | |||
*/ | |||
public static final int LONG_VALUE = 1; | |||
/** | |||
* <code>DOUBLE = 2;</code> | |||
*/ | |||
public static final int DOUBLE_VALUE = 2; | |||
/** | |||
* <code>BOOLEAN = 3;</code> | |||
*/ | |||
public static final int BOOLEAN_VALUE = 3; | |||
/** | |||
* <code>STRING = 4;</code> | |||
*/ | |||
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<MeasureValueType> | |||
internalGetValueMap() { | |||
return internalValueMap; | |||
} | |||
private static com.google.protobuf.Internal.EnumLiteMap<MeasureValueType> | |||
internalValueMap = | |||
new com.google.protobuf.Internal.EnumLiteMap<MeasureValueType>() { | |||
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 final class Constants { | |||
} | |||
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 final class Constants { | |||
} | |||
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 @@ public final class Constants { | |||
"\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[] { |
@@ -8,10 +8,10 @@ public final class 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; | |||
/** | |||
* <code>optional string key = 1;</code> | |||
*/ | |||
@@ -26,7 +26,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getKeyBytes(); | |||
// optional string module_key = 2; | |||
/** | |||
* <code>optional string module_key = 2;</code> | |||
*/ | |||
@@ -41,7 +40,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getModuleKeyBytes(); | |||
// optional string path = 3; | |||
/** | |||
* <code>optional string path = 3;</code> | |||
*/ | |||
@@ -56,7 +54,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getPathBytes(); | |||
// optional string rule_repository = 4; | |||
/** | |||
* <code>optional string rule_repository = 4;</code> | |||
*/ | |||
@@ -71,7 +68,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getRuleRepositoryBytes(); | |||
// optional string rule_key = 5; | |||
/** | |||
* <code>optional string rule_key = 5;</code> | |||
*/ | |||
@@ -86,7 +82,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getRuleKeyBytes(); | |||
// optional int32 line = 6; | |||
/** | |||
* <code>optional int32 line = 6;</code> | |||
*/ | |||
@@ -96,7 +91,6 @@ public final class BatchInput { | |||
*/ | |||
int getLine(); | |||
// optional string msg = 7; | |||
/** | |||
* <code>optional string msg = 7;</code> | |||
*/ | |||
@@ -111,7 +105,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getMsgBytes(); | |||
// optional .Severity severity = 8; | |||
/** | |||
* <code>optional .Severity severity = 8;</code> | |||
*/ | |||
@@ -121,7 +114,6 @@ public final class BatchInput { | |||
*/ | |||
org.sonar.batch.protocol.Constants.Severity getSeverity(); | |||
// optional bool manual_severity = 9; | |||
/** | |||
* <code>optional bool manual_severity = 9;</code> | |||
*/ | |||
@@ -131,7 +123,6 @@ public final class BatchInput { | |||
*/ | |||
boolean getManualSeverity(); | |||
// optional string resolution = 10; | |||
/** | |||
* <code>optional string resolution = 10;</code> | |||
*/ | |||
@@ -146,7 +137,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getResolutionBytes(); | |||
// optional string status = 11; | |||
/** | |||
* <code>optional string status = 11;</code> | |||
*/ | |||
@@ -161,7 +151,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getStatusBytes(); | |||
// optional string checksum = 12; | |||
/** | |||
* <code>optional string checksum = 12;</code> | |||
*/ | |||
@@ -176,7 +165,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getChecksumBytes(); | |||
// optional string assignee_login = 13; | |||
/** | |||
* <code>optional string assignee_login = 13;</code> | |||
*/ | |||
@@ -191,7 +179,6 @@ public final class BatchInput { | |||
com.google.protobuf.ByteString | |||
getAssigneeLoginBytes(); | |||
// optional int64 creation_date = 14; | |||
/** | |||
* <code>optional int64 creation_date = 14;</code> | |||
*/ | |||
@@ -205,8 +192,9 @@ public final class BatchInput { | |||
* 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 @@ public final class BatchInput { | |||
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 @@ public final class BatchInput { | |||
break; | |||
} | |||
case 58: { | |||
com.google.protobuf.ByteString bs = input.readBytes(); | |||
bitField0_ |= 0x00000040; | |||
msg_ = input.readBytes(); | |||
msg_ = bs; | |||
break; | |||
} | |||
case 64: { | |||
@@ -304,23 +298,27 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
} | |||
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 final class BatchInput { | |||
} | |||
} | |||
// optional string module_key = 2; | |||
public static final int MODULE_KEY_FIELD_NUMBER = 2; | |||
private java.lang.Object moduleKey_; | |||
/** | |||
@@ -454,7 +450,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string path = 3; | |||
public static final int PATH_FIELD_NUMBER = 3; | |||
private java.lang.Object path_; | |||
/** | |||
@@ -497,7 +492,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string rule_repository = 4; | |||
public static final int RULE_REPOSITORY_FIELD_NUMBER = 4; | |||
private java.lang.Object ruleRepository_; | |||
/** | |||
@@ -540,7 +534,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string rule_key = 5; | |||
public static final int RULE_KEY_FIELD_NUMBER = 5; | |||
private java.lang.Object ruleKey_; | |||
/** | |||
@@ -583,7 +576,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional int32 line = 6; | |||
public static final int LINE_FIELD_NUMBER = 6; | |||
private int line_; | |||
/** | |||
@@ -599,7 +591,6 @@ public final class BatchInput { | |||
return line_; | |||
} | |||
// optional string msg = 7; | |||
public static final int MSG_FIELD_NUMBER = 7; | |||
private java.lang.Object msg_; | |||
/** | |||
@@ -642,7 +633,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// 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 final class BatchInput { | |||
return severity_; | |||
} | |||
// optional bool manual_severity = 9; | |||
public static final int MANUAL_SEVERITY_FIELD_NUMBER = 9; | |||
private boolean manualSeverity_; | |||
/** | |||
@@ -674,7 +663,6 @@ public final class BatchInput { | |||
return manualSeverity_; | |||
} | |||
// optional string resolution = 10; | |||
public static final int RESOLUTION_FIELD_NUMBER = 10; | |||
private java.lang.Object resolution_; | |||
/** | |||
@@ -717,7 +705,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string status = 11; | |||
public static final int STATUS_FIELD_NUMBER = 11; | |||
private java.lang.Object status_; | |||
/** | |||
@@ -760,7 +747,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string checksum = 12; | |||
public static final int CHECKSUM_FIELD_NUMBER = 12; | |||
private java.lang.Object checksum_; | |||
/** | |||
@@ -803,7 +789,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional string assignee_login = 13; | |||
public static final int ASSIGNEE_LOGIN_FIELD_NUMBER = 13; | |||
private java.lang.Object assigneeLogin_; | |||
/** | |||
@@ -846,7 +831,6 @@ public final class BatchInput { | |||
} | |||
} | |||
// optional int64 creation_date = 14; | |||
public static final int CREATION_DATE_FIELD_NUMBER = 14; | |||
private long creationDate_; | |||
/** | |||
@@ -881,7 +865,8 @@ public final class BatchInput { | |||
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 @@ public final class BatchInput { | |||
* Protobuf type {@code ServerIssue} | |||
*/ | |||
public static final class Builder extends | |||
com.google.protobuf.GeneratedMessage.Builder<Builder> | |||
implements org.sonar.batch.protocol.input.BatchInput.ServerIssueOrBuilder { | |||
com.google.protobuf.GeneratedMessage.Builder<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 final class BatchInput { | |||
} | |||
private int bitField0_; | |||
// optional string key = 1; | |||
private java.lang.Object key_ = ""; | |||
/** | |||
* <code>optional string key = 1;</code> | |||
@@ -1344,9 +1329,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string module_key = 2; | |||
private java.lang.Object moduleKey_ = ""; | |||
/** | |||
* <code>optional string module_key = 2;</code> | |||
@@ -1418,9 +1405,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string path = 3; | |||
private java.lang.Object path_ = ""; | |||
/** | |||
* <code>optional string path = 3;</code> | |||
@@ -1492,9 +1481,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string rule_repository = 4; | |||
private java.lang.Object ruleRepository_ = ""; | |||
/** | |||
* <code>optional string rule_repository = 4;</code> | |||
@@ -1566,9 +1557,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string rule_key = 5; | |||
private java.lang.Object ruleKey_ = ""; | |||
/** | |||
* <code>optional string rule_key = 5;</code> | |||
@@ -1640,9 +1633,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional int32 line = 6; | |||
private int line_ ; | |||
/** | |||
* <code>optional int32 line = 6;</code> | |||
@@ -1733,7 +1728,6 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string msg = 7; | |||
private java.lang.Object msg_ = ""; | |||
/** | |||
* <code>optional string msg = 7;</code> | |||
@@ -1747,9 +1741,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional .Severity severity = 8; | |||
private org.sonar.batch.protocol.Constants.Severity severity_ = org.sonar.batch.protocol.Constants.Severity.INFO; | |||
/** | |||
* <code>optional .Severity severity = 8;</code> | |||
@@ -1843,7 +1839,6 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional bool manual_severity = 9; | |||
private boolean manualSeverity_ ; | |||
/** | |||
* <code>optional bool manual_severity = 9;</code> | |||
@@ -1876,7 +1871,6 @@ public final class BatchInput { | |||
return this; | |||
} | |||
// optional string resolution = 10; | |||
private java.lang.Object resolution_ = ""; | |||
/** | |||
* <code>optional string resolution = 10;</code> | |||
@@ -1890,9 +1884,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string status = 11; | |||
private java.lang.Object status_ = ""; | |||
/** | |||
* <code>optional string status = 11;</code> | |||
@@ -1964,9 +1960,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string checksum = 12; | |||
private java.lang.Object checksum_ = ""; | |||
/** | |||
* <code>optional string checksum = 12;</code> | |||
@@ -2038,9 +2036,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional string assignee_login = 13; | |||
private java.lang.Object assigneeLogin_ = ""; | |||
/** | |||
* <code>optional string assignee_login = 13;</code> | |||
@@ -2112,9 +2112,12 @@ public final class BatchInput { | |||
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 final class BatchInput { | |||
return this; | |||
} | |||
// optional int64 creation_date = 14; | |||
private long creationDate_ ; | |||
/** | |||
* <code>optional int64 creation_date = 14;</code> | |||
@@ -2216,7 +2218,7 @@ public final class BatchInput { | |||
// @@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 final class BatchInput { | |||
" \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) |
@@ -8,10 +8,10 @@ public final class 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; | |||
/** | |||
* <code>optional int32 line = 1;</code> | |||
*/ | |||
@@ -21,7 +21,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getLine(); | |||
// optional string source = 2; | |||
/** | |||
* <code>optional string source = 2;</code> | |||
*/ | |||
@@ -36,7 +35,6 @@ public final class FileSourceDb { | |||
com.google.protobuf.ByteString | |||
getSourceBytes(); | |||
// optional string scm_revision = 3; | |||
/** | |||
* <code>optional string scm_revision = 3;</code> | |||
* | |||
@@ -63,7 +61,6 @@ public final class FileSourceDb { | |||
com.google.protobuf.ByteString | |||
getScmRevisionBytes(); | |||
// optional string scm_author = 4; | |||
/** | |||
* <code>optional string scm_author = 4;</code> | |||
*/ | |||
@@ -78,7 +75,6 @@ public final class FileSourceDb { | |||
com.google.protobuf.ByteString | |||
getScmAuthorBytes(); | |||
// optional int64 scm_date = 5; | |||
/** | |||
* <code>optional int64 scm_date = 5;</code> | |||
*/ | |||
@@ -88,7 +84,6 @@ public final class FileSourceDb { | |||
*/ | |||
long getScmDate(); | |||
// optional int32 ut_line_hits = 6; | |||
/** | |||
* <code>optional int32 ut_line_hits = 6;</code> | |||
* | |||
@@ -106,7 +101,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getUtLineHits(); | |||
// optional int32 ut_conditions = 7; | |||
/** | |||
* <code>optional int32 ut_conditions = 7;</code> | |||
*/ | |||
@@ -116,7 +110,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getUtConditions(); | |||
// optional int32 ut_covered_conditions = 8; | |||
/** | |||
* <code>optional int32 ut_covered_conditions = 8;</code> | |||
*/ | |||
@@ -126,7 +119,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getUtCoveredConditions(); | |||
// optional int32 it_line_hits = 9; | |||
/** | |||
* <code>optional int32 it_line_hits = 9;</code> | |||
* | |||
@@ -144,7 +136,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getItLineHits(); | |||
// optional int32 it_conditions = 10; | |||
/** | |||
* <code>optional int32 it_conditions = 10;</code> | |||
*/ | |||
@@ -154,7 +145,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getItConditions(); | |||
// optional int32 it_covered_conditions = 11; | |||
/** | |||
* <code>optional int32 it_covered_conditions = 11;</code> | |||
*/ | |||
@@ -164,7 +154,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getItCoveredConditions(); | |||
// optional int32 overall_line_hits = 12; | |||
/** | |||
* <code>optional int32 overall_line_hits = 12;</code> | |||
* | |||
@@ -182,7 +171,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getOverallLineHits(); | |||
// optional int32 overall_conditions = 13; | |||
/** | |||
* <code>optional int32 overall_conditions = 13;</code> | |||
*/ | |||
@@ -192,7 +180,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getOverallConditions(); | |||
// optional int32 overall_covered_conditions = 14; | |||
/** | |||
* <code>optional int32 overall_covered_conditions = 14;</code> | |||
*/ | |||
@@ -202,7 +189,6 @@ public final class FileSourceDb { | |||
*/ | |||
int getOverallCoveredConditions(); | |||
// optional string highlighting = 15; | |||
/** | |||
* <code>optional string highlighting = 15;</code> | |||
*/ | |||
@@ -217,7 +203,6 @@ public final class FileSourceDb { | |||
com.google.protobuf.ByteString | |||
getHighlightingBytes(); | |||
// optional string symbols = 16; | |||
/** | |||
* <code>optional string symbols = 16;</code> | |||
*/ | |||
@@ -232,7 +217,6 @@ public final class FileSourceDb { | |||
com.google.protobuf.ByteString | |||
getSymbolsBytes(); | |||
// repeated int32 duplication = 17 [packed = true]; | |||
/** | |||
* <code>repeated int32 duplication = 17 [packed = true];</code> | |||
*/ | |||
@@ -250,8 +234,9 @@ public final class FileSourceDb { | |||
* 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 @@ public final class FileSourceDb { | |||
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 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
} | |||
private int bitField0_; | |||
// optional int32 line = 1; | |||
public static final int LINE_FIELD_NUMBER = 1; | |||
private int line_; | |||
/** | |||
@@ -457,7 +446,6 @@ public final class FileSourceDb { | |||
return line_; | |||
} | |||
// optional string source = 2; | |||
public static final int SOURCE_FIELD_NUMBER = 2; | |||
private java.lang.Object source_; | |||
/** | |||
@@ -500,7 +488,6 @@ public final class FileSourceDb { | |||
} | |||
} | |||
// optional string scm_revision = 3; | |||
public static final int SCM_REVISION_FIELD_NUMBER = 3; | |||
private java.lang.Object scmRevision_; | |||
/** | |||
@@ -555,7 +542,6 @@ public final class FileSourceDb { | |||
} | |||
} | |||
// optional string scm_author = 4; | |||
public static final int SCM_AUTHOR_FIELD_NUMBER = 4; | |||
private java.lang.Object scmAuthor_; | |||
/** | |||
@@ -598,7 +584,6 @@ public final class FileSourceDb { | |||
} | |||
} | |||
// optional int64 scm_date = 5; | |||
public static final int SCM_DATE_FIELD_NUMBER = 5; | |||
private long scmDate_; | |||
/** | |||
@@ -614,7 +599,6 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return utLineHits_; | |||
} | |||
// optional int32 ut_conditions = 7; | |||
public static final int UT_CONDITIONS_FIELD_NUMBER = 7; | |||
private int utConditions_; | |||
/** | |||
@@ -654,7 +637,6 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return itLineHits_; | |||
} | |||
// optional int32 it_conditions = 10; | |||
public static final int IT_CONDITIONS_FIELD_NUMBER = 10; | |||
private int itConditions_; | |||
/** | |||
@@ -710,7 +690,6 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return overallLineHits_; | |||
} | |||
// optional int32 overall_conditions = 13; | |||
public static final int OVERALL_CONDITIONS_FIELD_NUMBER = 13; | |||
private int overallConditions_; | |||
/** | |||
@@ -766,7 +743,6 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return overallCoveredConditions_; | |||
} | |||
// optional string highlighting = 15; | |||
public static final int HIGHLIGHTING_FIELD_NUMBER = 15; | |||
private java.lang.Object highlighting_; | |||
/** | |||
@@ -825,7 +800,6 @@ public final class FileSourceDb { | |||
} | |||
} | |||
// optional string symbols = 16; | |||
public static final int SYMBOLS_FIELD_NUMBER = 16; | |||
private java.lang.Object symbols_; | |||
/** | |||
@@ -868,7 +842,6 @@ public final class FileSourceDb { | |||
} | |||
} | |||
// repeated int32 duplication = 17 [packed = true]; | |||
public static final int DUPLICATION_FIELD_NUMBER = 17; | |||
private java.util.List<java.lang.Integer> duplication_; | |||
/** | |||
@@ -914,7 +887,8 @@ public final class FileSourceDb { | |||
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 @@ public final class FileSourceDb { | |||
* Protobuf type {@code org.sonar.server.source.db.Line} | |||
*/ | |||
public static final class Builder extends | |||
com.google.protobuf.GeneratedMessage.Builder<Builder> | |||
implements org.sonar.server.source.db.FileSourceDb.LineOrBuilder { | |||
com.google.protobuf.GeneratedMessage.Builder<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 final class FileSourceDb { | |||
} | |||
private int bitField0_; | |||
// optional int32 line = 1; | |||
private int line_ ; | |||
/** | |||
* <code>optional int32 line = 1;</code> | |||
@@ -1456,7 +1430,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional string source = 2; | |||
private java.lang.Object source_ = ""; | |||
/** | |||
* <code>optional string source = 2;</code> | |||
@@ -1470,9 +1443,12 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return this; | |||
} | |||
// optional string scm_revision = 3; | |||
private java.lang.Object scmRevision_ = ""; | |||
/** | |||
* <code>optional string scm_revision = 3;</code> | |||
@@ -1552,9 +1527,12 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return this; | |||
} | |||
// optional string scm_author = 4; | |||
private java.lang.Object scmAuthor_ = ""; | |||
/** | |||
* <code>optional string scm_author = 4;</code> | |||
@@ -1642,9 +1619,12 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int64 scm_date = 5; | |||
private long scmDate_ ; | |||
/** | |||
* <code>optional int64 scm_date = 5;</code> | |||
@@ -1735,7 +1714,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 ut_line_hits = 6; | |||
private int utLineHits_ ; | |||
/** | |||
* <code>optional int32 ut_line_hits = 6;</code> | |||
@@ -1784,7 +1762,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 ut_conditions = 7; | |||
private int utConditions_ ; | |||
/** | |||
* <code>optional int32 ut_conditions = 7;</code> | |||
@@ -1817,7 +1794,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 ut_covered_conditions = 8; | |||
private int utCoveredConditions_ ; | |||
/** | |||
* <code>optional int32 ut_covered_conditions = 8;</code> | |||
@@ -1850,7 +1826,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 it_line_hits = 9; | |||
private int itLineHits_ ; | |||
/** | |||
* <code>optional int32 it_line_hits = 9;</code> | |||
@@ -1899,7 +1874,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 it_conditions = 10; | |||
private int itConditions_ ; | |||
/** | |||
* <code>optional int32 it_conditions = 10;</code> | |||
@@ -1932,7 +1906,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 it_covered_conditions = 11; | |||
private int itCoveredConditions_ ; | |||
/** | |||
* <code>optional int32 it_covered_conditions = 11;</code> | |||
@@ -1965,7 +1938,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 overall_line_hits = 12; | |||
private int overallLineHits_ ; | |||
/** | |||
* <code>optional int32 overall_line_hits = 12;</code> | |||
@@ -2014,7 +1986,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 overall_conditions = 13; | |||
private int overallConditions_ ; | |||
/** | |||
* <code>optional int32 overall_conditions = 13;</code> | |||
@@ -2047,7 +2018,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional int32 overall_covered_conditions = 14; | |||
private int overallCoveredConditions_ ; | |||
/** | |||
* <code>optional int32 overall_covered_conditions = 14;</code> | |||
@@ -2080,7 +2050,6 @@ public final class FileSourceDb { | |||
return this; | |||
} | |||
// optional string highlighting = 15; | |||
private java.lang.Object highlighting_ = ""; | |||
/** | |||
* <code>optional string highlighting = 15;</code> | |||
@@ -2094,9 +2063,12 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return this; | |||
} | |||
// optional string symbols = 16; | |||
private java.lang.Object symbols_ = ""; | |||
/** | |||
* <code>optional string symbols = 16;</code> | |||
@@ -2168,9 +2139,12 @@ public final class FileSourceDb { | |||
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 final class FileSourceDb { | |||
return this; | |||
} | |||
// repeated int32 duplication = 17 [packed = true]; | |||
private java.util.List<java.lang.Integer> duplication_ = java.util.Collections.emptyList(); | |||
private void ensureDuplicationIsMutable() { | |||
if (!((bitField0_ & 0x00010000) == 0x00010000)) { | |||
@@ -2280,7 +2253,8 @@ public final class FileSourceDb { | |||
public Builder addAllDuplication( | |||
java.lang.Iterable<? extends java.lang.Integer> values) { | |||
ensureDuplicationIsMutable(); | |||
super.addAll(values, duplication_); | |||
com.google.protobuf.AbstractMessageLite.Builder.addAll( | |||
values, duplication_); | |||
onChanged(); | |||
return this; | |||
} | |||
@@ -2305,10 +2279,10 @@ public final class FileSourceDb { | |||
// @@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; | |||
/** | |||
* <code>repeated .org.sonar.server.source.db.Line lines = 1;</code> | |||
*/ | |||
@@ -2337,8 +2311,9 @@ public final class FileSourceDb { | |||
* 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 final class FileSourceDb { | |||
return PARSER; | |||
} | |||
// repeated .org.sonar.server.source.db.Line lines = 1; | |||
public static final int LINES_FIELD_NUMBER = 1; | |||
private java.util.List<org.sonar.server.source.db.FileSourceDb.Line> lines_; | |||
/** | |||
@@ -2476,7 +2450,8 @@ public final class FileSourceDb { | |||
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 @@ public final class FileSourceDb { | |||
* Protobuf type {@code org.sonar.server.source.db.Data} | |||
*/ | |||
public static final class Builder extends | |||
com.google.protobuf.GeneratedMessage.Builder<Builder> | |||
implements org.sonar.server.source.db.FileSourceDb.DataOrBuilder { | |||
com.google.protobuf.GeneratedMessage.Builder<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 final class FileSourceDb { | |||
} | |||
private int bitField0_; | |||
// repeated .org.sonar.server.source.db.Line lines = 1; | |||
private java.util.List<org.sonar.server.source.db.FileSourceDb.Line> lines_ = | |||
java.util.Collections.emptyList(); | |||
private void ensureLinesIsMutable() { | |||
@@ -2870,7 +2845,8 @@ public final class FileSourceDb { | |||
java.lang.Iterable<? extends org.sonar.server.source.db.FileSourceDb.Line> 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 final class FileSourceDb { | |||
// @@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 final class FileSourceDb { | |||
" .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) |
@@ -36,15 +36,25 @@ public class BatchReportReader { | |||
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<BatchReport.Measure> 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 class BatchReportReader { | |||
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(); | |||
} | |||
} |
@@ -63,6 +63,14 @@ public class BatchReportWriter { | |||
ProtobufUtil.writeToFile(issuesBuilder.build(), file); | |||
} | |||
public void writeComponentMeasures(int componentRef, Iterable<BatchReport.Measure> 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 |
@@ -27,7 +27,7 @@ import java.io.File; | |||
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; | |||
@@ -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; |
@@ -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; |
@@ -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 @@ public class BatchReportReaderTest { | |||
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())); | |||
} | |||
} |
@@ -119,6 +119,30 @@ public class BatchReportWriterTest { | |||
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(); |
@@ -169,7 +169,6 @@ public class DefaultTimeMachine implements TimeMachine { | |||
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; |
@@ -111,7 +111,6 @@ public class MeasurePersister implements ScanPersister { | |||
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()); |
@@ -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<MeasureKey>{ | |||
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 class MeasureDto extends Dto<MeasureKey>{ | |||
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 class MeasureDto extends Dto<MeasureKey>{ | |||
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 class MeasureDto extends Dto<MeasureKey>{ | |||
} | |||
} | |||
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 class MeasureDto extends Dto<MeasureKey>{ | |||
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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -28,13 +28,14 @@ import java.util.List; | |||
public interface MeasureMapper { | |||
MeasureDto selectByKey(@Param("key") MeasureKey key); | |||
MeasureDto selectByKey(@Param("componentKey") String componentKey, @Param("metricKey") String metricKey); | |||
List<MeasureDto> selectByComponentAndMetrics(@Param("componentKey") String componentKey, @Param("metricKeys") List<String> 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); | |||
} |
@@ -33,7 +33,7 @@ import javax.annotation.Nullable; | |||
import java.util.*; | |||
public final class RuleDto extends Dto<RuleKey> { | |||
public class RuleDto extends Dto<RuleKey> { | |||
public static final Integer DISABLED_CHARACTERISTIC_ID = -1; | |||
@@ -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 | |||
</sql> | |||
<select id="selectByKey" parameterType="map" resultType="Measure"> | |||
SELECT | |||
<include refid="measureColumns"/> | |||
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} | |||
<where> | |||
AND p.kee = #{key.componentKey} | |||
AND metric.name = #{key.metricKey} | |||
AND pm.rule_id IS NULL | |||
AND pm.characteristic_id IS NULL | |||
AND pm.person_id IS NULL | |||
</where> | |||
</select> | |||
<select id="selectByComponentAndMetrics" parameterType="map" resultType="Measure"> | |||
<select id="selectByComponentAndMetric" parameterType="map" resultType="Measure"> | |||
SELECT metric.name as metric_name, | |||
<include refid="measureColumns"/> | |||
FROM project_measures pm | |||
@@ -43,14 +27,14 @@ | |||
INNER JOIN metrics metric ON metric.id=pm.metric_id | |||
<where> | |||
AND p.kee = #{componentKey} | |||
AND <foreach item="metricKey" index="index" collection="metricKeys" open="(" separator=" or " close=")">metric.name=#{metricKey}</foreach> | |||
AND metric.name=#{metricKey} | |||
AND pm.rule_id IS NULL | |||
AND pm.characteristic_id IS NULL | |||
AND pm.person_id IS NULL | |||
</where> | |||
</select> | |||
<select id="selectByComponentAndMetric" parameterType="map" resultType="Measure"> | |||
<select id="selectByComponentAndMetrics" parameterType="map" resultType="Measure"> | |||
SELECT metric.name as metric_name, | |||
<include refid="measureColumns"/> | |||
FROM project_measures pm | |||
@@ -59,26 +43,44 @@ | |||
INNER JOIN metrics metric ON metric.id=pm.metric_id | |||
<where> | |||
AND p.kee = #{componentKey} | |||
AND metric.name=#{metricKey} | |||
AND | |||
<foreach item="metricKey" index="index" collection="metricKeys" open="(" separator=" or " close=")"> | |||
metric.name=#{metricKey} | |||
</foreach> | |||
AND pm.rule_id IS NULL | |||
AND pm.characteristic_id IS NULL | |||
AND pm.person_id IS NULL | |||
</where> | |||
</select> | |||
<select id="countByKey" parameterType="map" resultType="long"> | |||
<select id="countByComponentAndMetric" parameterType="map" resultType="long"> | |||
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} | |||
<where> | |||
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 | |||
</where> | |||
</select> | |||
<insert id="insert" parameterType="Measure" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> | |||
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} | |||
) | |||
</insert> | |||
</mapper> |
@@ -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); | |||
} | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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.DatabaseUnitException; | |||
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 abstract class AbstractDaoTestCase { | |||
} | |||
} | |||
@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 @@ public abstract class AbstractDaoTestCase { | |||
} | |||
} | |||
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 @@ public abstract class AbstractDaoTestCase { | |||
} | |||
} | |||
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(); | |||
} |