]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8744 Remove usage of periods 2 to 5 in Daos
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 6 Feb 2017 13:47:25 +0000 (14:47 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 9 Feb 2017 11:15:10 +0000 (12:15 +0100)
15 files changed:
sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java
sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java
sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java
sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java
sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
sonar-db/src/test/java/org/sonar/db/component/SnapshotDtoTest.java
sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java
sonar-db/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/empty.xml [deleted file]
sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/insert-result.xml [deleted file]
sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/modules.xml [deleted file]
sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/shared.xml [deleted file]

index 236b1459866d8212ac0058bbece1733f4bde50ec..7d5281602900053a6cf921f0a09fc72ee84d868f 100644 (file)
@@ -40,15 +40,6 @@ public class SnapshotDao implements Dao {
     return previousLastSnapshot == null || previousLastSnapshot.getCreatedAt() < snapshotTested.getCreatedAt();
   }
 
-  /**
-   * @deprecated use {@link #selectByUuid(DbSession, String)}
-   */
-  @Deprecated
-  @CheckForNull
-  public SnapshotDto selectById(DbSession session, long id) {
-    return mapper(session).selectByKey(id);
-  }
-
   public Optional<SnapshotDto> selectByUuid(DbSession dbSession, String analysisUuid) {
     List<SnapshotDto> dtos = mapper(dbSession).selectByUuids(Collections.singletonList(analysisUuid));
     if (dtos.isEmpty()) {
@@ -135,7 +126,6 @@ public class SnapshotDao implements Dao {
       .orNull();
   }
 
-
   private static SnapshotMapper mapper(DbSession session) {
     return session.getMapper(SnapshotMapper.class);
   }
index 635b911849684ab7aa7e505b6134ef740386b64b..e3e0d3be819124747e6810b454b7d305a509c5de 100644 (file)
@@ -30,8 +30,6 @@ public final class SnapshotDto {
   public static final String STATUS_UNPROCESSED = "U";
   public static final String STATUS_PROCESSED = "P";
 
-  private static final String INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5 = "Index should be in range from 1 to 5";
-
   private Long id;
   private String uuid;
   private String componentUuid;
@@ -41,24 +39,9 @@ public final class SnapshotDto {
   private Integer purgeStatus;
   private Boolean last;
   private String version;
-
-  private String period1Mode;
-  private String period2Mode;
-  private String period3Mode;
-  private String period4Mode;
-  private String period5Mode;
-
-  private String period1Param;
-  private String period2Param;
-  private String period3Param;
-  private String period4Param;
-  private String period5Param;
-
-  private Long period1Date;
-  private Long period2Date;
-  private Long period3Date;
-  private Long period4Date;
-  private Long period5Date;
+  private String periodMode;
+  private String periodParam;
+  private Long periodDate;
 
   public Long getId() {
     return id;
@@ -137,127 +120,88 @@ public final class SnapshotDto {
     return this;
   }
 
+  public SnapshotDto setPeriodMode(@Nullable String p) {
+    periodMode = p;
+    return this;
+  }
+
+  /**
+   * @deprecated use {@link #setPeriodMode(String)} instead
+   */
+  @Deprecated
   public SnapshotDto setPeriodMode(int index, @Nullable String p) {
-    switch (index) {
-      case 1:
-        period1Mode = p;
-        break;
-      case 2:
-        period2Mode = p;
-        break;
-      case 3:
-        period3Mode = p;
-        break;
-      case 4:
-        period4Mode = p;
-        break;
-      case 5:
-        period5Mode = p;
-        break;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    setPeriodMode(p);
     return this;
   }
 
+  @CheckForNull
+  public String getPeriodMode() {
+    return periodMode;
+  }
+
+  /**
+   * @deprecated use {@link #getPeriodMode()} instead
+   */
+  @Deprecated
   @CheckForNull
   public String getPeriodMode(int index) {
-    switch (index) {
-      case 1:
-        return period1Mode;
-      case 2:
-        return period2Mode;
-      case 3:
-        return period3Mode;
-      case 4:
-        return period4Mode;
-      case 5:
-        return period5Mode;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    return getPeriodMode();
+  }
+
+  public SnapshotDto setPeriodParam(@Nullable String p) {
+    periodParam = p;
+    return this;
   }
 
+  /**
+   * @deprecated use {@link #setPeriodParam(String)}} instead
+   */
+  @Deprecated
   public SnapshotDto setPeriodParam(int index, @Nullable String p) {
-    switch (index) {
-      case 1:
-        period1Param = p;
-        break;
-      case 2:
-        period2Param = p;
-        break;
-      case 3:
-        period3Param = p;
-        break;
-      case 4:
-        period4Param = p;
-        break;
-      case 5:
-        period5Param = p;
-        break;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    setPeriodParam(p);
     return this;
   }
 
+  @CheckForNull
+  public String getPeriodModeParameter() {
+    return periodParam;
+  }
+
+  /**
+   * @deprecated use {@link #getPeriodModeParameter()}} instead
+   */
+  @Deprecated
   @CheckForNull
   public String getPeriodModeParameter(int periodIndex) {
-    switch (periodIndex) {
-      case 1:
-        return period1Param;
-      case 2:
-        return period2Param;
-      case 3:
-        return period3Param;
-      case 4:
-        return period4Param;
-      case 5:
-        return period5Param;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    return getPeriodModeParameter();
   }
 
+  public SnapshotDto setPeriodDate(@Nullable Long date) {
+    periodDate = date;
+    return this;
+  }
+
+  /**
+   * @deprecated use {@link #setPeriodDate(Long)}} instead
+   */
+  @Deprecated
   public SnapshotDto setPeriodDate(int index, @Nullable Long date) {
-    switch (index) {
-      case 1:
-        period1Date = date;
-        break;
-      case 2:
-        period2Date = date;
-        break;
-      case 3:
-        period3Date = date;
-        break;
-      case 4:
-        period4Date = date;
-        break;
-      case 5:
-        period5Date = date;
-        break;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    setPeriodDate(date);
     return this;
   }
 
+  @CheckForNull
+  public Long getPeriodDate() {
+    return periodDate;
+  }
+
+  /**
+   * @deprecated use {@link #getPeriodDate()}} instead
+   */
+  @Deprecated
   @CheckForNull
   public Long getPeriodDate(int periodIndex) {
-    switch (periodIndex) {
-      case 1:
-        return period1Date;
-      case 2:
-        return period2Date;
-      case 3:
-        return period3Date;
-      case 4:
-        return period4Date;
-      case 5:
-        return period5Date;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    return getPeriodDate();
   }
 
   public SnapshotDto setCreatedAt(Long createdAt) {
index 4abd2972eae90a6b62df669aa5a6d719c5b83c96..6ec95ddfa959f88441038461ee9cb8ad15c746af 100644 (file)
@@ -27,9 +27,6 @@ import org.apache.ibatis.session.RowBounds;
 
 public interface SnapshotMapper {
 
-  @CheckForNull
-  SnapshotDto selectByKey(long id);
-
   List<SnapshotDto> selectByUuids(@Param("uuids") List<String> uuids);
 
   void insert(SnapshotDto snapshot);
index 9e41defc058584b148f825b1fd023a26e7aeb2b7..2b951e52aea3a4670af61e97d44a31874fecca5a 100644 (file)
@@ -25,17 +25,12 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
 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 Double value;
   private String textValue;
   private byte[] dataValue;
-  private Double variation1;
-  private Double variation2;
-  private Double variation3;
-  private Double variation4;
-  private Double variation5;
+  private Double variation;
   private String alertStatus;
   private String alertText;
   private String description;
@@ -86,47 +81,32 @@ public class MeasureDto {
     return this;
   }
 
+  @CheckForNull
+  public Double getVariation() {
+    return variation;
+  }
+
   /**
    * @param index starts at 1
+   * @deprecated use {@link #getVariation()} instead
    */
   @CheckForNull
+  @Deprecated
   public Double getVariation(int index) {
-    switch (index) {
-      case 1:
-        return variation1;
-      case 2:
-        return variation2;
-      case 3:
-        return variation3;
-      case 4:
-        return variation4;
-      case 5:
-        return variation5;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    return getVariation();
+  }
+
+  public MeasureDto setVariation(@Nullable Double d) {
+    variation = d;
+    return this;
   }
 
+  /**
+   * @deprecated use {@link #setVariation(Double)} instead
+   */
+  @Deprecated
   public MeasureDto setVariation(int index, @Nullable Double d) {
-    switch (index) {
-      case 1:
-        variation1 = d;
-        break;
-      case 2:
-        variation2 = d;
-        break;
-      case 3:
-        variation3 = d;
-        break;
-      case 4:
-        variation4 = d;
-        break;
-      case 5:
-        variation5 = d;
-        break;
-      default:
-        throw new IndexOutOfBoundsException(INDEX_SHOULD_BE_IN_RANGE_FROM_1_TO_5);
-    }
+    setVariation(d);
     return this;
   }
 
@@ -194,11 +174,7 @@ public class MeasureDto {
       .add("value", value)
       .add("textValue", textValue)
       .add("dataValue", dataValue)
-      .add("variation1", variation1)
-      .add("variation2", variation2)
-      .add("variation3", variation3)
-      .add("variation4", variation4)
-      .add("variation5", variation5)
+      .add("variation", variation)
       .add("alertStatus", alertStatus)
       .add("alertText", alertText)
       .add("description", description)
index 79051c4042e5f0e096b5868c14056ebddcacc628..4e00d6ac39cb3eced7730c2e6a95c1534a6f733e 100644 (file)
     s.purge_status as purgeStatus,
     s.islast as last,
     s.version as version,
-    s.period1_mode as period1Mode,
-    s.period2_mode as period2Mode,
-    s.period3_mode as period3Mode,
-    s.period4_mode as period4Mode,
-    s.period5_mode as period5Mode,
-    s.period1_param as period1Param,
-    s.period2_param as period2Param,
-    s.period3_param as period3Param,
-    s.period4_param as period4Param,
-    s.period5_param as period5Param,
-    s.period1_date as period1Date,
-    s.period2_date as period2Date,
-    s.period3_date as period3Date,
-    s.period4_date as period4Date,
-    s.period5_date as period5Date
+    s.period1_mode as periodMode,
+    s.period1_param as periodParam,
+    s.period1_date as periodDate
   </sql>
 
   <sql id="viewsSnapshotColumns">
     s.created_at as createdAt
   </sql>
 
-  <select id="selectByKey" parameterType="Long" resultType="Snapshot">
-    SELECT
-    <include refid="snapshotColumns" />
-    FROM snapshots s
-    where s.id=#{key,jdbcType=BIGINT}
-  </select>
-
   <select id="selectByUuids" parameterType="List" resultType="Snapshot">
     SELECT
       <include refid="snapshotColumns"/>
     islast,
     version,
     period1_mode,
-    period2_mode,
-    period3_mode,
-    period4_mode,
-    period5_mode,
     period1_param,
-    period2_param,
-    period3_param,
-    period4_param,
-    period5_param,
-    period1_date,
-    period2_date,
-    period3_date,
-    period4_date,
-    period5_date)
+    period1_date)
     values (
     #{uuid, jdbcType=VARCHAR},
     #{componentUuid, jdbcType=VARCHAR},
     #{purgeStatus, jdbcType=INTEGER},
     #{last, jdbcType=BOOLEAN},
     #{version, jdbcType=VARCHAR},
-    #{period1Mode, jdbcType=VARCHAR},
-    #{period2Mode, jdbcType=VARCHAR},
-    #{period3Mode, jdbcType=VARCHAR},
-    #{period4Mode, jdbcType=VARCHAR},
-    #{period5Mode, jdbcType=VARCHAR},
-    #{period1Param, jdbcType=VARCHAR},
-    #{period2Param, jdbcType=VARCHAR},
-    #{period3Param, jdbcType=VARCHAR},
-    #{period4Param, jdbcType=VARCHAR},
-    #{period5Param, jdbcType=VARCHAR},
-    #{period1Date, jdbcType=BIGINT},
-    #{period2Date, jdbcType=BIGINT},
-    #{period3Date, jdbcType=BIGINT},
-    #{period4Date, jdbcType=BIGINT},
-    #{period5Date, jdbcType=BIGINT})
+    #{periodMode, jdbcType=VARCHAR},
+    #{periodParam, jdbcType=VARCHAR},
+    #{periodDate, jdbcType=BIGINT})
   </insert>
 </mapper>
 
index 2a75e4a422c16343584db2b1de5876632635e8a7..24028b375d57f826345f90026acd73097fc697ad 100644 (file)
     pm.alert_status as alertStatus,
     pm.alert_text as alertText,
     pm.measure_data as dataValue,
-    pm.variation_value_1 as variation1,
-    pm.variation_value_2 as variation2,
-    pm.variation_value_3 as variation3,
-    pm.variation_value_4 as variation4,
-    pm.variation_value_5 as variation5
+    pm.variation_value_1 as variation
   </sql>
 
   <sql id="extendedMeasureColumns">
     description,
     person_id,
     variation_value_1,
-    variation_value_2,
-    variation_value_3,
-    variation_value_4,
-    variation_value_5,
     measure_data)
     VALUES (
     #{value, jdbcType=DOUBLE},
     #{alertText, jdbcType=VARCHAR},
     #{description, jdbcType=VARCHAR},
     #{developerId, jdbcType=INTEGER},
-    #{variation1, jdbcType=DOUBLE},
-    #{variation2, jdbcType=DOUBLE},
-    #{variation3, jdbcType=DOUBLE},
-    #{variation4, jdbcType=DOUBLE},
-    #{variation5, jdbcType=DOUBLE},
+    #{variation, jdbcType=DOUBLE},
     #{dataValue, jdbcType=BINARY}
     )
   </insert>
index dce25875e677c03b0a62e6f3bacf49ddd72f95a2..1978e60db0819863675426c77df80ccee8e406fd 100644 (file)
@@ -57,48 +57,35 @@ public class SnapshotDaoTest {
 
   @Test
   public void test_selectByUuid() {
-    db.prepareDbUnit(getClass(), "shared.xml");
-
-    Optional<SnapshotDto> result = underTest.selectByUuid(db.getSession(), "u3");
-    assertThat(result.isPresent()).isTrue();
-
-    assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST").isPresent()).isFalse();
-  }
+    ComponentDto project = db.components().insertProject();
+    db.components().insertSnapshot(newAnalysis(project)
+      .setUuid("ABCD")
+      .setStatus("P")
+      .setLast(true)
+      .setPurgeStatus(1)
+      .setPeriodMode("days")
+      .setPeriodParam("30")
+      .setPeriodDate(1500000000001L)
+      .setVersion("2.1-SNAPSHOT")
+      .setBuildDate(1500000000006L)
+      .setCreatedAt(1403042400000L));
 
-  @Test
-  public void test_selectById() {
-    db.prepareDbUnit(getClass(), "shared.xml");
-
-    SnapshotDto result = underTest.selectById(db.getSession(), 3L);
-    assertThat(result).isNotNull();
-    assertThat(result.getId()).isEqualTo(3L);
-    assertThat(result.getUuid()).isEqualTo("u3");
-    assertThat(result.getComponentUuid()).isEqualTo("uuid_3");
+    SnapshotDto result = underTest.selectByUuid(db.getSession(), "ABCD").get();
+    assertThat(result.getId()).isNotNull();
+    assertThat(result.getUuid()).isEqualTo("ABCD");
+    assertThat(result.getComponentUuid()).isEqualTo(project.uuid());
     assertThat(result.getStatus()).isEqualTo("P");
     assertThat(result.getLast()).isTrue();
     assertThat(result.getPurgeStatus()).isEqualTo(1);
     assertThat(result.getVersion()).isEqualTo("2.1-SNAPSHOT");
+    assertThat(result.getPeriodMode()).isEqualTo("days");
+    assertThat(result.getPeriodModeParameter()).isEqualTo("30");
+    assertThat(result.getPeriodDate()).isEqualTo(1500000000001L);
+    assertThat(result.getBuildDate()).isEqualTo(1500000000006L);
+    assertThat(result.getCreatedAt()).isEqualTo(1403042400000L);
+    assertThat(result.getVersion()).isEqualTo("2.1-SNAPSHOT");
 
-    assertThat(result.getPeriodMode(1)).isEqualTo("days1");
-    assertThat(result.getPeriodModeParameter(1)).isEqualTo("30");
-    assertThat(result.getPeriodDate(1)).isEqualTo(1316815200000L);
-    assertThat(result.getPeriodMode(2)).isEqualTo("days2");
-    assertThat(result.getPeriodModeParameter(2)).isEqualTo("31");
-    assertThat(result.getPeriodDate(2)).isEqualTo(1316901600000L);
-    assertThat(result.getPeriodMode(3)).isEqualTo("days3");
-    assertThat(result.getPeriodModeParameter(3)).isEqualTo("32");
-    assertThat(result.getPeriodDate(3)).isEqualTo(1316988000000L);
-    assertThat(result.getPeriodMode(4)).isEqualTo("days4");
-    assertThat(result.getPeriodModeParameter(4)).isEqualTo("33");
-    assertThat(result.getPeriodDate(4)).isEqualTo(1317074400000L);
-    assertThat(result.getPeriodMode(5)).isEqualTo("days5");
-    assertThat(result.getPeriodModeParameter(5)).isEqualTo("34");
-    assertThat(result.getPeriodDate(5)).isEqualTo(1317160800000L);
-
-    assertThat(result.getCreatedAt()).isEqualTo(1228172400000L);
-    assertThat(result.getBuildDate()).isEqualTo(1317247200000L);
-
-    assertThat(underTest.selectById(db.getSession(), 999L)).isNull();
+    assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST").isPresent()).isFalse();
   }
 
   @Test
@@ -213,24 +200,40 @@ public class SnapshotDaoTest {
 
   @Test
   public void insert() {
-    db.prepareDbUnit(getClass(), "empty.xml");
+    ComponentDto project = db.components().insertProject();
 
-    SnapshotDto dto = defaultSnapshot().setCreatedAt(1403042400000L);
-
-    underTest.insert(db.getSession(), dto);
-    db.getSession().commit();
+    SnapshotDto dto = underTest.insert(db.getSession(), newAnalysis(project)
+      .setStatus("P")
+      .setLast(true)
+      .setPurgeStatus(1)
+      .setPeriodMode("days")
+      .setPeriodParam("30")
+      .setPeriodDate(1500000000001L)
+      .setVersion("2.1-SNAPSHOT")
+      .setBuildDate(1500000000006L)
+      .setCreatedAt(1403042400000L));
 
     assertThat(dto.getId()).isNotNull();
-    db.assertDbUnit(getClass(), "insert-result.xml", new String[] {"id"}, "snapshots");
+    assertThat(dto.getUuid()).isNotNull();
+    assertThat(dto.getComponentUuid()).isEqualTo(project.uuid());
+    assertThat(dto.getStatus()).isEqualTo("P");
+    assertThat(dto.getLast()).isTrue();
+    assertThat(dto.getPurgeStatus()).isEqualTo(1);
+    assertThat(dto.getPeriodMode()).isEqualTo("days");
+    assertThat(dto.getPeriodModeParameter()).isEqualTo("30");
+    assertThat(dto.getPeriodDate()).isEqualTo(1500000000001L);
+    assertThat(dto.getBuildDate()).isEqualTo(1500000000006L);
+    assertThat(dto.getCreatedAt()).isEqualTo(1403042400000L);
+    assertThat(dto.getVersion()).isEqualTo("2.1-SNAPSHOT");
   }
 
   @Test
   public void insert_snapshots() {
-    db.prepareDbUnit(getClass(), "empty.xml");
+    ComponentDto project = db.components().insertProject();
 
     underTest.insert(db.getSession(),
-      new SnapshotDto().setComponentUuid("uuid_1").setLast(false).setUuid("u5"),
-      new SnapshotDto().setComponentUuid("uuid_2").setLast(false).setUuid("u6"));
+      newAnalysis(project).setLast(false).setUuid("u5"),
+      newAnalysis(project).setLast(false).setUuid("u6"));
     db.getSession().commit();
 
     assertThat(db.countRowsOfTable("snapshots")).isEqualTo(2);
@@ -304,7 +307,7 @@ public class SnapshotDaoTest {
   }
 
   private SnapshotDto insertAnalysis(String projectUuid, String uuid, String status, boolean isLastFlag) {
-    SnapshotDto snapshot = SnapshotTesting.newAnalysis(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid))
+    SnapshotDto snapshot = newAnalysis(ComponentTesting.newProjectDto(OrganizationTesting.newOrganizationDto(), projectUuid))
       .setLast(isLastFlag)
       .setStatus(status)
       .setUuid(uuid);
@@ -326,21 +329,9 @@ public class SnapshotDaoTest {
       .setLast(true)
       .setPurgeStatus(1)
       .setVersion("2.1-SNAPSHOT")
-      .setPeriodMode(1, "days1")
-      .setPeriodMode(2, "days2")
-      .setPeriodMode(3, "days3")
-      .setPeriodMode(4, "days4")
-      .setPeriodMode(5, "days5")
-      .setPeriodParam(1, "30")
-      .setPeriodParam(2, "31")
-      .setPeriodParam(3, "32")
-      .setPeriodParam(4, "33")
-      .setPeriodParam(5, "34")
-      .setPeriodDate(1, 1_500_000_000_001L)
-      .setPeriodDate(2, 1_500_000_000_002L)
-      .setPeriodDate(3, 1_500_000_000_003L)
-      .setPeriodDate(4, 1_500_000_000_004L)
-      .setPeriodDate(5, 1_500_000_000_005L)
+      .setPeriodMode("days1")
+      .setPeriodParam("30")
+      .setPeriodDate(1_500_000_000_001L)
       .setBuildDate(1_500_000_000_006L);
   }
 }
index ff6dcef388a91725c9f3bab09faa730e765af560..1991e424fb208ccc3e3ead522c82df1f9fa6dcab 100644 (file)
@@ -34,42 +34,18 @@ public class SnapshotDtoTest {
       .setComponentUuid("uuid_21")
       .setLast(true)
       .setVersion("1.0")
-      .setPeriodMode(1, "mode1")
-      .setPeriodMode(2, "mode2")
-      .setPeriodMode(3, "mode3")
-      .setPeriodMode(4, "mode4")
-      .setPeriodMode(5, "mode5")
-      .setPeriodParam(1, "param1")
-      .setPeriodParam(2, "param2")
-      .setPeriodParam(3, "param3")
-      .setPeriodParam(4, "param4")
-      .setPeriodParam(5, "param5")
-      .setPeriodDate(1, parseDate("2014-06-01").getTime())
-      .setPeriodDate(2, parseDate("2014-06-02").getTime())
-      .setPeriodDate(3, parseDate("2014-06-03").getTime())
-      .setPeriodDate(4, parseDate("2014-06-04").getTime())
-      .setPeriodDate(5, parseDate("2014-06-05").getTime());
+      .setPeriodMode("mode1")
+      .setPeriodParam("param1")
+      .setPeriodDate(parseDate("2014-06-01").getTime());
 
     assertThat(snapshotDto.getId()).isEqualTo(10L);
     assertThat(snapshotDto.getBuildDate()).isEqualTo(parseDate("2014-07-02").getTime());
     assertThat(snapshotDto.getComponentUuid()).isEqualTo("uuid_21");
     assertThat(snapshotDto.getLast()).isTrue();
     assertThat(snapshotDto.getVersion()).isEqualTo("1.0");
-    assertThat(snapshotDto.getPeriodMode(1)).isEqualTo("mode1");
-    assertThat(snapshotDto.getPeriodMode(2)).isEqualTo("mode2");
-    assertThat(snapshotDto.getPeriodMode(3)).isEqualTo("mode3");
-    assertThat(snapshotDto.getPeriodMode(4)).isEqualTo("mode4");
-    assertThat(snapshotDto.getPeriodMode(5)).isEqualTo("mode5");
-    assertThat(snapshotDto.getPeriodModeParameter(1)).isEqualTo("param1");
-    assertThat(snapshotDto.getPeriodModeParameter(2)).isEqualTo("param2");
-    assertThat(snapshotDto.getPeriodModeParameter(3)).isEqualTo("param3");
-    assertThat(snapshotDto.getPeriodModeParameter(4)).isEqualTo("param4");
-    assertThat(snapshotDto.getPeriodModeParameter(5)).isEqualTo("param5");
-    assertThat(snapshotDto.getPeriodDate(1)).isEqualTo(parseDate("2014-06-01").getTime());
-    assertThat(snapshotDto.getPeriodDate(2)).isEqualTo(parseDate("2014-06-02").getTime());
-    assertThat(snapshotDto.getPeriodDate(3)).isEqualTo(parseDate("2014-06-03").getTime());
-    assertThat(snapshotDto.getPeriodDate(4)).isEqualTo(parseDate("2014-06-04").getTime());
-    assertThat(snapshotDto.getPeriodDate(5)).isEqualTo(parseDate("2014-06-05").getTime());
+    assertThat(snapshotDto.getPeriodMode()).isEqualTo("mode1");
+    assertThat(snapshotDto.getPeriodModeParameter()).isEqualTo("param1");
+    assertThat(snapshotDto.getPeriodDate()).isEqualTo(parseDate("2014-06-01").getTime());
   }
 
 }
index 2500442b07a008238fd263a0d2339f4615a9758d..99a43f40090d417058886eb379c3fdb5bc0528d7 100644 (file)
@@ -87,11 +87,7 @@ public class MeasureDaoTest {
       .setComponentUuid("C4")
       .setValue(5.0d)
       .setData("data")
-      .setVariation(1, 1.0d)
-      .setVariation(2, 2.0d)
-      .setVariation(3, 3.0d)
-      .setVariation(4, 4.0d)
-      .setVariation(5, 5.0d)
+      .setVariation(1d)
       .setAlertStatus("alert")
       .setAlertText("alert-text")
       .setDescription("measure-description");
@@ -108,11 +104,7 @@ public class MeasureDaoTest {
     assertThat(selected.getComponentUuid()).isEqualTo(inserted.getComponentUuid());
     assertThat(selected.getValue()).isEqualTo(inserted.getValue());
     assertThat(selected.getData()).isEqualTo(inserted.getData());
-    assertThat(selected.getVariation(1)).isEqualTo(inserted.getVariation(1));
-    assertThat(selected.getVariation(2)).isEqualTo(inserted.getVariation(2));
-    assertThat(selected.getVariation(3)).isEqualTo(inserted.getVariation(3));
-    assertThat(selected.getVariation(4)).isEqualTo(inserted.getVariation(4));
-    assertThat(selected.getVariation(5)).isEqualTo(inserted.getVariation(5));
+    assertThat(selected.getVariation()).isEqualTo(inserted.getVariation());
     assertThat(selected.getAlertStatus()).isEqualTo(inserted.getAlertStatus());
     assertThat(selected.getAlertText()).isEqualTo(inserted.getAlertText());
   }
index 62cf5e09dc9184bf47e1947485bafe79cc190400..1783273bb6791e853158d02889862802d406773c 100644 (file)
@@ -33,19 +33,11 @@ public class MeasureDtoTest {
     underTest
       .setValue(2d)
       .setData("text value")
-      .setVariation(1, 1d)
-      .setVariation(2, 2d)
-      .setVariation(3, 3d)
-      .setVariation(4, 4d)
-      .setVariation(5, 5d);
+      .setVariation(1d);
 
     assertThat(underTest.getValue()).isEqualTo(2d);
     assertThat(underTest.getData()).isNotNull();
-    assertThat(underTest.getVariation(1)).isEqualTo(1d);
-    assertThat(underTest.getVariation(2)).isEqualTo(2d);
-    assertThat(underTest.getVariation(3)).isEqualTo(3d);
-    assertThat(underTest.getVariation(4)).isEqualTo(4d);
-    assertThat(underTest.getVariation(5)).isEqualTo(5d);
+    assertThat(underTest.getVariation()).isEqualTo(1d);
   }
 
   @Test
@@ -57,14 +49,4 @@ public class MeasureDtoTest {
   public void text_value_under_4000_characters() {
     assertThat(underTest.setData("text value").getData()).isEqualTo("text value");
   }
-
-  @Test(expected = IndexOutOfBoundsException.class)
-  public void fail_to_set_out_of_bounds_variation() {
-    underTest.setVariation(6, 1d);
-  }
-
-  @Test(expected = IndexOutOfBoundsException.class)
-  public void fail_to_get_out_of_bounds_variation() {
-    underTest.getVariation(6);
-  }
 }
index 20fe471ceb16a3eeabd3a12c63c3a394597df273..027e89f275205a0fc3671fad393c219b393aa0c9 100644 (file)
@@ -290,7 +290,7 @@ public class ProjectMeasuresIndexerIteratorTest {
   }
 
   private MeasureDto insertMeasure(ComponentDto project, SnapshotDto analysis, MetricDto metric, @Nullable Double value, @Nullable Double leakValue) {
-    return insertMeasure(MeasureTesting.newMeasureDto(metric, project, analysis).setValue(value).setVariation(1, leakValue));
+    return insertMeasure(MeasureTesting.newMeasureDto(metric, project, analysis).setValue(value).setVariation(leakValue));
   }
 
   private MeasureDto insertMeasure(MeasureDto measure) {
diff --git a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/empty.xml b/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/empty.xml
deleted file mode 100644 (file)
index 871dedc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/insert-result.xml
deleted file mode 100644 (file)
index 49d4cc1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<dataset>
-
-  <snapshots id="1"
-             uuid="u1"
-             component_uuid="uuid_3"
-             status="P"
-             islast="[true]"
-             purge_status="1"
-             period1_mode="days1"
-             period1_param="30"
-             period1_date="1500000000001"
-             period2_mode="days2"
-             period2_param="31"
-             period2_date="1500000000002"
-             period3_mode="days3"
-             period3_param="32"
-             period3_date="1500000000003"
-             period4_mode="days4"
-             period4_param="33"
-             period4_date="1500000000004"
-             period5_mode="days5"
-             period5_param="34"
-             period5_date="1500000000005"
-             created_at="1403042400000"
-             build_date="1500000000006"
-             version="2.1-SNAPSHOT"
-  />
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/modules.xml b/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/modules.xml
deleted file mode 100644 (file)
index 963b354..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-<dataset>
-
-  <!-- root project -->
-  <projects organization_uuid="org1"
-            id="1"
-            root_id="[null]"
-            scope="PRJ"
-            qualifier="TRK"
-            kee="org.struts:struts"
-            name="Struts"
-            uuid="ABCD"
-            project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path="."
-            description="the description"
-            long_name="Apache Struts"
-            enabled="[true]"
-            language="[null]"
-            copy_resource_id="[null]"
-            person_id="[null]"
-            path="[null]"
-            authorization_updated_at="[null]"/>
-  <snapshots id="1"
-             uuid="u1"
-             status="P"
-             islast="[true]"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             created_at="1228222680000"
-             build_date="1228222680000"
-             version="[null]"
-  />
-  <snapshots id="10"
-             uuid="u10"
-             status="P"
-             islast="[false]"
-             purge_status="[null]"
-             period1_mode="[null]"
-             period1_param="[null]"
-             period1_date="[null]"
-             period2_mode="[null]"
-             period2_param="[null]"
-             period2_date="[null]"
-             period3_mode="[null]"
-             period3_param="[null]"
-             period3_date="[null]"
-             period4_mode="[null]"
-             period4_param="[null]"
-             period4_date="[null]"
-             period5_mode="[null]"
-             period5_param="[null]"
-             period5_date="[null]"
-             created_at="1228136280000"
-             build_date="1228136280000"
-             version="[null]"
-  />
-
-  <!-- module -->
-  <projects organization_uuid="org1"
-            id="2"
-            root_id="1"
-            kee="org.struts:struts-core"
-            name="Struts Core"
-            uuid="EFGH"
-            project_uuid="ABCD"
-            module_uuid="[null]"
-            module_uuid_path=".ABCD."
-            scope="PRJ"
-            qualifier="BRC"
-            long_name="Struts Core"
-            description="[null]"
-            enabled="[true]"
-            language="[null]"
-            copy_resource_id="[null]"
-            person_id="[null]"
-            authorization_updated_at="[null]"/>
-
-  <!-- sub module -->
-  <projects organization_uuid="org1"
-            id="3"
-            root_id="1"
-            kee="org.struts:struts-data"
-            name="Struts Data"
-            uuid="FGHI"
-            project_uuid="ABCD"
-            module_uuid="EFGH"
-            module_uuid_path=".ABCD.EFGH."
-            scope="PRJ"
-            qualifier="BRC"
-            long_name="Struts Data"
-            description="[null]"
-            enabled="[true]"
-            language="[null]"
-            copy_resource_id="[null]"
-            person_id="[null]"
-            authorization_updated_at="[null]"/>
-
-
-  <!-- directory -->
-  <projects organization_uuid="org1"
-            long_name="org.struts"
-            id="4"
-            scope="DIR"
-            qualifier="DIR"
-            kee="org.struts:struts-core:src/org/struts"
-            uuid="GHIJ"
-            project_uuid="ABCD"
-            module_uuid="FGHI"
-            module_uuid_path=".ABCD.EFGH.FGHI."
-            name="src/org/struts"
-            root_id="3"
-            description="[null]"
-            enabled="[true]"
-            language="[null]"
-            copy_resource_id="[null]"
-            person_id="[null]"
-            path="src/org/struts"
-            authorization_updated_at="[null]"/>
-
-  <!-- file -->
-  <projects organization_uuid="org1"
-            long_name="org.struts.RequestContext"
-            id="5"
-            scope="FIL"
-            qualifier="FIL"
-            kee="org.struts:struts-core:src/org/struts/RequestContext.java"
-            uuid="HIJK"
-            project_uuid="ABCD"
-            module_uuid="FGHI"
-            module_uuid_path=".ABCD.EFGH.FGHI."
-            name="RequestContext.java"
-            root_id="3"
-            description="[null]"
-            enabled="[true]"
-            language="java"
-            copy_resource_id="[null]"
-            person_id="[null]"
-            path="src/org/struts/RequestContext.java"
-            authorization_updated_at="[null]"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/shared.xml
deleted file mode 100644 (file)
index a0cff55..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<dataset>
-
-  <snapshots id="3"
-             uuid="u3"
-             component_uuid="uuid_3"
-             status="P"
-             islast="[true]"
-             purge_status="1"
-             period1_mode="days1"
-             period1_param="30"
-             period1_date="1316815200000"
-             period2_mode="days2"
-             period2_param="31"
-             period2_date="1316901600000"
-             period3_mode="days3"
-             period3_param="32"
-             period3_date="1316988000000"
-             period4_mode="days4"
-             period4_param="33"
-             period4_date="1317074400000"
-             period5_mode="days5"
-             period5_param="34"
-             period5_date="1317160800000"
-             created_at="1228172400000"
-             build_date="1317247200000"
-             version="2.1-SNAPSHOT"
-  />
-
-</dataset>