]> source.dussan.org Git - sonarqube.git/commitdiff
Clean old remains of dev cockpit
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 25 Apr 2019 12:04:53 +0000 (14:04 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 25 Apr 2019 18:21:05 +0000 (20:21 +0200)
17 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DbIdsRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DbIdsRepositoryImpl.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/Developer.java [deleted file]
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/MapBasedDbIdsRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/MutableDbIdsRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepository.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/Measure.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/measure/MeasureKey.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DbIdsRepositoryImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DumbDeveloper.java [deleted file]
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MutableDbIdsRepositoryRule.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureKeyTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepoEntry.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryRule.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureTest.java

index 8daecf4a4563917dad336119e0cc89f3cc5bd240..04604bbd745f2e3bbd302d096d8dae394ca7d290 100644 (file)
@@ -24,9 +24,4 @@ public interface DbIdsRepository {
    * @throws IllegalStateException if there is no id for the specified Component
    */
   long getComponentId(Component component);
-
-  /**
-   * @throws IllegalStateException if there is no id for the specified Developer
-   */
-  long getDeveloperId(Developer developer);
 }
index f614ff028497e8e667d02520f416a11e90192efc..ac00e8f5eb11a3db2191e185d2b58cccaae2fb7b 100644 (file)
@@ -38,13 +38,4 @@ public class DbIdsRepositoryImpl implements MutableDbIdsRepository {
     return delegate.getComponentId(component);
   }
 
-  @Override
-  public DbIdsRepository setDeveloperId(Developer developer, long developerId) {
-    return delegate.setDeveloperId(developer, developerId);
-  }
-
-  @Override
-  public long getDeveloperId(Developer developer) {
-    return delegate.getDeveloperId(developer);
-  }
 }
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/Developer.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/Developer.java
deleted file mode 100644 (file)
index 5f5dce0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info 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.ce.task.projectanalysis.component;
-
-/**
- * Developers are created by the Developer Cockpit plugin
- */
-public interface Developer {
-
-}
index f78194c44376f0f4543340360ab91e1ba9b52e71..3b72d08846e92bae25862c5776f208253be6d64a 100644 (file)
@@ -35,7 +35,6 @@ public final class MapBasedDbIdsRepository<T> implements MutableDbIdsRepository
 
   private final Function<Component, T> componentToKey;
   private final Map<T, Long> componentIdsByRef = new HashMap<>();
-  private final Map<Developer, Long> developerIdsByKey = new HashMap<>();
 
   public MapBasedDbIdsRepository(Function<Component, T> componentToKey) {
     this.componentToKey = componentToKey;
@@ -59,18 +58,4 @@ public final class MapBasedDbIdsRepository<T> implements MutableDbIdsRepository
     return componentId;
   }
 
-  @Override
-  public DbIdsRepository setDeveloperId(Developer developer, long developerId) {
-    Long existingId = developerIdsByKey.get(developer);
-    checkState(existingId == null, "Id '%s' is already registered in repository for Developer '%s', can not set new id '%s'", existingId, developer, developerId);
-    developerIdsByKey.put(developer, developerId);
-    return this;
-  }
-
-  @Override
-  public long getDeveloperId(Developer developer) {
-    Long devId = developerIdsByKey.get(developer);
-    checkState(devId != null, "No id registered in repository for Developer '%s'", developer);
-    return devId;
-  }
 }
index 6e186d96bd6a8e08d5a925182dddc081fcd17b43..b446a23e8bdab0d16c2ad7144ecf432d80950a37 100644 (file)
@@ -24,9 +24,4 @@ public interface MutableDbIdsRepository extends DbIdsRepository {
    * @throws IllegalStateException if the component id for the specified component has already been set
    */
   DbIdsRepository setComponentId(Component component, long componentId);
-
-  /**
-   * @throws IllegalStateException if the id for the specified developer has already been set
-   */
-  DbIdsRepository setDeveloperId(Developer developer, long developerId);
 }
index 3bfeaf6adb856a6468b2e1a0b059c498cafcfa6d..ee8b6207b656ae93ad85fd121ba655f62fc617c0 100644 (file)
@@ -72,7 +72,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
     requireNonNull(component);
     checkValueTypeConsistency(metric, measure);
 
