]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8743 Remove MeasureVariations
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 8 Feb 2017 10:08:06 +0000 (11:08 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 9 Feb 2017 11:15:11 +0000 (12:15 +0100)
15 files changed:
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/BestValueOptimization.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/Measure.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureDtoToMeasure.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureToMeasureDto.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureVariations.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistMeasuresStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/BestValueOptimizationTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureAssert.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureDtoToMeasureTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureRepoEntry.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureToMeasureDtoTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureVariationsTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistMeasuresStepTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/QualityGateMeasuresStepTest.java

index e0282b9f8daf725ac27194f218e558f5b16b4b69..bf9cba661f65edde9b3f9d18efaf39e106ebf733 100644 (file)
@@ -65,15 +65,7 @@ public class BestValueOptimization implements Predicate<Measure> {
   }
 
   private static boolean hasNoVariation(Measure measure, Double bestValue) {
-    return !measure.hasVariations() || hasOnlyZeroVariations(measure.getVariations(), bestValue);
-  }
-
-  private static boolean hasOnlyZeroVariations(MeasureVariations variations, Double bestValue) {
-    return (!variations.hasVariation1() || isVariationEmptyOrBestValue(variations.getVariation1(), bestValue))
-      && (!variations.hasVariation2() || isVariationEmptyOrBestValue(variations.getVariation2(), bestValue))
-      && (!variations.hasVariation3() || isVariationEmptyOrBestValue(variations.getVariation3(), bestValue))
-      && (!variations.hasVariation4() || isVariationEmptyOrBestValue(variations.getVariation4(), bestValue))
-      && (!variations.hasVariation5() || isVariationEmptyOrBestValue(variations.getVariation5(), bestValue));
+    return !measure.hasVariation() || isVariationEmptyOrBestValue(measure.getVariation(), bestValue);
   }
 
   private static boolean isVariationEmptyOrBestValue(double variation, Double bestValue) {
index f12a73c3ced386f7e9033d7a03fe8cd4d189cfed..3038460991f133d35b4ac9b477c9611148079c0e 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Objects;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.server.computation.task.projectanalysis.component.Developer;
-import org.sonar.server.computation.task.projectanalysis.period.Period;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
@@ -81,24 +80,7 @@ public final class Measure {
   @CheckForNull
   private final QualityGateStatus qualityGateStatus;
   @CheckForNull
-  private final MeasureVariations variations;
-
-  /**
-   * @deprecated {{@link #Measure(ValueType, Developer, Double, String, Level, String, QualityGateStatus, Double)}} should be used instead
-   */
-  @Deprecated
-  private Measure(ValueType valueType, @Nullable Developer developer,
-    @Nullable Double value, @Nullable String data, @Nullable Level dataLevel,
-    @Nullable String description, @Nullable QualityGateStatus qualityGateStatus, @Nullable MeasureVariations variations) {
-    this.valueType = valueType;
-    this.developer = developer;
-    this.value = value;
-    this.data = data;
-    this.dataLevel = dataLevel;
-    this.description = description;
-    this.qualityGateStatus = qualityGateStatus;
-    this.variations = variations;
-  }
+  private final Double variation;
 
   private Measure(ValueType valueType, @Nullable Developer developer,
     @Nullable Double value, @Nullable String data, @Nullable Level dataLevel,
@@ -110,7 +92,7 @@ public final class Measure {
     this.dataLevel = dataLevel;
     this.description = description;
     this.qualityGateStatus = qualityGateStatus;
-    this.variations = variation != null ? createLeakVariation(variation) : null;
+    this.variation = variation;
   }
 
   public static NewMeasureBuilder newMeasureBuilder() {
@@ -125,7 +107,7 @@ public final class Measure {
     private Developer developer;
     private String description;
     private QualityGateStatus qualityGateStatus;
-    private MeasureVariations variations;
+    private Double variation;
 
     /**
      * Sets the developer this measure is associated to.
@@ -151,22 +133,13 @@ public final class Measure {
       return this;
     }
 
-    /**
-     * @deprecated as only one period is now available. Use {@link #hasVariation()} instead
-     */
-    @Deprecated
-    public NewMeasureBuilder setVariations(MeasureVariations variations) {
-      this.variations = requireNonNull(variations, "Variations can not be set to null");
-      return this;
-    }
-
     public NewMeasureBuilder setVariation(double variation) {
-      this.variations = createLeakVariation(variation);
+      this.variation = variation;
       return this;
     }
 
     public Measure create(boolean value, @Nullable String data) {
-      return new Measure(ValueType.BOOLEAN, developer, value ? 1.0d : 0.0d, data, null, description, qualityGateStatus, variations);
+      return new Measure(ValueType.BOOLEAN, developer, value ? 1.0d : 0.0d, data, null, description, qualityGateStatus, variation);
     }
 
     public Measure create(boolean value) {
@@ -174,7 +147,7 @@ public final class Measure {
     }
 
     public Measure create(int value, @Nullable String data) {
-      return new Measure(ValueType.INT, developer, (double) value, data, null, description, qualityGateStatus, variations);
+      return new Measure(ValueType.INT, developer, (double) value, data, null, description, qualityGateStatus, variation);
     }
 
     public Measure create(int value) {
@@ -182,7 +155,7 @@ public final class Measure {
     }
 
     public Measure create(long value, @Nullable String data) {
-      return new Measure(ValueType.LONG, developer, (double) value, data, null, description, qualityGateStatus, variations);
+      return new Measure(ValueType.LONG, developer, (double) value, data, null, description, qualityGateStatus, variation);
     }
 
     public Measure create(long value) {
@@ -192,7 +165,7 @@ public final class Measure {
     public Measure create(double value, int decimalScale, @Nullable String data) {
       checkArgument(!Double.isNaN(value), "NaN is not allowed as a Measure value");
       double scaledValue = scale(value, decimalScale);
-      return new Measure(ValueType.DOUBLE, developer, scaledValue, data, null, description, qualityGateStatus, variations);
+      return new Measure(ValueType.DOUBLE, developer, scaledValue, data, null, description, qualityGateStatus, variation);
     }
 
     public Measure create(double value, int decimalScale) {
@@ -200,15 +173,15 @@ public final class Measure {
     }
 
     public Measure create(String value) {
-      return new Measure(ValueType.STRING, developer, null, requireNonNull(value), null, description, qualityGateStatus, variations);
+      return new Measure(ValueType.STRING, developer, null, requireNonNull(value), null, description, qualityGateStatus, variation);
     }
 
     public Measure create(Level level) {
-      return new Measure(ValueType.LEVEL, developer, null, null, requireNonNull(level), description, qualityGateStatus, variations);
+      return new Measure(ValueType.LEVEL, developer, null, null, requireNonNull(level), description, qualityGateStatus, variation);
     }
 
     public Measure createNoValue() {
-      return new Measure(ValueType.NO_VALUE, developer, null, null, null, description, qualityGateStatus, variations);
+      return new Measure(ValueType.NO_VALUE, developer, null, null, null, description, qualityGateStatus, variation);
     }
 
     private static double scale(double value, int decimalScale) {
@@ -220,7 +193,7 @@ public final class Measure {
   public static final class UpdateMeasureBuilder {
     private final Measure source;
     private QualityGateStatus qualityGateStatus;
-    private MeasureVariations variations;
+    private Double variation;
 
     public UpdateMeasureBuilder(Measure source) {
       this.source = requireNonNull(source, "Can not create a measure from null");
@@ -240,32 +213,16 @@ public final class Measure {
       return this;
     }
 
-    /**
-     * Sets the MeasureVariations of the updated Measure to create.
-     *
-     * @throws NullPointerException if the specified {@link MeasureVariations} is {@code null}
-     * @throws UnsupportedOperationException if the source measure already has a {@link MeasureVariations}
-     * @deprecated as only one period is now available. Use {@link #setVariation(double)} instead
-     */
-    @Deprecated
-    public UpdateMeasureBuilder setVariations(MeasureVariations variations) {
-      if (source.variations != null) {
-        throw new UnsupportedOperationException("Variations can not be changed if already set on source Measure");
-      }
-      this.variations = requireNonNull(variations, "Variations can not be set to null");
-      return this;
-    }
-
     /**
      * Sets the variation of the updated Measure to create.
      *
-     * @throws UnsupportedOperationException if the source measure already has a {@link MeasureVariations}
+     * @throws UnsupportedOperationException if the source measure already has a variation
      */
     public UpdateMeasureBuilder setVariation(double variation) {
-      if (source.variations != null) {
+      if (source.variation != null) {
         throw new UnsupportedOperationException("Variation can not be changed if already set on source Measure");
       }
-      this.variations = createLeakVariation(variation);
+      this.variation = variation;
       return this;
     }
 
@@ -274,7 +231,7 @@ public final class Measure {
         source.value, source.data, source.dataLevel,
         source.description,
         source.qualityGateStatus == null ? qualityGateStatus : source.qualityGateStatus,
-        source.variations == null ? variations : source.variations);
+        source.variation == null ? variation : source.variation);
     }
   }
 
@@ -388,32 +345,11 @@ public final class Measure {
     return this.qualityGateStatus;
   }
 
-  /**
-   * Any Measure, which ever is its value type, can have a Variations.
-   * @deprecated as only one period is now available. Use {@link #hasVariation()} instead
-   */
-  @Deprecated
-  public boolean hasVariations() {
-    return variations != null;
-  }
-
   /**
    * Any Measure, which ever is its value type, can have a variation.
    */
   public boolean hasVariation() {
-    return hasVariations() && variations.hasVariation1();
-  }
-
-  /**
-   * The variations of this measure.
-   *
-   * @throws IllegalStateException if the measure has no MeasureVariations
-   * @deprecated as only one period is now available. Use {@link #getVariation()} instead
-   */
-  @Deprecated
-  public MeasureVariations getVariations() {
-    checkState(variations != null, "Measure does not have variations");
-    return variations;
+    return variation != null;
   }
 
   /**
@@ -422,8 +358,8 @@ public final class Measure {
    * @throws IllegalStateException if the measure has no variation
    */
   public double getVariation() {
-    checkState(variations != null, "Measure does not have variation");
-    return variations.getVariation1();
+    checkState(variation != null, "Measure does not have variation");
+    return variation;
   }
 
   /**
@@ -464,12 +400,9 @@ public final class Measure {
       .add("data", data)
       .add("dataLevel", dataLevel)
       .add("qualityGateStatus", qualityGateStatus)
-      .add("variations", variations)
+      .add("variations", variation)
       .add("description", description)
       .toString();
   }
 
-  private static MeasureVariations createLeakVariation(double variation) {
-    return MeasureVariations.newMeasureVariationsBuilder().setVariation(new Period(1, "mode", null, 0l, null), variation).build();
-  }
 }
index 1869cffbbd03d6a3a8998dc905d3060c199a0394..49aebddddeb301ea1aecd216e4f8688b3ef89e92 100644 (file)
@@ -117,7 +117,7 @@ public class MeasureDtoToMeasure {
       }
     }
     if (hasAnyVariation(measureDto)) {
-      builder.setVariations(createVariations(measureDto));
+      builder.setVariation(measureDto.getVariation());
     }
     return builder;
   }
@@ -126,8 +126,4 @@ public class MeasureDtoToMeasure {
     return measureDto.getVariation() != null;
   }
 
-  private static MeasureVariations createVariations(MeasureDto measureDto) {
-    return new MeasureVariations(measureDto.getVariation());
-  }
-
 }
index 0a117786fd1dea24a06b55cdd5e41bd396f52c82..a88ae053187991c48dd85142830f043db6e8f3d6 100644 (file)
@@ -44,8 +44,8 @@ public class MeasureToMeasureDto {
     out.setMetricId(metric.getId());
     out.setComponentUuid(component.getUuid());
     out.setAnalysisUuid(analysisMetadataHolder.getUuid());
-    if (measure.hasVariations()) {
-      setVariation(out, measure.getVariations());
+    if (measure.hasVariation()) {
+      out.setVariation(measure.getVariation());
     }
     if (measure.hasQualityGateStatus()) {
       setAlert(out, measure.getQualityGateStatus());
@@ -60,10 +60,6 @@ public class MeasureToMeasureDto {
     return out;
   }
 
-  private static void setVariation(MeasureDto measureDto, MeasureVariations variations) {
-    measureDto.setVariation(variations.hasVariation1() ? variations.getVariation1() : null);
-  }
-
   private static void setAlert(MeasureDto measureDto, QualityGateStatus qualityGateStatus) {
     measureDto.setAlertStatus(qualityGateStatus.getStatus().name());
     measureDto.setAlertText(qualityGateStatus.getText());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureVariations.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureVariations.java
deleted file mode 100644 (file)
index 5a3aa75..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.task.projectanalysis.measure;
-
-import com.google.common.base.MoreObjects;
-import java.util.Arrays;
-import java.util.Objects;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-import org.sonar.server.computation.task.projectanalysis.period.Period;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * @deprecated as only one period is now available, this class should be simply replaced by a {@link Double}
- */
-@Immutable
-@Deprecated
-public final class MeasureVariations {
-  private static final String NAN_ERROR_MESSAGE = "NaN is not allowed in MeasureVariation";
-
-  private final Double[] variations = new Double[5];
-
-  public MeasureVariations(Double... variations) {
-    checkArgument(variations.length <= 5, "There can not be more than 5 variations");
-    checkArgument(Arrays.stream(variations).anyMatch(Objects::nonNull), "There must be at least one variation");
-    for (Double variation : variations) {
-      checkArgument(variation == null || !Double.isNaN(variation), NAN_ERROR_MESSAGE);
-    }
-    System.arraycopy(variations, 0, this.variations, 0, variations.length);
-  }
-
-  public static Builder newMeasureVariationsBuilder() {
-    return new Builder();
-  }
-
-  public static final class Builder {
-    private final Double[] variations = new Double[5];
-
-    private Builder() {
-      // prevents instantiation outside static method
-    }
-
-    public Builder setVariation(Period period, double variation) {
-      int arrayIndex = period.getIndex() - 1;
-      checkState(variations[arrayIndex] == null, "Variation for Period %s has already been set", period.getIndex());
-      checkArgument(!Double.isNaN(variation), NAN_ERROR_MESSAGE);
-      variations[arrayIndex] = variation;
-      return this;
-    }
-
-    /**
-     * Indicates whether any variation has been set in the builder.
-     * This method can be used to know beforehand whether the {@link #build()} method will raise a
-     * {@link IllegalArgumentException} because the constructor of {@link MeasureVariations} has been invoked with no
-     * value.
-     */
-    public boolean isEmpty() {
-      for (Double variation : variations) {
-        if (variation != null) {
-          return false;
-        }
-      }
-      return true;
-    }
-
-    public MeasureVariations build() {
-      return new MeasureVariations(variations);
-    }
-  }
-
-  public boolean hasVariation1() {
-    return hasVariation(1);
-  }
-
-  public boolean hasVariation2() {
-    return hasVariation(2);
-  }
-
-  public boolean hasVariation3() {
-    return hasVariation(3);
-  }
-
-  public boolean hasVariation4() {
-    return hasVariation(4);
-  }
-
-  public boolean hasVariation5() {
-    return hasVariation(5);
-  }
-
-  private void checkHasVariation(int periodIndex) {
-    if (!hasVariation(periodIndex)) {
-      throw new IllegalStateException(String.format("Variation %s has not been set", periodIndex));
-    }
-  }
-
-  public boolean hasVariation(int periodIndex) {
-    return variations[periodIndex - 1] != null;
-  }
-
-  public double getVariation1() {
-    return getVariation(1);
-  }
-
-  public double getVariation2() {
-    return getVariation(2);
-  }
-
-  public double getVariation3() {
-    return getVariation(3);
-  }
-
-  public double getVariation4() {
-    return getVariation(4);
-  }
-
-  public double getVariation5() {
-    return getVariation(5);
-  }
-
-  public double getVariation(int i) {
-    checkHasVariation(i);
-    return variations[i - 1];
-  }
-
-  @Override
-  public String toString() {
-    return MoreObjects.toStringHelper(this)
-      .add("1", variations[0])
-      .add("2", variations[1])
-      .add("3", variations[2])
-      .add("4", variations[3])
-      .add("5", variations[4])
-      .toString();
-  }
-
-  @Override
-  public boolean equals(@Nullable Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-    MeasureVariations that = (MeasureVariations) o;
-    return Arrays.equals(variations, that.variations);
-  }
-
-  @Override
-  public int hashCode() {
-    return Arrays.hashCode(variations);
-  }
-}
index 5eabcd82ccf05e35081bf49c81ed105599b0a8d8..281582ad6b2a700da29bc10b2b702ba67ee9ebdc 100644 (file)
@@ -129,7 +129,7 @@ public class PersistMeasuresStep implements ComputationStep {
 
     @Override
     public boolean apply(@Nonnull Measure input) {
-      return input.getValueType() != Measure.ValueType.NO_VALUE || input.hasVariations() || input.getData() != null;
+      return input.getValueType() != Measure.ValueType.NO_VALUE || input.hasVariation() || input.getData() != null;
     }
   }
 
index 8f6cf385a243ba27d024f5623b8f3a43cbd0bad6..2ffdfe6256eec123af9df846aaad1b4203f27eb6 100644 (file)
@@ -38,19 +38,19 @@ public class BestValueOptimizationTest {
   private static final String SOME_DATA = "some_data";
   private static final MetricImpl METRIC_BOOLEAN_FALSE = createMetric(Metric.MetricType.BOOL, 6d);
   private static final MetricImpl METRIC_BOOLEAN_TRUE = createMetric(Metric.MetricType.BOOL, 1d);
-  private static final MeasureVariations SOME_EMPTY_VARIATIONS = new MeasureVariations(null, 0d, null, 0d, null);
+  private static final double SOME_EMPTY_VARIATIONS = 0d;
 
   public static Measure.NewMeasureBuilder[] builders_of_non_bestValueOptimized_measures() {
     QualityGateStatus someQualityGateStatus = new QualityGateStatus(Measure.Level.ERROR, null);
-    MeasureVariations someVariations = new MeasureVariations(2d);
+    double someVariations = 2d;
     String someDescription = "desc";
     return new Measure.NewMeasureBuilder[] {
       newMeasureBuilder().setQualityGateStatus(someQualityGateStatus),
-      newMeasureBuilder().setQualityGateStatus(someQualityGateStatus).setVariations(someVariations),
-      newMeasureBuilder().setVariations(someVariations),
+      newMeasureBuilder().setQualityGateStatus(someQualityGateStatus).setVariation(someVariations),
+      newMeasureBuilder().setVariation(someVariations),
       newMeasureBuilder().setQualityGateStatus(someQualityGateStatus).setDescription(someDescription),
       newMeasureBuilder().setDescription(someDescription),
-      newMeasureBuilder().setQualityGateStatus(someQualityGateStatus).setVariations(someVariations).setDescription(someDescription),
+      newMeasureBuilder().setQualityGateStatus(someQualityGateStatus).setVariation(someVariations).setDescription(someDescription),
     };
   }
 
@@ -59,9 +59,9 @@ public class BestValueOptimizationTest {
     Predicate<Measure> underTest = BestValueOptimization.from(METRIC_BOOLEAN_TRUE, FILE_COMPONENT);
 
     assertThat(underTest.apply(newMeasureBuilder().create(true))).isTrue();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(SOME_EMPTY_VARIATIONS).create(true))).isTrue();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation(SOME_EMPTY_VARIATIONS).create(true))).isTrue();
     assertThat(underTest.apply(newMeasureBuilder().create(false))).isFalse();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(SOME_EMPTY_VARIATIONS).create(false))).isFalse();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation(SOME_EMPTY_VARIATIONS).create(false))).isFalse();
   }
 
   @Test
@@ -96,7 +96,7 @@ public class BestValueOptimizationTest {
 
     assertThat(underTest.apply(newMeasureBuilder().create(true))).isFalse();
     assertThat(underTest.apply(newMeasureBuilder().create(false))).isTrue();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(SOME_EMPTY_VARIATIONS).create(false))).isTrue();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation(SOME_EMPTY_VARIATIONS).create(false))).isTrue();
   }
 
   @Test
@@ -130,7 +130,7 @@ public class BestValueOptimizationTest {
     Predicate<Measure> underTest = BestValueOptimization.from(createMetric(Metric.MetricType.INT, 10), FILE_COMPONENT);
 
     assertThat(underTest.apply(newMeasureBuilder().create(10))).isTrue();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(SOME_EMPTY_VARIATIONS).create(10))).isTrue();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation(SOME_EMPTY_VARIATIONS).create(10))).isTrue();
     assertThat(underTest.apply(newMeasureBuilder().create(11))).isFalse();
   }
 
