aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-26 16:27:24 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-02-29 13:26:54 +0100
commitbcb58ffd908080e9976ac5acdc5ad9f2b0fa3192 (patch)
tree35f37849707936976cb26a442e76a64d186c0f70 /sonar-db
parent25c379d3e6620bd94d77c8990d14640941baed00 (diff)
downloadsonarqube-bcb58ffd908080e9976ac5acdc5ad9f2b0fa3192.tar.gz
sonarqube-bcb58ffd908080e9976ac5acdc5ad9f2b0fa3192.zip
SONAR-7330 Update date columns of rules and active_rules
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java20
-rw-r--r--sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java20
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java9
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java54
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java54
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml14
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml14
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql5
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl12
-rw-r--r--sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java14
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java51
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java51
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml9
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectNonManual.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/select_parameters_by_rule_key.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml9
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update.xml3
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter-result.xml2
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter.xml2
23 files changed, 285 insertions, 78 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java b/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
index 0112420c6c7..2b4613889bb 100644
--- a/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
@@ -41,8 +41,8 @@ public class ActiveRuleDto {
private Integer severity;
private String inheritance;
- private long createdAtInMs;
- private long updatedAtInMs;
+ private long createdAt;
+ private long updatedAt;
// These fields do not exists in db, it's only retrieve by joins
private Integer parentId;
@@ -139,21 +139,21 @@ public class ActiveRuleDto {
return StringUtils.equals(OVERRIDES, inheritance);
}
- public long getUpdatedAtInMs() {
- return updatedAtInMs;
+ public long getUpdatedAt() {
+ return updatedAt;
}
- public ActiveRuleDto setUpdatedAtInMs(long updatedAtInMs) {
- this.updatedAtInMs = updatedAtInMs;
+ public ActiveRuleDto setUpdatedAt(long updatedAt) {
+ this.updatedAt = updatedAt;
return this;
}
- public long getCreatedAtInMs() {
- return createdAtInMs;
+ public long getCreatedAt() {
+ return createdAt;
}
- public ActiveRuleDto setCreatedAtInMs(long createdAtInMs) {
- this.createdAtInMs = createdAtInMs;
+ public ActiveRuleDto setCreatedAt(long createdAt) {
+ this.createdAt = createdAt;
return this;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java b/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java
index 3bf350b777c..22ed140485f 100644
--- a/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java
@@ -74,8 +74,8 @@ public class RuleDto {
private RuleKey key;
- private long createdAtInMs;
- private long updatedAtInMs;
+ private long createdAt;
+ private long updatedAt;
public RuleKey getKey() {
if (key == null) {
@@ -378,21 +378,21 @@ public class RuleDto {
return this;
}
- public long getCreatedAtInMs() {
- return createdAtInMs;
+ public long getCreatedAt() {
+ return createdAt;
}
- public RuleDto setCreatedAtInMs(long createdAt) {
- this.createdAtInMs = createdAt;
+ public RuleDto setCreatedAt(long createdAt) {
+ this.createdAt = createdAt;
return this;
}
- public long getUpdatedAtInMs() {
- return updatedAtInMs;
+ public long getUpdatedAt() {
+ return updatedAt;
}
- public RuleDto setUpdatedAtInMs(long updatedAt) {
- this.updatedAtInMs = updatedAt;
+ public RuleDto setUpdatedAt(long updatedAt) {
+ this.updatedAt = updatedAt;
return this;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
index 744620671a6..67e20f40c64 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
@@ -29,7 +29,7 @@ import org.sonar.db.MyBatis;
public class DatabaseVersion {
- public static final int LAST_VERSION = 1107;
+ public static final int LAST_VERSION = 1111;
/**
* The minimum supported version which can be upgraded. Lower
diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
index b4d9ac00205..6859cac4175 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
@@ -72,8 +72,10 @@ import org.sonar.db.version.v54.RemovePreviewPermission;
import org.sonar.db.version.v55.AddActiveRulesLongDateColumns;
import org.sonar.db.version.v55.AddIssuesType;
import org.sonar.db.version.v55.AddRulesLongDateColumns;
-import org.sonar.db.version.v55.FeedActiveRulesLongDateColumns;
import org.sonar.db.version.v55.DeleteMeasuresWithCharacteristicId;
+import org.sonar.db.version.v55.DropActiveRulesDateColumns;
+import org.sonar.db.version.v55.DropRulesDateColumns;
+import org.sonar.db.version.v55.FeedActiveRulesLongDateColumns;
import org.sonar.db.version.v55.FeedIssueTypes;
import org.sonar.db.version.v55.FeedRulesLongDateColumns;
@@ -148,9 +150,10 @@ public class MigrationStepModule extends Module {
DeleteMeasuresWithCharacteristicId.class,
AddActiveRulesLongDateColumns.class,
FeedActiveRulesLongDateColumns.class,
- DeleteMeasuresWithCharacteristicId.class,
AddIssuesType.class,
- FeedIssueTypes.class
+ FeedIssueTypes.class,
+ DropRulesDateColumns.class,
+ DropActiveRulesDateColumns.class
);
}
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java
new file mode 100644
index 00000000000..73d48056fde
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.version.v55;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropColumnsBuilder;
+
+/**
+ * Drop the following columns from the active_rules table :
+ * - created_at
+ * - updated_at
+ */
+public class DropActiveRulesDateColumns extends DdlChange {
+
+ private final Database db;
+
+ public DropActiveRulesDateColumns(Database db) {
+ super(db);
+ this.db = db;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(generateSql());
+ }
+
+ @VisibleForTesting
+ String generateSql() {
+ return new DropColumnsBuilder(db.getDialect(), "active_rules",
+ "created_at", "updated_at")
+ .build();
+ }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java
new file mode 100644
index 00000000000..38f440cda5b
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.version.v55;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropColumnsBuilder;
+
+/**
+ * Drop the following columns from the rules table :
+ * - created_at
+ * - updated_at
+ */
+public class DropRulesDateColumns extends DdlChange {
+
+ private final Database db;
+
+ public DropRulesDateColumns(Database db) {
+ super(db);
+ this.db = db;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ context.execute(generateSql());
+ }
+
+ @VisibleForTesting
+ String generateSql() {
+ return new DropColumnsBuilder(db.getDialect(), "rules",
+ "created_at", "updated_at")
+ .build();
+ }
+
+}
diff --git a/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml b/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml
index a79f5e4103e..17e6aa4a274 100644
--- a/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml
@@ -12,8 +12,8 @@
r.plugin_rule_key as "rulefield",
r.plugin_name as "repository",
qp.kee as "profileKey",
- a.created_at_ms as "createdAtInMs",
- a.updated_at_ms as "updatedAtInMs"
+ a.created_at as "createdAt",
+ a.updated_at as "updatedAt"
</sql>
<sql id="activeRuleKeyJoin">
@@ -29,8 +29,8 @@
a.failure_level as severity,
a.inheritance as inheritance,
active_rule_parent.id as parentId,
- a.created_at_ms as "createdAtInMs",
- a.updated_at_ms as "updatedAtInMs"
+ a.created_at as "createdAt",
+ a.updated_at as "updatedAt"
</sql>
<!-- Should be removed when ActiveRuleDao v2 will be removed -->
@@ -54,8 +54,8 @@
</select>
<insert id="insert" parameterType="ActiveRule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO active_rules (profile_id, rule_id, failure_level, inheritance, created_at_ms, updated_at_ms)
- VALUES (#{profileId}, #{ruleId}, #{severity}, #{inheritance}, #{createdAtInMs}, #{updatedAtInMs})
+ INSERT INTO active_rules (profile_id, rule_id, failure_level, inheritance, created_at, updated_at)
+ VALUES (#{profileId}, #{ruleId}, #{severity}, #{inheritance}, #{createdAt}, #{updatedAt})
</insert>
<update id="update" parameterType="ActiveRule">
@@ -64,7 +64,7 @@
rule_id=#{ruleId},
failure_level=#{severity},
inheritance=#{inheritance},
- updated_at_ms=#{updatedAtInMs}
+ updated_at=#{updatedAt}
WHERE id=#{id}
</update>
diff --git a/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml b/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
index 4d98081a923..3492b3e79ff 100644
--- a/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
@@ -31,8 +31,8 @@
r.effort_to_fix_description as "effortToFixDescription",
r.tags as "tagsField",
r.system_tags as "systemTagsField",
- r.created_at_ms as "createdAtInMs",
- r.updated_at_ms as "updatedAtInMs"
+ r.created_at as "createdAt",
+ r.updated_at as "updatedAt"
</sql>
<select id="selectAll" resultType="Rule">
@@ -127,7 +127,7 @@
AND r.plugin_config_key = #{query.configKey}
</if>
</where>
- ORDER BY r.updated_at_ms DESC
+ ORDER BY r.updated_at DESC
</select>
<update id="update" parameterType="Rule">
@@ -158,7 +158,7 @@
effort_to_fix_description=#{effortToFixDescription},
tags=#{tagsField},
system_tags=#{systemTagsField},
- updated_at_ms=#{updatedAtInMs}
+ updated_at=#{updatedAt}
WHERE id=#{id}
</update>
@@ -168,7 +168,7 @@
characteristic_id, default_characteristic_id, remediation_function, default_remediation_function,
remediation_coeff, default_remediation_coeff, remediation_offset, default_remediation_offset,
effort_to_fix_description, tags, system_tags, note_data, note_user_login, note_created_at, note_updated_at,
- created_at_ms, updated_at_ms)
+ created_at, updated_at)
</sql>
<insert id="insert" parameterType="Rule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
@@ -179,7 +179,7 @@
#{subCharacteristicId}, #{defaultSubCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
#{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset},
#{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt},
- #{noteUpdatedAt}, #{createdAtInMs}, #{updatedAtInMs})
+ #{noteUpdatedAt}, #{createdAt}, #{updatedAt})
</insert>
<insert id="batchInsert" parameterType="Rule" useGeneratedKeys="false">
@@ -196,7 +196,7 @@
#{remediationOffset,jdbcType=VARCHAR}, #{defaultRemediationOffset,jdbcType=VARCHAR},
#{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt},
#{noteUpdatedAt,jdbcType=TIMESTAMP},
- #{createdAtInMs,jdbcType=BIGINT}, #{updatedAtInMs,jdbcType=BIGINT}
+ #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}
)
</insert>
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
index 4ecc1757f51..d8da5b65e7f 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
+++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
@@ -383,7 +383,12 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1102');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1103');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1104');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1105');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1106');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1107');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1108');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1109');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1110');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1111');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
index bedb09a40c6..93c5661b02a 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
+++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
@@ -124,10 +124,8 @@ CREATE TABLE "RULES" (
"EFFORT_TO_FIX_DESCRIPTION" VARCHAR(4000),
"TAGS" VARCHAR(4000),
"SYSTEM_TAGS" VARCHAR(4000),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "CREATED_AT_MS" BIGINT,
- "UPDATED_AT_MS" BIGINT
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT
);
@@ -262,10 +260,8 @@ CREATE TABLE "ACTIVE_RULES" (
"RULE_ID" INTEGER NOT NULL,
"FAILURE_LEVEL" INTEGER NOT NULL,
"INHERITANCE" VARCHAR(10),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "CREATED_AT_MS" BIGINT,
- "UPDATED_AT_MS" BIGINT
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT
);
CREATE TABLE "NOTIFICATIONS" (
diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
index 28208807e43..8da2677ea43 100644
--- a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
@@ -223,8 +223,8 @@ public class RuleDaoTest {
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
- .setCreatedAtInMs(1500000000000L)
- .setUpdatedAtInMs(2000000000000L);
+ .setCreatedAt(1500000000000L)
+ .setUpdatedAt(2000000000000L);
underTest.insert(dbTester.getSession(), newRule);
dbTester.getSession().commit();
@@ -252,8 +252,8 @@ public class RuleDaoTest {
assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min");
assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h");
assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix");
- assertThat(ruleDto.getCreatedAtInMs()).isEqualTo(1500000000000L);
- assertThat(ruleDto.getUpdatedAtInMs()).isEqualTo(2000000000000L);
+ assertThat(ruleDto.getCreatedAt()).isEqualTo(1500000000000L);
+ assertThat(ruleDto.getUpdatedAt()).isEqualTo(2000000000000L);
}
@Test
@@ -284,7 +284,7 @@ public class RuleDaoTest {
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
- .setUpdatedAtInMs(2000000000000L);
+ .setUpdatedAt(2000000000000L);
underTest.update(dbTester.getSession(), ruleToUpdate);
dbTester.getSession().commit();
@@ -312,8 +312,8 @@ public class RuleDaoTest {
assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min");
assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h");
assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix");
- assertThat(ruleDto.getCreatedAtInMs()).isEqualTo(1500000000000L);
- assertThat(ruleDto.getUpdatedAtInMs()).isEqualTo(2000000000000L);
+ assertThat(ruleDto.getCreatedAt()).isEqualTo(1500000000000L);
+ assertThat(ruleDto.getUpdatedAt()).isEqualTo(2000000000000L);
}
@Test
diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
index e81f6085362..8de7b00ca97 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
public void verify_count_of_added_MigrationStep_types() {
ComponentContainer container = new ComponentContainer();
new MigrationStepModule().configure(container);
- assertThat(container.size()).isEqualTo(56);
+ assertThat(container.size()).isEqualTo(60);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java
new file mode 100644
index 00000000000..29b2bf5e56c
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.version.v55;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.db.Database;
+import org.sonar.db.dialect.PostgreSql;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DropActiveRulesDateColumnsTest {
+
+ DropActiveRulesDateColumns migration;
+
+ Database database;
+
+ @Before
+ public void setUp() {
+ database = mock(Database.class);
+ migration = new DropActiveRulesDateColumns(database);
+ }
+
+ @Test
+ public void generate_sql_on_postgresql() {
+ when(database.getDialect()).thenReturn(new PostgreSql());
+ assertThat(migration.generateSql()).isEqualTo(
+ "ALTER TABLE active_rules DROP COLUMN created_at, DROP COLUMN updated_at"
+ );
+ }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java
new file mode 100644
index 00000000000..f05eda3ea48
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.version.v55;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.db.Database;
+import org.sonar.db.dialect.PostgreSql;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DropRulesDateColumnsTest {
+
+ DropRulesDateColumns migration;
+
+ Database database;
+
+ @Before
+ public void setUp() {
+ database = mock(Database.class);
+ migration = new DropRulesDateColumns(database);
+ }
+
+ @Test
+ public void generate_sql_on_postgresql() {
+ when(database.getDialect()).thenReturn(new PostgreSql());
+ assertThat(migration.generateSql()).isEqualTo(
+ "ALTER TABLE rules DROP COLUMN created_at, DROP COLUMN updated_at"
+ );
+ }
+
+}
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml
index 423fc21f0c0..497ceafcf7f 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml
@@ -1,13 +1,13 @@
<dataset>
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
- plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-17" template_id="3"
+ plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3"
note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
characteristic_id="100" default_characteristic_id="101"
remediation_function="linear" default_remediation_function="linear_offset"
remediation_coeff="1h" default_remediation_coeff="5d"
remediation_offset="5min" default_remediation_offset="10h"
effort_to_fix_description="squid.S115.effortToFix"
- created_at_ms="[null]" updated_at_ms="[null]"
+ created_at="[null]" updated_at="[null]"
/>
<rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml
index de4e4e969ca..75036a0b316 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml
@@ -1,12 +1,12 @@
<dataset>
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
- plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-17" template_id="3"
+ plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3"
note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
characteristic_id="100" default_characteristic_id="101"
remediation_function="linear" default_remediation_function="linear_offset"
remediation_coeff="1h" default_remediation_coeff="5d"
remediation_offset="5min" default_remediation_offset="10h"
effort_to_fix_description="squid.S115.effortToFix"
- created_at_ms="[null]" updated_at_ms="[null]"
+ created_at="[null]" updated_at="[null]"
/>
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml
index 59a8dae0f4f..1ae601a67ab 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml
@@ -7,8 +7,7 @@
remediation_coeff="1h" default_remediation_coeff="5d"
remediation_offset="5min" default_remediation_offset="10h"
effort_to_fix_description="squid.S115.effortToFix"
- created_at="2014-05-10" updated_at="2014-05-11"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"
+ created_at="1500000000000" updated_at="1600000000000"
/>
<rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="squid" name="Avoid Null" description="Should avoid NULL" status="REMOVED"
@@ -18,8 +17,7 @@
remediation_coeff="[null]" default_remediation_coeff="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
effort_to_fix_description="[null]"
- created_at="2014-05-10" updated_at="2014-05-11"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"
+ created_at="1500000000000" updated_at="1600000000000"
/>
<rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule" description="Should not appear" status="READY"
@@ -29,8 +27,7 @@
remediation_coeff="[null]" default_remediation_coeff="[null]"
remediation_offset="[null]" default_remediation_offset="[null]"
effort_to_fix_description="[null]"
- created_at="2014-05-10" updated_at="2014-05-11"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"
+ created_at="1500000000000" updated_at="1600000000000"
/>
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectNonManual.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectNonManual.xml
index f76ce5c6545..f4c6a9bc32f 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectNonManual.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectNonManual.xml
@@ -2,9 +2,9 @@
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
<rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule"
description="Should not appear" status="READY" description_format="HTML"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/select_parameters_by_rule_key.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/select_parameters_by_rule_key.xml
index 079e238d48c..65d9b4e5a45 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/select_parameters_by_rule_key.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/select_parameters_by_rule_key.xml
@@ -2,13 +2,13 @@
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
name="Avoid Null" description="Should avoid NULL" status="READY"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
<rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
description="My Parameter"/>
<rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule"
description="Not used" status="REMOVED"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
<rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
description="Other Parameter"/>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
index 94c54d47437..c4d8d267be2 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
@@ -4,24 +4,21 @@
plugin_config_key="S1" plugin_name="java" description="[null]" priority="4" status="READY"
is_template="[false]" template_id="[null]"
tags="bug,performance" system_tags="cwe"
- created_at="2014-05-10" updated_at="2014-05-11"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"
+ created_at="1500000000000" updated_at="1600000000000"
/>
<rules id="2" name="Slow" plugin_rule_key="S002"
plugin_config_key="S2" plugin_name="java" description="[null]" priority="4" status="BETA"
is_template="[false]" template_id="[null]"
tags="[null]" system_tags="[null]"
- created_at="2014-05-10" updated_at="2014-05-11"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"
+ created_at="1500000000000" updated_at="1600000000000"
/>
<rules id="10" name="Removed" plugin_rule_key="S003"
plugin_config_key="S3" plugin_name="java" description="[null]" priority="4" status="REMOVED"
is_template="[false]" template_id="[null]"
tags="[null]" system_tags="[null]"
- created_at="2014-05-10" updated_at="2014-05-11"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"
+ created_at="1500000000000" updated_at="1600000000000"
/>
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update.xml
index b80cd56461f..c75cc533f11 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update.xml
@@ -3,7 +3,6 @@
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
name="Avoid Null" description="Should avoid NULL" status="READY"
plugin_config_key="AvoidNull" priority="2" is_template="[false]" language="golo"
- created_at="2011-04-25 01:05:00" template_id="2" description_format="HTML"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter-result.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter-result.xml
index e60f87e31b3..3907b7d23c6 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter-result.xml
@@ -1,7 +1,7 @@
<dataset>
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
name="Avoid Null" description="Should avoid NULL" status="READY"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
<rules_parameters id="1" rule_id="1" name="max" param_type="STRING" default_value="^[a-z]+(\.[a-z][a-z0-9]*)*$"
description="Regular expression used to check the package names against."/>
diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter.xml
index 8ac19218587..2eb61cc7029 100644
--- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter.xml
@@ -1,7 +1,7 @@
<dataset>
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
name="Avoid Null" description="Should avoid NULL" status="READY"
- created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+ created_at="1500000000000" updated_at="1600000000000"/>
<rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
</dataset>