-    Optional<Measure> existingMeasure = find(component, metric, measure);
+    Optional<Measure> existingMeasure = find(component, metric);
     if (existingMeasure.isPresent()) {
       throw new UnsupportedOperationException(
         format(
@@ -88,7 +88,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
     requireNonNull(component);
     checkValueTypeConsistency(metric, measure);
 
-    Optional<Measure> existingMeasure = find(component, metric, measure);
+    Optional<Measure> existingMeasure = find(component, metric);
     if (!existingMeasure.isPresent()) {
       throw new UnsupportedOperationException(
         format(
@@ -142,16 +142,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
     if (measuresPerMetric == null) {
       return Optional.empty();
     }
-    return Optional.ofNullable(measuresPerMetric.get(new MeasureKey(metric.getKey(), null)));
-  }
-
-  private Optional<Measure> find(Component component, Metric metric, Measure measure) {
-    T componentKey = componentToKey.apply(component);
-    Map<MeasureKey, Measure> measuresPerMetric = measures.get(componentKey);
-    if (measuresPerMetric == null) {
-      return Optional.empty();
-    }
-    return Optional.ofNullable(measuresPerMetric.get(new MeasureKey(metric.getKey(), measure.getDeveloper())));
+    return Optional.ofNullable(measuresPerMetric.get(new MeasureKey(metric.getKey())));
   }
 
   public void add(Component component, Metric metric, Measure measure, OverridePolicy overridePolicy) {
@@ -162,7 +153,7 @@ public final class MapBasedRawMeasureRepository<T> implements MeasureRepository
 
     T componentKey = componentToKey.apply(component);
     Map<MeasureKey, Measure> measuresPerMetric = measures.computeIfAbsent(componentKey, key -> new HashMap<>());
-    MeasureKey key = new MeasureKey(metric.getKey(), measure.getDeveloper());
+    MeasureKey key = new MeasureKey(metric.getKey());
     if (!measuresPerMetric.containsKey(key) || overridePolicy == OverridePolicy.OVERRIDE) {
       measuresPerMetric.put(key, measure);
     }
index 327c1eb00f2cd5fab180183765bf1647b869a5da..bbefe1b6f6beaa5a70418e01d00a9375a900ae5e 100644 (file)
@@ -22,11 +22,9 @@ package org.sonar.ce.task.projectanalysis.measure;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Locale;
-import java.util.Objects;
 import java.util.Optional;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-import org.sonar.ce.task.projectanalysis.component.Developer;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
@@ -73,8 +71,6 @@ public final class Measure {
 
   private final ValueType valueType;
   @CheckForNull
-  private final Developer developer;
-  @CheckForNull
   private final Double value;
   @CheckForNull
   private final String data;
@@ -85,11 +81,10 @@ public final class Measure {
   @CheckForNull
   private final Double variation;
 
-  private Measure(ValueType valueType, @Nullable Developer developer,
+  private Measure(ValueType valueType,
     @Nullable Double value, @Nullable String data, @Nullable Level dataLevel,
     @Nullable QualityGateStatus qualityGateStatus, @Nullable Double variation) {
     this.valueType = valueType;
-    this.developer = developer;
     this.value = value;
     this.data = data;
     this.dataLevel = dataLevel;
@@ -106,19 +101,9 @@ public final class Measure {
   }
 
   public static final class NewMeasureBuilder {
-    private Developer developer;
     private QualityGateStatus qualityGateStatus;
     private Double variation;
 
-    /**
-     * Sets the developer this measure is associated to.
-     *
-     */
-    public NewMeasureBuilder forDeveloper(Developer developer) {
-      this.developer = developer;
-      return this;
-    }
-
     public NewMeasureBuilder setQualityGateStatus(QualityGateStatus qualityGateStatus) {
       this.qualityGateStatus = requireNonNull(qualityGateStatus, "QualityGateStatus can not be set to null");
       return this;
@@ -130,7 +115,7 @@ public final class Measure {
     }
 
     public Measure create(boolean value, @Nullable String data) {
-      return new Measure(ValueType.BOOLEAN, developer, value ? 1.0D : 0.0D, data, null, qualityGateStatus, variation);
+      return new Measure(ValueType.BOOLEAN, value ? 1.0D : 0.0D, data, null, qualityGateStatus, variation);
     }
 
     public Measure create(boolean value) {
@@ -138,7 +123,7 @@ public final class Measure {
     }
 
     public Measure create(int value, @Nullable String data) {
-      return new Measure(ValueType.INT, developer, (double) value, data, null, qualityGateStatus, variation);
+      return new Measure(ValueType.INT, (double) value, data, null, qualityGateStatus, variation);
     }
 
     public Measure create(int value) {
@@ -146,7 +131,7 @@ public final class Measure {
     }
 
     public Measure create(long value, @Nullable String data) {
-      return new Measure(ValueType.LONG, developer, (double) value, data, null, qualityGateStatus, variation);
+      return new Measure(ValueType.LONG, (double) value, data, null, qualityGateStatus, variation);
     }
 
     public Measure create(long value) {
@@ -156,7 +141,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, qualityGateStatus, variation);
+      return new Measure(ValueType.DOUBLE, scaledValue, data, null, qualityGateStatus, variation);
     }
 
     public Measure create(double value, int decimalScale) {
@@ -164,15 +149,15 @@ public final class Measure {
     }
 
     public Measure create(String value) {
-      return new Measure(ValueType.STRING, developer, null, requireNonNull(value), null, qualityGateStatus, variation);
+      return new Measure(ValueType.STRING, null, requireNonNull(value), null, qualityGateStatus, variation);
     }
 
     public Measure create(Level level) {
-      return new Measure(ValueType.LEVEL, developer, null, null, requireNonNull(level), qualityGateStatus, variation);
+      return new Measure(ValueType.LEVEL, null, null, requireNonNull(level), qualityGateStatus, variation);
     }
 
     public Measure createNoValue() {
-      return new Measure(ValueType.NO_VALUE, developer, null, null, null, qualityGateStatus, variation);
+      return new Measure(ValueType.NO_VALUE, null, null, null, qualityGateStatus, variation);
     }
 
     private static double scale(double value, int decimalScale) {
@@ -218,18 +203,13 @@ public final class Measure {
     }
 
     public Measure create() {
-      return new Measure(source.valueType, source.developer,
+      return new Measure(source.valueType,
         source.value, source.data, source.dataLevel,
         source.qualityGateStatus == null ? qualityGateStatus : source.qualityGateStatus,
         source.variation == null ? variation : source.variation);
     }
   }
 
-  @CheckForNull
-  public Developer getDeveloper() {
-    return developer;
-  }
-
   /**
    * The type of value stored in the measure.
    */
@@ -352,32 +332,10 @@ public final class Measure {
     return variation;
   }
 
-  /**
-   * a Metric is equal to another Metric if it has the same ruleId/characteristicId paar (both being potentially
-   * {@code null} but only one of them can be non {@code null}).
-   */
-  @Override
-  public boolean equals(@Nullable Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-    Measure measure = (Measure) o;
-    return Objects.equals(developer, measure.developer);
-  }
-
-  @Override
-  public int hashCode() {
-    return Objects.hash(developer);
-  }
-
   @Override
   public String toString() {
     return com.google.common.base.MoreObjects.toStringHelper(this)
       .add("valueType", valueType)
-      .add("developer", developer)
       .add("value", value)
       .add("data", data)
       .add("dataLevel", dataLevel)
index 373bbcda9774ce03e2209483d8514ae22c102d49..e283f1b2bc01dabeb028abf958488016b9d3465d 100644 (file)
 package org.sonar.ce.task.projectanalysis.measure;
 
 import java.util.Objects;
-import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
-import org.sonar.ce.task.projectanalysis.component.Developer;
-import org.sonar.ce.task.projectanalysis.component.Developer;
 
 import static java.util.Objects.requireNonNull;
 
@@ -32,23 +29,15 @@ import static java.util.Objects.requireNonNull;
 public final class MeasureKey {
 
   private final String metricKey;
-  @CheckForNull
-  private final Developer developer;
 
-  public MeasureKey(String metricKey, @Nullable Developer developer) {
+  public MeasureKey(String metricKey) {
     this.metricKey = requireNonNull(metricKey, "MetricKey can not be null");
-    this.developer = developer;
   }
 
   public String getMetricKey() {
     return metricKey;
   }
 
-  @CheckForNull
-  public Developer getDeveloper() {
-    return developer;
-  }
-
   @Override
   public boolean equals(@Nullable Object o) {
     if (this == o) {
@@ -58,8 +47,7 @@ public final class MeasureKey {
       return false;
     }
     MeasureKey that = (MeasureKey) o;
-    return metricKey.equals(that.metricKey)
-      && developer == that.developer;
+    return metricKey.equals(that.metricKey);
   }
 
   @Override
@@ -71,7 +59,6 @@ public final class MeasureKey {
   public String toString() {
     return "MeasureKey{" +
       "metricKey='" + metricKey + '\'' +
-      ", developer=" + developer +
       '}';
   }
 }
index 5e88d86f23430030699ce8639fa7574e6524d33f..103b5bd9048c388d3354a08bd4220ce6b968adf9 100644 (file)
@@ -33,7 +33,6 @@ public class DbIdsRepositoryImplTest {
 
   private static final String SOME_COMPONENT_KEY = "SOME_COMPONENT_KEY";
   private static final Component SOME_COMPONENT = ReportComponent.builder(PROJECT, 1).setKey(SOME_COMPONENT_KEY).build();
-  private static final Developer SOME_DEVELOPER = new DumbDeveloper("DEV1");
 
   @Test
   public void add_and_get_component_id() {
@@ -61,30 +60,4 @@ public class DbIdsRepositoryImplTest {
     cache.setComponentId(SOME_COMPONENT, 11L);
   }
 
-  @Test
-  public void add_and_get_developer_id() {
-    DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl();
-    cache.setDeveloperId(SOME_DEVELOPER, 100L);
-
-    assertThat(cache.getDeveloperId(SOME_DEVELOPER)).isEqualTo(100L);
-  }
-
-  @Test
-  public void fail_to_get_developer_id_on_unknown_developer() {
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("No id registered in repository for Developer '" + SOME_DEVELOPER + "'");
-
-    new DbIdsRepositoryImpl().getDeveloperId(SOME_DEVELOPER);
-  }
-
-  @Test
-  public void fail_if_developer_id_already_set() {
-    DbIdsRepositoryImpl cache = new DbIdsRepositoryImpl();
-    cache.setDeveloperId(SOME_DEVELOPER, 10L);
-
-    thrown.expect(IllegalStateException.class);
-    thrown.expectMessage("Id '10' is already registered in repository for Developer '" + SOME_DEVELOPER + "', can not set new id '11'");
-    cache.setDeveloperId(SOME_DEVELOPER, 11L);
-  }
-
 }
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DumbDeveloper.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DumbDeveloper.java
deleted file mode 100644 (file)
index a770165..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info 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.ce.task.projectanalysis.component;
-
-/**
- * Implementation od {@link Developer} only used for test
- */
-public class DumbDeveloper implements Developer {
-
-  private final String key;
-
-  public DumbDeveloper(String key) {
-    this.key = key;
-  }
-
-  public String getKey() {
-    return key;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-
-    DumbDeveloper that = (DumbDeveloper) o;
-
-    return key.equals(that.key);
-
-  }
-
-  @Override
-  public int hashCode() {
-    return key.hashCode();
-  }
-
-  @Override
-  public String toString() {
-    return "Developer{" +
-      "key='" + key + '\'' +
-      '}';
-  }
-}
index 967118c869bbadd63b40942fdf63027e5e6a29e1..91a2ef9e12cc960e3247d3a103dd5d594358849e 100644 (file)
@@ -72,16 +72,6 @@ public class MutableDbIdsRepositoryRule extends ExternalResource implements Muta
     return delegate.setComponentId(component, componentId);
   }
 
-  @Override
-  public DbIdsRepository setDeveloperId(Developer developer, long developerId) {
-    return delegate.setDeveloperId(developer, developerId);
-  }
-
-  @Override
-  public long getDeveloperId(Developer developer) {
-    return delegate.getDeveloperId(developer);
-  }
-
   @Override
   public long getComponentId(Component component) {
     return delegate.getComponentId(component);
index 202d748581c3b2af1bdd95b9227317c0004d5f40..3a069e648236d763e60a8033f626a7b865c2cafb 100644 (file)
@@ -25,7 +25,6 @@ import com.tngtech.java.junit.dataprovider.DataProviderRunner;
 import com.tngtech.java.junit.dataprovider.UseDataProvider;
 import java.util.List;
 import java.util.Optional;
-import java.util.Set;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -35,8 +34,6 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.api.utils.System2;
 import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.ce.task.projectanalysis.component.Component;
-import org.sonar.ce.task.projectanalysis.component.Developer;
-import org.sonar.ce.task.projectanalysis.component.DumbDeveloper;
 import org.sonar.ce.task.projectanalysis.component.ReportComponent;
 import org.sonar.ce.task.projectanalysis.metric.Metric;
 import org.sonar.ce.task.projectanalysis.metric.MetricImpl;
@@ -78,7 +75,6 @@ public class MapBasedRawMeasureRepositoryTest {
   private static final Measure SOME_MEASURE = Measure.newMeasureBuilder().create("some value");
 
   private static final RuleDto SOME_RULE = RuleDto.createFor(RuleKey.of("A", "1")).setId(963);
-  private static final Developer SOME_DEVELOPER = new DumbDeveloper("DEV1");
 
   private ReportMetricValidator reportMetricValidator = mock(ReportMetricValidator.class);
 
@@ -149,8 +145,7 @@ public class MapBasedRawMeasureRepositoryTest {
     Measure.newMeasureBuilder().create(false),
     Measure.newMeasureBuilder().create("sds"),
     Measure.newMeasureBuilder().create(Measure.Level.OK),
-    Measure.newMeasureBuilder().createNoValue()
-  );
+    Measure.newMeasureBuilder().createNoValue());
 
   @DataProvider
   public static Object[][] measures() {
@@ -267,15 +262,4 @@ public class MapBasedRawMeasureRepositoryTest {
     assertThat(underTest.getRawMeasures(FILE_COMPONENT, metric1)).isEmpty();
   }
 
-  @Test
-  public void getRawMeasures_for_metric_returns_developer_measure() {
-    Measure devMeasure = Measure.newMeasureBuilder().forDeveloper(SOME_DEVELOPER).createNoValue();
-
-    underTest.add(FILE_COMPONENT, metric1, devMeasure);
-
-    Set<Measure> measures = underTest.getRawMeasures(FILE_COMPONENT, metric1);
-    assertThat(measures).hasSize(1);
-    assertThat(measures.iterator().next()).isSameAs(devMeasure);
-  }
-
 }
index 25454e91c079adc6c02e9bbfba0424c54235c23c..6c420591210d8cf29613f62fbb64479a5b62eded 100644 (file)
@@ -22,8 +22,6 @@ package org.sonar.ce.task.projectanalysis.measure;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
-import org.sonar.ce.task.projectanalysis.component.Developer;
-import org.sonar.ce.task.projectanalysis.component.DumbDeveloper;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -32,42 +30,34 @@ public class MeasureKeyTest {
   @Rule
   public ExpectedException thrown = ExpectedException.none();
 
-  static final Developer DEVELOPER = new DumbDeveloper("DEV1");
-
   @Test
   public void fail_with_NPE_when_metric_key_is_null() {
     thrown.expect(NullPointerException.class);
 
-    new MeasureKey(null, DEVELOPER);
+    new MeasureKey(null);
   }
 
   @Test
   public void test_equals_and_hashcode() {
-    MeasureKey measureKey = new MeasureKey("metricKey", null);
-    MeasureKey measureKey2 = new MeasureKey("metricKey", null);
-    MeasureKey anotherMeasureKey = new MeasureKey("anotherMetricKey", null);
-
-    MeasureKey developerMeasureKey = new MeasureKey("metricKey", DEVELOPER);
-    MeasureKey developerMeasureKey2 = new MeasureKey("metricKey", DEVELOPER);
+    MeasureKey measureKey = new MeasureKey("metricKey");
+    MeasureKey measureKey2 = new MeasureKey("metricKey");
+    MeasureKey anotherMeasureKey = new MeasureKey("anotherMetricKey");
 
     assertThat(measureKey).isEqualTo(measureKey);
     assertThat(measureKey).isEqualTo(measureKey2);
     assertThat(measureKey).isNotEqualTo(null);
     assertThat(measureKey).isNotEqualTo(anotherMeasureKey);
 
-    assertThat(developerMeasureKey).isEqualTo(developerMeasureKey2);
 
     assertThat(measureKey.hashCode()).isEqualTo(measureKey.hashCode());
     assertThat(measureKey.hashCode()).isEqualTo(measureKey2.hashCode());
     assertThat(measureKey.hashCode()).isNotEqualTo(anotherMeasureKey.hashCode());
-
-    assertThat(developerMeasureKey.hashCode()).isEqualTo(developerMeasureKey2.hashCode());
   }
 
   @Test
   public void to_string() {
-    assertThat(new MeasureKey("metricKey", DEVELOPER).toString()).isEqualTo(
-      "MeasureKey{metricKey='metricKey', developer=Developer{key='DEV1'}}");
-    assertThat(new MeasureKey("metricKey", null).toString()).isEqualTo("MeasureKey{metricKey='metricKey', developer=null}");
+    assertThat(new MeasureKey("metricKey").toString()).isEqualTo(
+      "MeasureKey{metricKey='metricKey'}");
+    assertThat(new MeasureKey("metricKey").toString()).isEqualTo("MeasureKey{metricKey='metricKey'}");
   }
 }
index ce5c542e2d0491c92496044f8196a8de527210f8..2cf7fc130c6f8f11ea4e80209c9f0c7b122ce2ec 100644 (file)
@@ -72,8 +72,7 @@ public final class MeasureRepoEntry {
   }
 
   public static boolean deepEquals(Measure measure, Measure measure1) {
-    return Objects.equals(measure, measure1)
-      && measure.getValueType() == measure1.getValueType()
+    return measure.getValueType() == measure1.getValueType()
       && equalsByValue(measure, measure1)
       && equalsByVariation(measure, measure1)
       && equalsByQualityGateStatus(measure, measure1)
index 85f473d0c23c4e5628dc79c87b28101d63e4683c..e151f2e8a0f46a6a450c396394a9ac71410949a0 100644 (file)
@@ -411,7 +411,7 @@ public class MeasureRepositoryImplTest {
 
     assertThat(rawMeasures.keySet()).hasSize(2);
     assertThat(rawMeasures.get(METRIC_KEY_1)).containsOnly(addedMeasure);
-    assertThat(rawMeasures.get(METRIC_KEY_2)).containsOnly(Measure.newMeasureBuilder().create("some value"));
+    assertThat(rawMeasures.get(METRIC_KEY_2)).extracting(Measure::getStringValue).containsOnly("some value");
   }
 
   private static MeasureDto createMeasureDto(int metricId, String componentUuid, String analysisUuid) {
index f4546184277527aa6c9dd63e9a16bdc5a79eebda..d83245d86acc825585b3bb0e6a7b47b2a80312cc 100644 (file)
@@ -35,8 +35,6 @@ import javax.annotation.Nullable;
 import org.junit.rules.ExternalResource;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.ComponentProvider;
-import org.sonar.ce.task.projectanalysis.component.Developer;
-import org.sonar.ce.task.projectanalysis.component.DumbDeveloper;
 import org.sonar.ce.task.projectanalysis.component.NoComponentProvider;
 import org.sonar.ce.task.projectanalysis.component.TreeComponentProvider;
 import org.sonar.ce.task.projectanalysis.component.TreeRootHolder;
@@ -174,7 +172,7 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
   public MeasureRepositoryRule addRawMeasure(int componentRef, String metricKey, Measure measure) {
     checkAndInitProvidersState();
 
-    InternalKey internalKey = new InternalKey(componentProvider.getByRef(componentRef), metricRepositoryRule.getByKey(metricKey), measure.getDeveloper());
+    InternalKey internalKey = new InternalKey(componentProvider.getByRef(componentRef), metricRepositoryRule.getByKey(metricKey));
     checkState(!rawMeasures.containsKey(internalKey), format(
       "A measure can only be set once for Component (ref=%s), Metric (key=%s)",
       componentRef, metricKey));
@@ -203,12 +201,8 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
     return Optional.ofNullable(rawMeasures.get(new InternalKey(component, metric)));
   }
 
-  public Optional<Measure> getRawMeasure(Component component, Metric metric, DumbDeveloper developer) {
-    return Optional.ofNullable(rawMeasures.get(new InternalKey(component, metric, developer)));
-  }
-
   public Optional<Measure> getRawRuleMeasure(Component component, Metric metric, int ruleId) {
-    return Optional.ofNullable(rawMeasures.get(new InternalKey(component, metric, null)));
+    return Optional.ofNullable(rawMeasures.get(new InternalKey(component, metric)));
   }
 
   @Override
@@ -232,7 +226,7 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
   @Override
   public void add(Component component, Metric metric, Measure measure) {
     String ref = getRef(component);
-    InternalKey internalKey = new InternalKey(ref, metric.getKey(), measure.getDeveloper());
+    InternalKey internalKey = new InternalKey(ref, metric.getKey());
     if (rawMeasures.containsKey(internalKey)) {
       throw new UnsupportedOperationException(format(
         "A measure can only be set once for Component (ref=%s), Metric (key=%s)",
@@ -244,7 +238,7 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
   @Override
   public void update(Component component, Metric metric, Measure measure) {
     String componentRef = getRef(component);
-    InternalKey internalKey = new InternalKey(componentRef, metric.getKey(), measure.getDeveloper());
+    InternalKey internalKey = new InternalKey(componentRef, metric.getKey());
     if (!rawMeasures.containsKey(internalKey)) {
       throw new UnsupportedOperationException(format(
         "A measure can only be updated if it has been added first for Component (ref=%s), Metric (key=%s)",
@@ -265,21 +259,14 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
   private static final class InternalKey {
     private final String componentRef;
     private final String metricKey;
-    @Nullable
-    private final Developer developer;
 
     public InternalKey(Component component, Metric metric) {
-      this(getRef(component), metric.getKey(), null);
-    }
-
-    public InternalKey(Component component, Metric metric, @Nullable Developer developer) {
-      this(getRef(component), metric.getKey(), developer);
+      this(getRef(component), metric.getKey());
     }
 
-    private InternalKey(String componentRef, String metricKey, @Nullable Developer developer) {
+    private InternalKey(String componentRef, String metricKey) {
       this.componentRef = componentRef;
       this.metricKey = metricKey;
-      this.developer = developer;
     }
 
     public String getComponentRef() {
@@ -300,13 +287,12 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
       }
       InternalKey that = (InternalKey) o;
       return Objects.equals(componentRef, that.componentRef) &&
-        Objects.equals(metricKey, that.metricKey) &&
-        Objects.equals(developer, that.developer);
+        Objects.equals(metricKey, that.metricKey);
     }
 
     @Override
     public int hashCode() {
-      return Objects.hash(componentRef, metricKey, developer);
+      return Objects.hash(componentRef, metricKey);
     }
 
     @Override
@@ -314,7 +300,6 @@ public class MeasureRepositoryRule extends ExternalResource implements MeasureRe
       return "InternalKey{" +
         "component=" + componentRef +
         ", metric='" + metricKey + '\'' +
-        ", developer=" + developer +
         '}';
     }
   }
index d3f2695f10815c9fa08e6e17c959da7c6da3c2b4..4bac1d7de3b167157ba0821e2582235b03282cb1 100644 (file)
@@ -28,8 +28,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
-import org.sonar.ce.task.projectanalysis.component.Developer;
-import org.sonar.ce.task.projectanalysis.component.DumbDeveloper;
 import org.sonar.ce.task.projectanalysis.measure.Measure.ValueType;
 import org.sonar.server.util.WrapInSingleElementArray;
 
@@ -50,7 +48,6 @@ public class MeasureTest {
 
   private static final List<Measure> MEASURES = ImmutableList.of(
     INT_MEASURE, LONG_MEASURE, DOUBLE_MEASURE, STRING_MEASURE, TRUE_MEASURE, FALSE_MEASURE, NO_VALUE_MEASURE, LEVEL_MEASURE);
-  private static final Developer SOME_DEVELOPER = new DumbDeveloper("DEV1");
 
   @Rule
   public final ExpectedException expectedException = ExpectedException.none();
@@ -97,19 +94,6 @@ public class MeasureTest {
       .toArray(Object[][]::new);
   }
 
-  @Test
-  public void getDeveloper_returns_dev_set_in_builder() {
-    assertThat(newMeasureBuilder().forDeveloper(SOME_DEVELOPER).createNoValue().getDeveloper()).isEqualTo(SOME_DEVELOPER);
-  }
-
-  @Test
-  public void create_measure_for_dev() {
-    Measure measure = newMeasureBuilder()
-      .forDeveloper(SOME_DEVELOPER)
-      .createNoValue();
-    assertThat(measure.getDeveloper()).isEqualTo(SOME_DEVELOPER);
-  }
-
   @Test(expected = NullPointerException.class)
   public void create_from_String_throws_NPE_if_arg_is_null() {
     newMeasureBuilder().create((String) null);