@@ -139,7 +139,7 @@ public class BestValueOptimizationTest {
     Predicate<Measure> underTest = BestValueOptimization.from(createMetric(Metric.MetricType.WORK_DUR, 9511L), FILE_COMPONENT);
 
     assertThat(underTest.apply(newMeasureBuilder().create(9511L))).isTrue();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(SOME_EMPTY_VARIATIONS).create(9511L))).isTrue();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation(SOME_EMPTY_VARIATIONS).create(9511L))).isTrue();
     assertThat(underTest.apply(newMeasureBuilder().create(963L))).isFalse();
   }
 
@@ -148,9 +148,9 @@ public class BestValueOptimizationTest {
     Predicate<Measure> underTest = BestValueOptimization.from(createMetric(Metric.MetricType.RATING, A.getIndex()), FILE_COMPONENT);
 
     assertThat(underTest.apply(newMeasureBuilder().create(A.getIndex()))).isTrue();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(new MeasureVariations(null, (double) A.getIndex(), null, (double) A.getIndex(), null)).createNoValue())).isTrue();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation((double) A.getIndex()).createNoValue())).isTrue();
     assertThat(underTest.apply(newMeasureBuilder().create(B.getIndex()))).isFalse();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(new MeasureVariations(null, (double) A.getIndex(), null, (double) B.getIndex(), null)).createNoValue())).isFalse();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation((double) B.getIndex()).createNoValue())).isFalse();
   }
 
   @Test
