diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2019-01-14 16:56:12 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-02-11 09:11:47 +0100 |
commit | 18297ee25ceb40f438a5aee1e92a8c2d4d8fe496 (patch) | |
tree | ab454c4375aa3fba77556b50dcf28b7b26559b2c /server/sonar-db-dao | |
parent | 47ebff25c379b9162943121a49278553967f2dfe (diff) | |
download | sonarqube-18297ee25ceb40f438a5aee1e92a8c2d4d8fe496.tar.gz sonarqube-18297ee25ceb40f438a5aee1e92a8c2d4d8fe496.zip |
SONAR-11631 rename snapshot's version to codePeriodVersion
Diffstat (limited to 'server/sonar-db-dao')
6 files changed, 41 insertions, 41 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDto.java index 47a2f9673fe..f30fb1a5ff5 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDto.java @@ -32,7 +32,7 @@ public final class SnapshotDto { */ public static final String STATUS_UNPROCESSED = "U"; public static final String STATUS_PROCESSED = "P"; - public static final int MAX_VERSION_LENGTH = 100; + private static final int MAX_VERSION_LENGTH = 100; private Long id; private String uuid; @@ -42,7 +42,7 @@ public final class SnapshotDto { private String status = STATUS_UNPROCESSED; private Integer purgeStatus; private Boolean last; - private String version; + private String codePeriodVersion; private String periodMode; private String periodParam; private Long periodDate; @@ -115,24 +115,24 @@ public final class SnapshotDto { * Version is only available on projects and modules */ @CheckForNull - public String getVersion() { - return version; + public String getCodePeriodVersion() { + return codePeriodVersion; } - public SnapshotDto setVersion(@Nullable String version) { - if (version != null) { - checkArgument(version.length() <= MAX_VERSION_LENGTH, - "Event name length (%s) is longer than the maximum authorized (%s). '%s' was provided.", version.length(), MAX_VERSION_LENGTH, version); + public SnapshotDto setCodePeriodVersion(@Nullable String codePeriodVersion) { + if (codePeriodVersion != null) { + checkArgument(codePeriodVersion.length() <= MAX_VERSION_LENGTH, + "Event name length (%s) is longer than the maximum authorized (%s). '%s' was provided.", codePeriodVersion.length(), MAX_VERSION_LENGTH, codePeriodVersion); } - this.version = version; + this.codePeriodVersion = codePeriodVersion; return this; } /** * Used by MyBatis */ - private void setRawVersion(@Nullable String version) { - this.version = version; + private void setRawCodePeriodVersion(@Nullable String codePeriodVersion) { + this.codePeriodVersion = codePeriodVersion; } public SnapshotDto setPeriodMode(@Nullable String p) { @@ -194,7 +194,7 @@ public final class SnapshotDto { Objects.equals(status, that.status) && Objects.equals(purgeStatus, that.purgeStatus) && Objects.equals(last, that.last) && - Objects.equals(version, that.version) && + Objects.equals(codePeriodVersion, that.codePeriodVersion) && Objects.equals(periodMode, that.periodMode) && Objects.equals(periodParam, that.periodParam) && Objects.equals(periodDate, that.periodDate); @@ -202,7 +202,7 @@ public final class SnapshotDto { @Override public int hashCode() { - return Objects.hash(id, uuid, componentUuid, createdAt, buildDate, status, purgeStatus, last, version, periodMode, periodParam, periodDate); + return Objects.hash(id, uuid, componentUuid, createdAt, buildDate, status, purgeStatus, last, codePeriodVersion, periodMode, periodParam, periodDate); } @Override @@ -216,7 +216,7 @@ public final class SnapshotDto { ", status='" + status + '\'' + ", purgeStatus=" + purgeStatus + ", last=" + last + - ", version='" + version + '\'' + + ", codePeriodVersion='" + codePeriodVersion + '\'' + ", periodMode='" + periodMode + '\'' + ", periodParam='" + periodParam + '\'' + ", periodDate=" + periodDate + diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotQuery.java index 774b86485ab..4b11d588913 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotQuery.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotQuery.java @@ -46,7 +46,7 @@ public final class SnapshotQuery { private Long createdAfter; private Long createdBefore; private String status; - private String version; + private String codePeriodVersion; private Boolean isLast; private String sortField; private String sortOrder; @@ -108,12 +108,12 @@ public final class SnapshotQuery { } @CheckForNull - public String getVersion() { - return version; + public String getCodePeriodVersion() { + return codePeriodVersion; } - public SnapshotQuery setVersion(@Nullable String version) { - this.version = version; + public SnapshotQuery setCodePeriodVersion(@Nullable String codePeriodVersion) { + this.codePeriodVersion = codePeriodVersion; return this; } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml index d5e8bca8378..15d242471ab 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml @@ -11,7 +11,7 @@ s.status as status, s.purge_status as purgeStatus, s.islast as last, - s.version as rawVersion, + s.version as rawCodePeriodVersion, s.period1_mode as periodMode, s.period1_param as periodParam, s.period1_date as periodDate @@ -72,8 +72,8 @@ <if test="query.status != null"> AND s.status=#{query.status,jdbcType=VARCHAR} </if> - <if test="query.version != null"> - AND s.version=#{query.version,jdbcType=VARCHAR} + <if test="query.codePeriodVersion != null"> + AND s.version=#{query.codePeriodVersion,jdbcType=VARCHAR} </if> <if test="query.isLast != null"> AND s.islast=#{query.isLast} @@ -151,7 +151,7 @@ <update id="update" parameterType="Snapshot"> update snapshots - set version = #{version, jdbcType=VARCHAR}, + set version = #{codePeriodVersion, jdbcType=VARCHAR}, status = #{status, jdbcType=VARCHAR} where uuid = #{uuid,jdbcType=VARCHAR} </update> @@ -177,7 +177,7 @@ #{status, jdbcType=VARCHAR}, #{purgeStatus, jdbcType=INTEGER}, #{last, jdbcType=BOOLEAN}, - #{version, jdbcType=VARCHAR}, + #{codePeriodVersion, jdbcType=VARCHAR}, #{periodMode, jdbcType=VARCHAR}, #{periodParam, jdbcType=VARCHAR}, #{periodDate, jdbcType=BIGINT}) diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java index 71c08ac9c0b..575e4ad2067 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java @@ -76,7 +76,7 @@ public class SnapshotDaoTest { .setPeriodMode("days") .setPeriodParam("30") .setPeriodDate(1500000000001L) - .setVersion("2.1-SNAPSHOT") + .setCodePeriodVersion("2.1-SNAPSHOT") .setBuildDate(1500000000006L) .setCreatedAt(1403042400000L)); @@ -87,13 +87,13 @@ public class SnapshotDaoTest { assertThat(result.getStatus()).isEqualTo("P"); assertThat(result.getLast()).isTrue(); assertThat(result.getPurgeStatus()).isEqualTo(1); - assertThat(result.getVersion()).isEqualTo("2.1-SNAPSHOT"); + assertThat(result.getCodePeriodVersion()).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.getCodePeriodVersion()).isEqualTo("2.1-SNAPSHOT"); assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST").isPresent()).isFalse(); } @@ -288,7 +288,7 @@ public class SnapshotDaoTest { .setPeriodMode("days") .setPeriodParam("30") .setPeriodDate(1500000000001L) - .setVersion("2.1-SNAPSHOT") + .setCodePeriodVersion("2.1-SNAPSHOT") .setBuildDate(1500000000006L) .setCreatedAt(1403042400000L)); @@ -303,7 +303,7 @@ public class SnapshotDaoTest { assertThat(dto.getPeriodDate()).isEqualTo(1500000000001L); assertThat(dto.getBuildDate()).isEqualTo(1500000000006L); assertThat(dto.getCreatedAt()).isEqualTo(1403042400000L); - assertThat(dto.getVersion()).isEqualTo("2.1-SNAPSHOT"); + assertThat(dto.getCodePeriodVersion()).isEqualTo("2.1-SNAPSHOT"); } @@ -375,13 +375,13 @@ public class SnapshotDaoTest { db.commit(); analysis .setComponentUuid("P42") - .setVersion("5.6.3") + .setCodePeriodVersion("5.6.3") .setStatus(STATUS_UNPROCESSED); underTest.update(dbSession, analysis); SnapshotDto result = underTest.selectByUuid(dbSession, "A1").get(); - assertThat(result.getVersion()).isEqualTo("5.6.3"); + assertThat(result.getCodePeriodVersion()).isEqualTo("5.6.3"); assertThat(result.getStatus()).isEqualTo(STATUS_UNPROCESSED); assertThat(result.getComponentUuid()).isEqualTo("P1"); } @@ -395,7 +395,7 @@ public class SnapshotDaoTest { db.commit(); assertThat(underTest.selectByUuid(dbSession, analysis.getUuid()) - .map(SnapshotDto::getVersion)) + .map(SnapshotDto::getCodePeriodVersion)) .contains(tooLongVersion); } @@ -422,7 +422,7 @@ public class SnapshotDaoTest { .setStatus("P") .setLast(true) .setPurgeStatus(1) - .setVersion("2.1-SNAPSHOT") + .setCodePeriodVersion("2.1-SNAPSHOT") .setPeriodMode("days1") .setPeriodParam("30") .setPeriodDate(1_500_000_000_001L) diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java index 669dac0897a..b57b9dd068c 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDtoTest.java @@ -39,7 +39,7 @@ public class SnapshotDtoTest { .setBuildDate(parseDate("2014-07-02").getTime()) .setComponentUuid("uuid_21") .setLast(true) - .setVersion("1.0") + .setCodePeriodVersion("1.0") .setPeriodMode("mode1") .setPeriodParam("param1") .setPeriodDate(parseDate("2014-06-01").getTime()); @@ -48,7 +48,7 @@ public class SnapshotDtoTest { 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.getCodePeriodVersion()).isEqualTo("1.0"); assertThat(snapshotDto.getPeriodMode()).isEqualTo("mode1"); assertThat(snapshotDto.getPeriodModeParameter()).isEqualTo("param1"); assertThat(snapshotDto.getPeriodDate()).isEqualTo(parseDate("2014-06-01").getTime()); @@ -57,14 +57,14 @@ public class SnapshotDtoTest { @Test public void fail_if_version_name_is_longer_then_100_characters() { SnapshotDto snapshotDto = new SnapshotDto(); - snapshotDto.setVersion(null); - snapshotDto.setVersion("1.0"); - snapshotDto.setVersion(repeat("a", 100)); + snapshotDto.setCodePeriodVersion(null); + snapshotDto.setCodePeriodVersion("1.0"); + snapshotDto.setCodePeriodVersion(repeat("a", 100)); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Event name length (101) is longer than the maximum authorized (100). " + "'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' was provided."); - snapshotDto.setVersion(repeat("a", 101)); + snapshotDto.setCodePeriodVersion(repeat("a", 101)); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotQueryTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotQueryTest.java index a7be08411d8..95ab68f9107 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotQueryTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotQueryTest.java @@ -33,7 +33,7 @@ public class SnapshotQueryTest { .setComponentUuid("abcd") .setIsLast(true) .setStatus("P") - .setVersion("1.0") + .setCodePeriodVersion("1.0") .setCreatedAfter(10L) .setCreatedBefore(20L) .setSort(BY_DATE, ASC); @@ -41,7 +41,7 @@ public class SnapshotQueryTest { assertThat(query.getComponentUuid()).isEqualTo("abcd"); assertThat(query.getIsLast()).isTrue(); assertThat(query.getStatus()).isEqualTo("P"); - assertThat(query.getVersion()).isEqualTo("1.0"); + assertThat(query.getCodePeriodVersion()).isEqualTo("1.0"); assertThat(query.getCreatedAfter()).isEqualTo(10L); assertThat(query.getCreatedBefore()).isEqualTo(20L); assertThat(query.getSortField()).isEqualTo("created_at"); |