From: Sébastien Lesaint Date: Wed, 2 Dec 2015 16:36:54 +0000 (+0100) Subject: SONAR-7027 add&retrieve raw measure for dev in MeasureRepositoryRule X-Git-Tag: 5.3-RC1~93 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=70e0f84f971e5a6adb79613c956584116e129318;p=sonarqube.git SONAR-7027 add&retrieve raw measure for dev in MeasureRepositoryRule --- diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java index 9f0e09422c4..f62de9218e2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java @@ -35,6 +35,7 @@ import org.junit.rules.ExternalResource; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.ComponentProvider; import org.sonar.server.computation.component.Developer; +import org.sonar.server.computation.component.DumbDeveloper; import org.sonar.server.computation.component.NoComponentProvider; import org.sonar.server.computation.component.TreeComponentProvider; import org.sonar.server.computation.component.TreeRootHolder; @@ -232,7 +233,7 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe checkAndInitProvidersState(); InternalKey internalKey = new InternalKey(componentProvider.getByRef(componentRef), metricRepositoryRule.getByKey(metricKey), measure.getRuleId(), - measure.getCharacteristicId()); + measure.getCharacteristicId(), measure.getDeveloper()); checkState(!rawMeasures.containsKey(internalKey), format( "A measure can only be set once for Component (ref=%s), Metric (key=%s), ruleId=%s, characteristicId=%s", componentRef, metricKey, measure.getRuleId(), measure.getCharacteristicId())); @@ -253,6 +254,10 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe return Optional.fromNullable(rawMeasures.get(new InternalKey(component, metric))); } + public Optional getRawMeasure(Component component, Metric metric, DumbDeveloper developer) { + return Optional.fromNullable(rawMeasures.get(new InternalKey(component, metric, null, null, developer))); + } + public Optional getRawRuleMeasure(Component component, Metric metric, int ruleId) { return Optional.fromNullable(rawMeasures.get(new InternalKey(component, metric, ruleId, null))); } @@ -330,7 +335,11 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe this(getRef(component), metric.getKey(), ruleId, characteristicId, null); } - public InternalKey(String componentRef, String metricKey, @Nullable Integer ruleId, @Nullable Integer characteristicId, @Nullable Developer developer) { + public InternalKey(Component component, Metric metric, @Nullable Integer ruleId, @Nullable Integer characteristicId, @Nullable Developer developer) { + this(getRef(component), metric.getKey(), ruleId, characteristicId, null); + } + + private InternalKey(String componentRef, String metricKey, @Nullable Integer ruleId, @Nullable Integer characteristicId, @Nullable Developer developer) { this.componentRef = componentRef; this.metricKey = metricKey; this.ruleId = ruleId == null ? DEFAULT_VALUE : ruleId;