diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-02-06 14:47:25 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-02-09 12:15:10 +0100 |
commit | 249770f0db06b31d1da4bc1f0f418aebffeb7c82 (patch) | |
tree | aafe9f5ec3d7351056c9f400ffd25dbe9b526f42 | |
parent | d0e2843455903704e470a5fb4834cded31d10dcb (diff) | |
download | sonarqube-249770f0db06b31d1da4bc1f0f418aebffeb7c82.tar.gz sonarqube-249770f0db06b31d1da4bc1f0f418aebffeb7c82.zip |
SONAR-8744 Remove usage of periods 2 to 5 in Daos
15 files changed, 155 insertions, 578 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java index 236b1459866..7d528160290 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDao.java @@ -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); } diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java index 635b9118496..e3e0d3be819 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotDto.java @@ -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) { diff --git a/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java b/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java index 4abd2972eae..6ec95ddfa95 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/SnapshotMapper.java @@ -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); diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java index 9e41defc058..2b951e52aea 100644 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java +++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java @@ -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) diff --git a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml index 79051c4042e..4e00d6ac39c 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml @@ -12,21 +12,9 @@ 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"> @@ -34,13 +22,6 @@ 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"/> @@ -181,20 +162,8 @@ 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}, @@ -204,21 +173,9 @@ #{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> diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml index 2a75e4a422c..24028b375d5 100644 --- a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml @@ -13,11 +13,7 @@ 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"> @@ -186,10 +182,6 @@ description, person_id, variation_value_1, - variation_value_2, - variation_value_3, - variation_value_4, - variation_value_5, measure_data) VALUES ( #{value, jdbcType=DOUBLE}, @@ -201,11 +193,7 @@ #{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> diff --git a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java index dce25875e67..1978e60db08 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDaoTest.java @@ -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); } } diff --git a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDtoTest.java b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDtoTest.java index ff6dcef388a..1991e424fb2 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/SnapshotDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/SnapshotDtoTest.java @@ -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()); } } diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java index 2500442b07a..99a43f40090 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java @@ -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()); } diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java index 62cf5e09dc9..1783273bb67 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDtoTest.java @@ -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); - } } diff --git a/sonar-db/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java b/sonar-db/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java index 20fe471ceb1..027e89f2752 100644 --- a/sonar-db/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java +++ b/sonar-db/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java @@ -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 index 871dedcb5e9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/empty.xml +++ /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 index 49d4cc182f8..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/insert-result.xml +++ /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 index 963b354b93d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/modules.xml +++ /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 index a0cff55cdd2..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/component/SnapshotDaoTest/shared.xml +++ /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> |