@@ -158,7 +158,7 @@ public class BestValueOptimizationTest {
     Predicate<Measure> underTest = BestValueOptimization.from(createMetric(Metric.MetricType.FLOAT, 36.5d), FILE_COMPONENT);
 
     assertThat(underTest.apply(newMeasureBuilder().create(36.5d, 1))).isTrue();
-    assertThat(underTest.apply(newMeasureBuilder().setVariations(SOME_EMPTY_VARIATIONS).create(36.5d, 1))).isTrue();
+    assertThat(underTest.apply(newMeasureBuilder().setVariation(SOME_EMPTY_VARIATIONS).create(36.5d, 1))).isTrue();
     assertThat(underTest.apply(newMeasureBuilder().create(36.6d, 1))).isFalse();
   }
 
index d21e998949843d2ca53f7a278fe3f2bbf295b1a7..090ea642ffaba07f6f26bde8e878ae5719e8df42 100644 (file)
@@ -249,16 +249,6 @@ public class MeasureAssert extends AbstractAssert<MeasureAssert, Measure> {
     }
   }
 
-  public MeasureAssert hasNoVariations() {
-    isNotNull();
-
-    if (actual.hasVariations()) {
-      failWithMessage("Expected Measure to have a no Variations but it did");
-    }
-
-    return this;
-  }
-
   public MeasureAssert hasVariation(double expected) {
     isNotNull();
     hasVariation();
index 881379b75070e8030bd935d28ae7b374270cf398..a0ecb67a57c7412754a1fcc5cd13d60d1a6d7a20 100644 (file)
@@ -300,13 +300,13 @@ public class MeasureDtoToMeasureTest {
   @Test
   @UseDataProvider("all_types_MeasureDtos")
   public void toMeasure_creates_no_MeasureVariation_if_dto_has_none_whichever_the_ValueType(MeasureDto measureDto, Metric metric) {
-    assertThat(underTest.toMeasure(measureDto, metric).get().hasVariations()).isFalse();
+    assertThat(underTest.toMeasure(measureDto, metric).get().hasVariation()).isFalse();
   }
 
   @Test
   @UseDataProvider("all_types_MeasureDtos")
   public void toMeasure_creates_MeasureVariation_and_maps_the_right_one(MeasureDto builder, Metric metric) {
-    assertThat(underTest.toMeasure(builder.setVariation(1d), metric).get().getVariations().getVariation1()).isEqualTo(1);
+    assertThat(underTest.toMeasure(builder.setVariation(1d), metric).get().getVariation()).isEqualTo(1);
   }
 
   @Test
@@ -317,7 +317,7 @@ public class MeasureDtoToMeasureTest {
 
     Optional<Measure> measure = underTest.toMeasure(measureDto, SOME_STRING_METRIC);
 
-    assertThat(measure.get().getVariations().getVariation1()).isEqualTo(2);
+    assertThat(measure.get().getVariation()).isEqualTo(2);
   }
 
   @Test
index d69c78a027d7729be975881c05255805b31a24d4..d13ea26b0d5e9484ece58bbe6ac778f8e2758c72 100644 (file)
@@ -103,24 +103,8 @@ public final class MeasureRepoEntry {
   }
 
   private static boolean equalsByVariation(Measure measure, Measure measure1) {
-    if (measure.hasVariations() != measure1.hasVariations()) {
-      return false;
-    }
-    if (!measure.hasVariations()) {
-      return true;
-    }
-    MeasureVariations variations = measure.getVariations();
-    MeasureVariations variations1 = measure1.getVariations();
-    for (int i = 1; i <= 5; i++) {
-      if (variations.hasVariation(i) != variations1.hasVariation(i)) {
-        return false;
-      }
-      if (variations.hasVariation(i)
-          && Double.compare(scale(variations.getVariation(i)), scale(variations1.getVariation(i))) != 0) {
-        return false;
-      }
-    }
-    return true;
+    return measure.hasVariation() == measure1.hasVariation() && (!measure.hasVariation()
+      || Double.compare(scale(measure.getVariation()), scale(measure1.getVariation())) == 0);
   }
 
   private static final int DOUBLE_PRECISION = 1;
index bf99fadc3e735ae5ebe7ce9c03479a6e76875ed7..8d8b8eb05c94409c07e9046986a2cf4d7b150d52 100644 (file)
@@ -251,11 +251,6 @@ public class MeasureTest {
     newMeasureBuilder().setQualityGateStatus(null);
   }
 
-  @Test(expected = NullPointerException.class)
-  public void newMeasureBuilder_setVariations_throws_NPE_if_arg_is_null() {
-    newMeasureBuilder().setVariations(null);
-  }
-
   @Test(expected = NullPointerException.class)
   public void newMeasureBuilder_setDescription_throws_NPE_if_arg_is_null() {
     newMeasureBuilder().setDescription(null);
@@ -266,11 +261,6 @@ public class MeasureTest {
     Measure.updatedMeasureBuilder(newMeasureBuilder().createNoValue()).setQualityGateStatus(null);
   }
 
-  @Test(expected = NullPointerException.class)
-  public void updateMeasureBuilder_setVariations_throws_NPE_if_arg_is_null() {
-    Measure.updatedMeasureBuilder(newMeasureBuilder().createNoValue()).setVariations(null);
-  }
-
   @Test(expected = UnsupportedOperationException.class)
   public void updateMeasureBuilder_setQualityGateStatus_throws_USO_if_measure_already_has_a_QualityGateStatus() {
     QualityGateStatus qualityGateStatus = new QualityGateStatus(Measure.Level.ERROR);
@@ -280,9 +270,7 @@ public class MeasureTest {
 
   @Test(expected = UnsupportedOperationException.class)
   public void updateMeasureBuilder_setVariations_throws_USO_if_measure_already_has_Variations() {
-    MeasureVariations variations = new MeasureVariations(1d);
-
-    Measure.updatedMeasureBuilder(newMeasureBuilder().setVariations(variations).createNoValue()).setVariations(variations);
+    Measure.updatedMeasureBuilder(newMeasureBuilder().setVariation(1d).createNoValue()).setVariation(2d);
   }
 
   @Test
index d6a3b2b263c88f988f8154935cbff0fc173fe67b..e890251d5efb673a0d9874e3bee1ff454947df00 100644 (file)
@@ -44,7 +44,7 @@ public class MeasureToMeasureDtoTest {
   private static final int SOME_COMPONENT_ID = 951;
   private static final String SOME_DATA = "some_data";
   private static final String SOME_STRING = "some_string";
-  private static final MeasureVariations SOME_VARIATIONS = new MeasureVariations(1d);
+  private static final double SOME_VARIATIONS = 1d;
   private static final MetricImpl SOME_BOOLEAN_METRIC = new MetricImpl(1, "1", "1", Metric.MetricType.BOOL);
   private static final MetricImpl SOME_INT_METRIC = new MetricImpl(2, "2", "2", Metric.MetricType.INT);
   private static final MetricImpl SOME_LONG_METRIC = new MetricImpl(3, "3", "3", Metric.MetricType.DISTRIB);
@@ -100,7 +100,7 @@ public class MeasureToMeasureDtoTest {
 
   @Test
   public void toMeasureDto_returns_Dto_with_variation_if_Measure_has_MeasureVariations() {
-    MeasureDto measureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().setVariations(SOME_VARIATIONS).create(SOME_STRING), SOME_STRING_METRIC, SOME_COMPONENT);
+    MeasureDto measureDto = underTest.toMeasureDto(Measure.newMeasureBuilder().setVariation(SOME_VARIATIONS).create(SOME_STRING), SOME_STRING_METRIC, SOME_COMPONENT);
 
     assertThat(measureDto.getVariation()).isEqualTo(1d);
   }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureVariationsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MeasureVariationsTest.java
deleted file mode 100644 (file)
index f319797..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.task.projectanalysis.measure;
-
-import javax.annotation.Nullable;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.server.computation.task.projectanalysis.period.Period;
-import org.sonar.server.computation.task.projectanalysis.period.PeriodsHolder;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Fail.fail;
-import static org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations.newMeasureVariationsBuilder;
-
-public class MeasureVariationsTest {
-  public static final String NO_VARIATION_ERROR_MESSAGE = "There must be at least one variation";
-  public static final String NAN_ERROR_MESSAGE = "NaN is not allowed in MeasureVariation";
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  @Test
-  public void constructor_throws_IAE_if_array_arg_has_more_than_5_elements() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("There can not be more than 5 variations");
-
-    new MeasureVariations(1d, 2d, 3d, 4d, 5d, 6d);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_no_arg() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NO_VARIATION_ERROR_MESSAGE);
-
-    new MeasureVariations();
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_single_arg_is_null() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NO_VARIATION_ERROR_MESSAGE);
-
-    new MeasureVariations((Double) null);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_two_args_are_null() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NO_VARIATION_ERROR_MESSAGE);
-
-    new MeasureVariations((Double) null, (Double) null);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_three_args_are_null() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NO_VARIATION_ERROR_MESSAGE);
-
-    new MeasureVariations((Double) null, (Double) null, (Double) null);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_four_args_are_null() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NO_VARIATION_ERROR_MESSAGE);
-
-    new MeasureVariations((Double) null, (Double) null, (Double) null, (Double) null);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_five_args_are_null() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NO_VARIATION_ERROR_MESSAGE);
-
-    new MeasureVariations((Double) null, (Double) null, (Double) null, (Double) null, (Double) null);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_any_arg_1_is_NaN() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NAN_ERROR_MESSAGE);
-
-    new MeasureVariations(Double.NaN);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_any_arg_2_is_NaN() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NAN_ERROR_MESSAGE);
-
-    new MeasureVariations(1d, Double.NaN);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_any_arg_3_is_NaN() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NAN_ERROR_MESSAGE);
-
-    new MeasureVariations(1d, 2d, Double.NaN);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_any_arg_4_is_NaN() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NAN_ERROR_MESSAGE);
-
-    new MeasureVariations(1d, 2d, 3d, Double.NaN);
-  }
-
-  @Test
-  public void constructor_throws_IAE_if_any_arg_5_is_NaN() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage(NAN_ERROR_MESSAGE);
-
-    new MeasureVariations(1d, 2d, 3d, 5d, Double.NaN);
-  }
-
-  @Test
-  public void verify_has_variationX_and_getVariationX() {
-    verifyAsVariations(new MeasureVariations(1d), 1d, null, null, null, null);
-
-    verifyAsVariations(new MeasureVariations(1d, 2d), 1d, 2d, null, null, null);
-    verifyAsVariations(new MeasureVariations(null, 2d), null, 2d, null, null, null);
-    verifyAsVariations(new MeasureVariations(1d, null), 1d, null, null, null, null);
-
-    verifyAsVariations(new MeasureVariations(1d, 2d, 3d), 1d, 2d, 3d, null, null);
-    verifyAsVariations(new MeasureVariations(null, 2d, 3d), null, 2d, 3d, null, null);
-    verifyAsVariations(new MeasureVariations(1d, null, 3d), 1d, null, 3d, null, null);
-    verifyAsVariations(new MeasureVariations(null, null, 3d), null, null, 3d, null, null);
-    verifyAsVariations(new MeasureVariations(1d, 2d, null), 1d, 2d, null, null, null);
-
-    verifyAsVariations(new MeasureVariations(1d, 2d, 3d, 4d), 1d, 2d, 3d, 4d, null);
-    verifyAsVariations(new MeasureVariations(null, 2d, 3d, 4d), null, 2d, 3d, 4d, null);
-    verifyAsVariations(new MeasureVariations(null, 2d, null, 4d), null, 2d, null, 4d, null);
-    verifyAsVariations(new MeasureVariations(null, null, 3d, 4d), null, null, 3d, 4d, null);
-    verifyAsVariations(new MeasureVariations(null, null, null, 4d), null, null, null, 4d, null);
-    verifyAsVariations(new MeasureVariations(1d, null, 3d, 4d), 1d, null, 3d, 4d, null);
-    verifyAsVariations(new MeasureVariations(1d, 2d, null, 4d), 1d, 2d, null, 4d, null);
-    verifyAsVariations(new MeasureVariations(1d, 2d, 3d, null), 1d, 2d, 3d, null, null);
-
-    verifyAsVariations(new MeasureVariations(1d, 2d, 3d, 4d, 5d), 1d, 2d, 3d, 4d, 5d);
-    verifyAsVariations(new MeasureVariations(null, 2d, 3d, 4d, 5d), null, 2d, 3d, 4d, 5d);
-    verifyAsVariations(new MeasureVariations(1d, null, 3d, 4d, 5d), 1d, null, 3d, 4d, 5d);
-    verifyAsVariations(new MeasureVariations(1d, 2d, null, 4d, 5d), 1d, 2d, null, 4d, 5d);
-    verifyAsVariations(new MeasureVariations(1d, 2d, 3d, null, 5d), 1d, 2d, 3d, null, 5d);
-    verifyAsVariations(new MeasureVariations(1d, 2d, 3d, 4d, null), 1d, 2d, 3d, 4d, null);
-  }
-
-  private static void verifyAsVariations(MeasureVariations measureVariations,
-    @Nullable Double variation1, @Nullable Double variation2, @Nullable Double variation3, @Nullable Double variation4, @Nullable Double variation5) {
-    assertThat(measureVariations.hasVariation1()).isEqualTo(variation1 != null);
-    try {
-      if (variation1 == null) {
-        measureVariations.getVariation1();
-        fail("An exception should have been raised");
-      }
-      assertThat(measureVariations.getVariation1()).isEqualTo(variation1);
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Variation 1 has not been set");
-    }
-    assertThat(measureVariations.hasVariation2()).isEqualTo(variation2 != null);
-    try {
-      if (variation2 == null) {
-        measureVariations.getVariation2();
-        fail("An exception should have been raised");
-      }
-      assertThat(measureVariations.getVariation2()).isEqualTo(variation2);
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Variation 2 has not been set");
-    }
-    assertThat(measureVariations.hasVariation3()).isEqualTo(variation3 != null);
-    try {
-      if (variation3 == null) {
-        measureVariations.getVariation3();
-        fail("An exception should have been raised");
-      }
-      assertThat(measureVariations.getVariation3()).isEqualTo(variation3);
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Variation 3 has not been set");
-    }
-    assertThat(measureVariations.hasVariation4()).isEqualTo(variation4 != null);
-    try {
-      if (variation4 == null) {
-        measureVariations.getVariation4();
-        fail("An exception should have been raised");
-      }
-      assertThat(measureVariations.getVariation4()).isEqualTo(variation4);
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Variation 4 has not been set");
-    }
-    assertThat(measureVariations.hasVariation5()).isEqualTo(variation5 != null);
-    try {
-      if (variation5 == null) {
-        measureVariations.getVariation5();
-        fail("An exception should have been raised");
-      }
-      assertThat(measureVariations.getVariation5()).isEqualTo(variation5);
-    } catch (IllegalStateException e) {
-      assertThat(e.getMessage()).isEqualTo("Variation 5 has not been set");
-    }
-  }
-
-  @Test
-  public void verify_toString() {
-    assertThat(new MeasureVariations(1d).toString()).isEqualTo("MeasureVariations{1=1.0, 2=null, 3=null, 4=null, 5=null}");
-    assertThat(new MeasureVariations(1d, 2d, 3d, 4d, 5d).toString()).isEqualTo("MeasureVariations{1=1.0, 2=2.0, 3=3.0, 4=4.0, 5=5.0}");
-  }
-
-  @Test
-  public void equals_takes_values_into_account() {
-    MeasureVariations variations = new MeasureVariations(1d);
-
-    assertThat(variations).isEqualTo(variations);
-    assertThat(variations).isEqualTo(new MeasureVariations(1d));
-    assertThat(new MeasureVariations(null, 1d)).isEqualTo(new MeasureVariations(null, 1d));
-
-    assertThat(new MeasureVariations(null, 2d)).isNotEqualTo(new MeasureVariations(null, 1d));
-  }
-
-  @Test
-  public void verify_MeasureVariations_built_by_builder_from_Period() {
-    MeasureVariations.Builder builder = newMeasureVariationsBuilder();
-    for (int i = 1; i <= PeriodsHolder.MAX_NUMBER_OF_PERIODS; i++) {
-      builder.setVariation(createPeriod(i), i);
-    }
-    MeasureVariations variations = builder.build();
-
-    verifyAsVariations(variations, 1d, 2d, 3d, 4d, 5d);
-  }
-
-  @Test
-  public void builder_isEmpty_returns_true_if_builder_has_not_been_used() {
-    assertThat(newMeasureVariationsBuilder().isEmpty()).isTrue();
-  }
-
-  @Test
-  public void builder_isEmpty_returns_false_if_any_variation_has_been_set() {
-    for (int i = 1; i <= PeriodsHolder.MAX_NUMBER_OF_PERIODS; i++) {
-      assertThat(newMeasureVariationsBuilder().setVariation(createPeriod(i), i).isEmpty()).isFalse();
-    }
-  }
-
-  @Test
-  public void builder_setVariation_for_Period_throws_IAE_if_value_is_NaN() {
-    for (int i = 1; i <= PeriodsHolder.MAX_NUMBER_OF_PERIODS; i++) {
-      try {
-        newMeasureVariationsBuilder().setVariation(createPeriod(i), Double.NaN);
-        fail("An IAE should have been raised");
-      } catch (IllegalArgumentException e) {
-        assertThat(e).hasMessage(NAN_ERROR_MESSAGE);
-      }
-    }
-  }
-
-  private static Period createPeriod(int i) {
-    return new Period(i, "mode " + i, null, 100L + i, String.valueOf(952L + i));
-  }
-}
index a17e3d3f76da74232e8da12f311f2fb862455530..9f55e3a3707dec53ab5f6ee67f3abbda3b971b82 100644 (file)
@@ -59,7 +59,6 @@ import static org.sonar.server.computation.task.projectanalysis.component.Compon
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.SUBVIEW;
 import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.VIEW;
 import static org.sonar.server.computation.task.projectanalysis.measure.Measure.newMeasureBuilder;
