]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7027 add&retrieve raw measure for dev in MeasureRepositoryRule
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 2 Dec 2015 16:36:54 +0000 (17:36 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 3 Dec 2015 07:43:18 +0000 (08:43 +0100)
server/sonar-server/src/test/java/org/sonar/server/computation/measure/MeasureRepositoryRule.java

index 9f0e09422c45d74dba1180fc52e74b517a9050ea..f62de9218e2524b044c659c36e0d01e55ef30593 100644 (file)
@@ -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<Measure> getRawMeasure(Component component, Metric metric, DumbDeveloper developer) {
+    return Optional.fromNullable(rawMeasures.get(new InternalKey(component, metric, null, null, developer)));
+  }
+
   public Optional<Measure> 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;