-import static org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations.newMeasureVariationsBuilder;
 
 public class PersistMeasuresStepTest extends BaseStepTest {
 
@@ -259,10 +258,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
 
     measureRepository.addRawMeasure(ROOT_REF, DOUBLE_METRIC_KEY,
       newMeasureBuilder()
-        .setVariations(
-          newMeasureVariationsBuilder()
-            .setVariation(createPeriod(), 1.1d)
-            .build())
+        .setVariation(1.1d)
         .create(10d, 1));
 
     underTest.execute();
index 5fa218095406ad1df752f82c54298819574f7c1f..0a872de2076c7f0456d92e1f1d431a4466b9510d 100644 (file)
@@ -42,7 +42,6 @@ import org.sonar.server.computation.task.projectanalysis.measure.qualitygatedeta
 import org.sonar.server.computation.task.projectanalysis.metric.Metric;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricImpl;
 import org.sonar.server.computation.task.projectanalysis.metric.MetricRepositoryRule;
-import org.sonar.server.computation.task.projectanalysis.period.Period;
 import org.sonar.server.computation.task.projectanalysis.qualitygate.Condition;
 import org.sonar.server.computation.task.projectanalysis.qualitygate.ConditionStatus;
 import org.sonar.server.computation.task.projectanalysis.qualitygate.EvaluationResult;
@@ -63,7 +62,6 @@ import static org.sonar.server.computation.task.projectanalysis.measure.Measure.
 import static org.sonar.server.computation.task.projectanalysis.measure.Measure.Level.OK;
 import static org.sonar.server.computation.task.projectanalysis.measure.Measure.Level.WARN;
 import static org.sonar.server.computation.task.projectanalysis.measure.MeasureAssert.assertThat;
-import static org.sonar.server.computation.task.projectanalysis.measure.MeasureVariations.newMeasureVariationsBuilder;
 
 public class QualityGateMeasuresStepTest {
   private static final MetricImpl INT_METRIC_1 = createIntMetric(1);
@@ -301,7 +299,7 @@ public class QualityGateMeasuresStepTest {
 
     qualityGateHolder.setQualityGate(new QualityGate(SOME_QG_ID, SOME_QG_NAME, of(fixedCondition, periodCondition)));
     Measure measure = newMeasureBuilder()
-      .setVariations(newMeasureVariationsBuilder().setVariation(new Period(1, "mode", null, 1212, "u1"), rawValue).build())
+      .setVariation(rawValue)
       .create(rawValue, null);
     measureRepository.addRawMeasure(PROJECT_REF, INT_METRIC_1_KEY, measure);