diff options
61 files changed, 501 insertions, 179 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java index 1f308137e0a..997fb701a8f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java @@ -158,7 +158,7 @@ public class DebtModelBackup { rule.setRemediationFunction(null); rule.setRemediationCoefficient(null); rule.setRemediationOffset(null); - rule.setUpdatedAtInMs(updateDate.getTime()); + rule.setUpdatedAt(updateDate.getTime()); dbClient.ruleDao().update(session, rule); } } @@ -205,7 +205,7 @@ public class DebtModelBackup { ruleDebt != null ? ruleDebt.function() : null, ruleDebt != null ? ruleDebt.coefficient() : null, ruleDebt != null ? ruleDebt.offset() : null, session); - rule.setUpdatedAtInMs(updateDate.getTime()); + rule.setUpdatedAt(updateDate.getTime()); ruleDebts.remove(ruleDebt); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index a278611705f..6c2b8422e01 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -257,8 +257,8 @@ public class RuleActivator { if (inheritance != null) { activeRule.setInheritance(inheritance.name()); } - activeRule.setUpdatedAtInMs(system2.now()); - activeRule.setCreatedAtInMs(system2.now()); + activeRule.setUpdatedAt(system2.now()); + activeRule.setCreatedAt(system2.now()); dao.insert(dbSession, activeRule); for (Map.Entry<String, String> param : change.getParameters().entrySet()) { if (param.getValue() != null) { @@ -282,7 +282,7 @@ public class RuleActivator { if (inheritance != null) { activeRule.setInheritance(inheritance.name()); } - activeRule.setUpdatedAtInMs(system2.now()); + activeRule.setUpdatedAt(system2.now()); dao.update(dbSession, activeRule); for (Map.Entry<String, String> param : change.getParameters().entrySet()) { @@ -506,7 +506,7 @@ public class RuleActivator { changes.addAll(deactivate(dbSession, activeRule.getKey(), true)); } else if (ActiveRuleDto.OVERRIDES.equals(activeRule.getInheritance())) { activeRule.setInheritance(null); - activeRule.setUpdatedAtInMs(system2.now()); + activeRule.setUpdatedAt(system2.now()); db.activeRuleDao().update(dbSession, activeRule); changes.add(ActiveRuleChange.createFor(ActiveRuleChange.Type.UPDATED, activeRule.getKey()).setInheritance(null)); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java index 1b262701eb9..5b5e944a84c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java @@ -44,8 +44,8 @@ public class ActiveRuleResultSetIterator extends ResultSetIterator<ActiveRuleDoc "r.plugin_name", "qp.kee", "profile_parent.kee", - "a.created_at_ms", - "a.updated_at_ms" + "a.created_at", + "a.updated_at" }; private static final String SQL_ALL = "SELECT " + StringUtils.join(FIELDS, ",") + " FROM active_rules a " + @@ -53,7 +53,7 @@ public class ActiveRuleResultSetIterator extends ResultSetIterator<ActiveRuleDoc "INNER JOIN rules r ON r.id = a.rule_id " + "LEFT JOIN rules_profiles profile_parent ON profile_parent.kee=qp.parent_kee "; - private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE a.updated_at_ms>?"; + private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE a.updated_at>?"; private ActiveRuleResultSetIterator(PreparedStatement stmt) throws SQLException { super(stmt); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java b/server/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java index d6aaa74bcfc..91bf2feba74 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java @@ -175,8 +175,8 @@ public class DefaultRuleFinder implements RuleFinder { .setKey(rule.getRuleKey()) .setConfigKey(rule.getConfigKey()) .setIsTemplate(rule.isTemplate()) - .setCreatedAt(new Date(rule.getCreatedAtInMs())) - .setUpdatedAt(new Date(rule.getUpdatedAtInMs())) + .setCreatedAt(new Date(rule.getCreatedAt())) + .setUpdatedAt(new Date(rule.getUpdatedAt())) .setRepositoryKey(rule.getRepositoryKey()) .setSeverity(severity != null ? RulePriority.valueOf(severity) : null) .setStatus(rule.getStatus().name()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index 03f4b64f31b..291e6fe2916 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -171,8 +171,8 @@ public class RegisterRules implements Startable { .setStatus(ruleDef.status()) .setEffortToFixDescription(ruleDef.effortToFixDescription()) .setSystemTags(ruleDef.tags()) - .setCreatedAtInMs(system2.now()) - .setUpdatedAtInMs(system2.now()); + .setCreatedAt(system2.now()) + .setUpdatedAt(system2.now()); if (ruleDef.htmlDescription() != null) { ruleDto.setDescription(ruleDef.htmlDescription()); ruleDto.setDescriptionFormat(Format.HTML); @@ -453,7 +453,7 @@ public class RegisterRules implements Startable { } private void update(DbSession session, RuleDto rule){ - rule.setUpdatedAtInMs(system2.now()); + rule.setUpdatedAt(system2.now()); dbClient.ruleDao().update(session, rule); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java index 1d0dacd9488..e5ad2a656e8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java @@ -215,8 +215,8 @@ public class RuleCreator { .setEffortToFixDescription(templateRuleDto.getEffortToFixDescription()) .setTags(templateRuleDto.getTags()) .setSystemTags(templateRuleDto.getSystemTags()) - .setCreatedAtInMs(system2.now()) - .setUpdatedAtInMs(system2.now()); + .setCreatedAt(system2.now()) + .setUpdatedAt(system2.now()); dbClient.ruleDao().insert(dbSession, ruleDto); for (RuleParamDto templateRuleParamDto : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, templateRuleDto.getKey())) { @@ -242,8 +242,8 @@ public class RuleCreator { .setDescriptionFormat(Format.MARKDOWN) .setSeverity(newRule.severity()) .setStatus(RuleStatus.READY) - .setCreatedAtInMs(system2.now()) - .setUpdatedAtInMs(system2.now()); + .setCreatedAt(system2.now()) + .setUpdatedAt(system2.now()); dbClient.ruleDao().insert(dbSession, ruleDto); return ruleKey; } @@ -254,7 +254,7 @@ public class RuleCreator { throw new ReactivationException(String.format("A removed rule with the key '%s' already exists", ruleDto.getKey().rule()), ruleDto.getKey()); } else { ruleDto.setStatus(RuleStatus.READY) - .setUpdatedAtInMs(system2.now()); + .setUpdatedAt(system2.now()); dbClient.ruleDao().update(dbSession, ruleDto); } } else { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java index 0ee0dd0d4a5..38a58b16d6a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java @@ -306,7 +306,7 @@ public class RuleUpdater { } private void update(DbSession session, RuleDto rule) { - rule.setUpdatedAtInMs(system.now()); + rule.setUpdatedAt(system.now()); dbClient.ruleDao().update(session, rule); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleResultSetIterator.java index cf223abe9f5..0dbcdfddc51 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleResultSetIterator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleResultSetIterator.java @@ -61,14 +61,14 @@ public class RuleResultSetIterator extends ResultSetIterator<RuleDoc> { "t.plugin_name", "r.plugin_config_key", "r.language", - "r.created_at_ms", - "r.updated_at_ms", + "r.created_at", + "r.updated_at", }; private static final String SQL_ALL = "SELECT " + StringUtils.join(FIELDS, ",") + " FROM rules r " + "LEFT OUTER JOIN rules t ON t.id=r.template_id"; - private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE r.updated_at_ms>?"; + private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE r.updated_at>?"; private static final Splitter TAGS_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java index 9b01137e134..bbb6cbf112a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java @@ -171,7 +171,7 @@ public class RuleMapper { private static void setCreatedAt(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set<String> fieldsToReturn) { if (shouldReturnField(fieldsToReturn, RuleNormalizer.RuleField.CREATED_AT)) { - ruleResponse.setCreatedAt(formatDateTime(ruleDto.getCreatedAtInMs())); + ruleResponse.setCreatedAt(formatDateTime(ruleDto.getCreatedAt())); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java b/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java index 49119d2f80f..ea1913020e6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java +++ b/server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java @@ -85,7 +85,7 @@ public class ClearRulesOverloadedDebt implements Startable { rule.setRemediationFunction(null); rule.setRemediationCoefficient(null); rule.setRemediationOffset(null); - rule.setUpdatedAtInMs(system2.now()); + rule.setUpdatedAt(system2.now()); dbClient.ruleDao().update(session, rule); countClearedRules++; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java index 68b6c1d78d7..5219db120d3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java @@ -257,12 +257,12 @@ public class DebtModelBackupTest { assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h"); assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min"); - assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime()); + assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); assertThat(rule.getRemediationFunction()).isNull(); assertThat(rule.getRemediationCoefficient()).isNull(); assertThat(rule.getRemediationOffset()).isNull(); - assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime()); + assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); } @Test @@ -299,7 +299,7 @@ public class DebtModelBackupTest { assertThat(rule.getDefaultRemediationFunction()).isNull(); assertThat(rule.getDefaultRemediationCoefficient()).isNull(); assertThat(rule.getDefaultRemediationOffset()).isNull(); - assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime()); + assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); } @Test @@ -343,12 +343,12 @@ public class DebtModelBackupTest { assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET"); assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h"); assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min"); - assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime()); + assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); assertThat(rule.getRemediationFunction()).isNull(); assertThat(rule.getRemediationCoefficient()).isNull(); assertThat(rule.getRemediationOffset()).isNull(); - assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime()); + assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime()); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java index 5f213e685ef..409e5a9191b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java @@ -1095,8 +1095,8 @@ public class RuleActivatorMediumTest { assertThat(activeRuleDto.getSeverityString()).isEqualTo(expectedSeverity); assertThat(activeRuleDto.getInheritance()).isEqualTo(expectedInheritance); // Dates should be set - assertThat(activeRuleDto.getCreatedAtInMs()).isNotNull(); - assertThat(activeRuleDto.getUpdatedAtInMs()).isNotNull(); + assertThat(activeRuleDto.getCreatedAt()).isNotNull(); + assertThat(activeRuleDto.getUpdatedAt()).isNotNull(); List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey()); assertThat(paramDtos).hasSize(expectedParams.size()); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java index cfcf852ebf4..45f38494334 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java @@ -157,7 +157,7 @@ public class ActiveRuleIndexerTest { QualityProfileDto profile = QualityProfileDto.createFor("qp").setLanguage("xoo").setName("profile"); dbTester.getDbClient().qualityProfileDao().insert(dbTester.getSession(), profile); ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity(Severity.BLOCKER) - .setCreatedAtInMs(yesterday).setUpdatedAtInMs(yesterday); + .setCreatedAt(yesterday).setUpdatedAt(yesterday); dbTester.getDbClient().activeRuleDao().insert(dbTester.getSession(), activeRule); dbTester.getSession().commit(); @@ -169,7 +169,7 @@ public class ActiveRuleIndexerTest { RuleDto rule2 = RuleTesting.newDto(RULE_KEY_2); dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), rule2); ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profile, rule2).setSeverity(Severity.CRITICAL) - .setCreatedAtInMs(now).setUpdatedAtInMs(now); + .setCreatedAt(now).setUpdatedAt(now); dbTester.getDbClient().activeRuleDao().insert(dbTester.getSession(), activeRule2); dbTester.getSession().commit(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java index 19e445b36d8..3e741a5ec51 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java @@ -146,8 +146,8 @@ public class InheritanceActionMediumTest { .setLanguage(lang) .setSeverity(Severity.BLOCKER) .setStatus(RuleStatus.READY) - .setUpdatedAtInMs(now) - .setCreatedAtInMs(now); + .setUpdatedAt(now) + .setCreatedAt(now); db.ruleDao().insert(session, rule); return rule; } @@ -156,8 +156,8 @@ public class InheritanceActionMediumTest { long now = new Date().getTime(); ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule) .setSeverity(rule.getSeverityString()) - .setUpdatedAtInMs(now) - .setCreatedAtInMs(now); + .setUpdatedAt(now) + .setCreatedAt(now); db.activeRuleDao().insert(session, activeRule); return activeRule; } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java index 0648192121a..bc2cdff1e47 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java @@ -324,13 +324,13 @@ public class RegisterRulesMediumTest { .setStatus(RuleStatus.READY) .setParameters(ImmutableMap.of("format", "txt"))); - Long updatedAt = ruleDao.selectOrFailByKey(dbSession, customRuleKey).getUpdatedAtInMs(); + Long updatedAt = ruleDao.selectOrFailByKey(dbSession, customRuleKey).getUpdatedAt(); register(rules); // Verify custom rule has been restore from the template RuleDto customRuleReloaded = ruleDao.selectOrFailByKey(dbSession, customRuleKey); - assertThat(customRuleReloaded.getUpdatedAtInMs()).isEqualTo(updatedAt); + assertThat(customRuleReloaded.getUpdatedAt()).isEqualTo(updatedAt); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index ae72e14747f..b5a617d1b91 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -104,8 +104,8 @@ public class RegisterRulesTest { assertThat(rule1.getSystemTags()).containsOnly("tag1", "tag2", "tag3"); assertThat(rule1.getConfigKey()).isEqualTo("config1"); assertThat(rule1.getStatus()).isEqualTo(RuleStatus.BETA); - assertThat(rule1.getCreatedAtInMs()).isEqualTo(DATE1.getTime()); - assertThat(rule1.getUpdatedAtInMs()).isEqualTo(DATE1.getTime()); + assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime()); + assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1.getTime()); assertThat(rule1.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name()); assertThat(rule1.getDefaultRemediationCoefficient()).isEqualTo("5d"); assertThat(rule1.getDefaultRemediationOffset()).isEqualTo("10h"); @@ -148,8 +148,8 @@ public class RegisterRulesTest { assertThat(rule1.getNoteData()).isEqualTo("user *note*"); assertThat(rule1.getNoteUserLogin()).isEqualTo("marius"); assertThat(rule1.getStatus()).isEqualTo(RuleStatus.READY); - assertThat(rule1.getCreatedAtInMs()).isEqualTo(DATE1.getTime()); - assertThat(rule1.getUpdatedAtInMs()).isEqualTo(DATE2.getTime()); + assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime()); + assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2.getTime()); // TODO check remediation function List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), RULE_KEY1); @@ -161,7 +161,7 @@ public class RegisterRulesTest { // rule2 has been removed -> status set to REMOVED but db row is not deleted RuleDto rule2 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY2); assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED); - assertThat(rule2.getUpdatedAtInMs()).isEqualTo(DATE2.getTime()); + assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2.getTime()); // rule3 has been created RuleDto rule3 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY3); @@ -273,8 +273,8 @@ public class RegisterRulesTest { execute(new FakeRepositoryV1()); RuleDto rule1 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY1); - assertThat(rule1.getCreatedAtInMs()).isEqualTo(DATE1.getTime()); - assertThat(rule1.getUpdatedAtInMs()).isEqualTo(DATE1.getTime()); + assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime()); + assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1.getTime()); } @Test @@ -306,7 +306,7 @@ public class RegisterRulesTest { // -> rule2 is still removed, but not update at DATE3 rule2 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY2); assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED); - assertThat(rule2.getUpdatedAtInMs()).isEqualTo(DATE2.getTime()); + assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2.getTime()); assertThat(ruleIndex.search(new RuleQuery(), new SearchOptions()).getIds()).containsOnly(RULE_KEY1, RULE_KEY3); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java index 086f4b29397..950423434b4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java @@ -688,8 +688,8 @@ public class RuleCreatorMediumTest { .setEffortToFixDescription("desc") .setTags(Sets.newHashSet("usertag1", "usertag2")) .setSystemTags(Sets.newHashSet("tag1", "tag4")) - .setCreatedAtInMs(new Date().getTime()) - .setUpdatedAtInMs(new Date().getTime()); + .setCreatedAt(new Date().getTime()) + .setUpdatedAt(new Date().getTime()); dao.insert(dbSession, templateRule); RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*"); dao.insertRuleParam(dbSession, templateRule, ruleParamDto); @@ -707,8 +707,8 @@ public class RuleCreatorMediumTest { .setDefaultRemediationCoefficient("1h") .setDefaultRemediationOffset("5min") .setEffortToFixDescription("desc") - .setCreatedAtInMs(new Date().getTime()) - .setUpdatedAtInMs(new Date().getTime()); + .setCreatedAt(new Date().getTime()) + .setUpdatedAt(new Date().getTime()); dao.insert(dbSession, templateRule); RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule) .setName("myIntegers").setType("INTEGER,multiple=true,values=1;2;3").setDescription("My Integers").setDefaultValue("1"); @@ -727,8 +727,8 @@ public class RuleCreatorMediumTest { .setDefaultRemediationCoefficient("1h") .setDefaultRemediationOffset("5min") .setEffortToFixDescription("desc") - .setCreatedAtInMs(new Date().getTime()) - .setUpdatedAtInMs(new Date().getTime()); + .setCreatedAt(new Date().getTime()) + .setUpdatedAt(new Date().getTime()); dao.insert(dbSession, templateRule); RuleParamDto ruleParam1Dto = RuleParamDto.createFor(templateRule) .setName("first").setType("INTEGER").setDescription("First integer").setDefaultValue("0"); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java index d77445a6f4f..a3c8a206f88 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java @@ -84,14 +84,14 @@ public class RuleIndexerTest { // Create and Index rule RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("xoo", "S001")) .setStatus(RuleStatus.READY) - .setUpdatedAtInMs(1000L); + .setUpdatedAt(1000L); dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), ruleDto); dbTester.getSession().commit(); indexer.index(); // Remove rule ruleDto.setStatus(RuleStatus.REMOVED); - ruleDto.setUpdatedAtInMs(2000L); + ruleDto.setUpdatedAt(2000L); dbTester.getDbClient().ruleDao().update(dbTester.getSession(), ruleDto); dbTester.getSession().commit(); indexer.index(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java index 5e7eb7b719d..79bd12c564b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java @@ -547,11 +547,11 @@ public class SearchActionMediumTest { public void available_since() throws Exception { Date since = new Date(); ruleDao.insert(dbSession, RuleTesting.newXooX1() - .setUpdatedAtInMs(since.getTime()) - .setCreatedAtInMs(since.getTime())); + .setUpdatedAt(since.getTime()) + .setCreatedAt(since.getTime())); ruleDao.insert(dbSession, RuleTesting.newXooX2() - .setUpdatedAtInMs(since.getTime()) - .setCreatedAtInMs(since.getTime())); + .setUpdatedAt(since.getTime()) + .setCreatedAt(since.getTime())); dbSession.commit(); dbSession.clearCache(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java index 684c0fd06c1..f6bc97fef8f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java @@ -90,12 +90,12 @@ public class ClearRulesOverloadedDebtTest { @Test public void not_update_rule_debt_not_overridden() throws Exception { RuleDto rule = insertRuleDto(RULE_KEY_1, null, null, null, null); - long updateAt = rule.getUpdatedAtInMs(); + long updateAt = rule.getUpdatedAt(); underTest.start(); RuleDto reloaded = ruleDao.selectOrFailByKey(dbSession, RULE_KEY_1); - assertThat(reloaded.getUpdatedAtInMs()).isEqualTo(updateAt); + assertThat(reloaded.getUpdatedAt()).isEqualTo(updateAt); verifyRuleHasNotOverriddenDebt(RULE_KEY_1); verifyTaskRegistered(); @@ -106,12 +106,12 @@ public class ClearRulesOverloadedDebtTest { public void not_update_rule_debt_when_sqale_is_installed() throws Exception { insertSqaleProperty(); RuleDto rule = insertRuleDto(RULE_KEY_1, SUB_CHARACTERISTIC_ID, "LINEAR", null, "1d"); - long updateAt = rule.getUpdatedAtInMs(); + long updateAt = rule.getUpdatedAt(); underTest.start(); RuleDto reloaded = ruleDao.selectOrFailByKey(dbSession, RULE_KEY_1); - assertThat(reloaded.getUpdatedAtInMs()).isEqualTo(updateAt); + assertThat(reloaded.getUpdatedAt()).isEqualTo(updateAt); verifyTaskRegistered(); verifyEmptyLog(); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/insert_new_issue.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/insert_new_issue.xml index 9f3a7f46ea4..b3228c223b1 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/insert_new_issue.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/insert_new_issue.xml @@ -9,7 +9,7 @@ remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="[null]" description_format="MARKDOWN" tags="[null]" system_tags="[null]" - created_at="2013-12-16" updated_at="2013-12-16" + created_at="1500000000000" updated_at="1500000000000" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml index a06f7a729e0..69125c85d93 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml @@ -9,7 +9,7 @@ remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="[null]" description_format="MARKDOWN" tags="[null]" system_tags="[null]" - created_at="2013-12-16" updated_at="2013-12-16" + created_at="1500000000000" updated_at="1500000000000" /> <issues diff --git a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml index b8d14359444..dd71fc74cee 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml @@ -16,8 +16,7 @@ remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN" - created_at="2013-12-16" updated_at="2013-12-16" - created_at_ms="150000" updated_at_ms="150000" + created_at="150000" updated_at="150000" /> <properties id="1" prop_key="sonar.profile.java" text_value="Sonar Way" resource_id="1" user_id="[null]"/> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest/index.xml index a2f2f9503f7..d2a59d2049c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest/index.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest/index.xml @@ -4,10 +4,10 @@ plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo" priority="4" status="READY" is_template="[false]" template_id="[null]" tags="bug,performance" system_tags="cwe" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <rules_profiles id="100" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/> <active_rules id="1" profile_id="100" rule_id="10" failure_level="3" inheritance="[null]" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_inherited_inheritance.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_inherited_inheritance.xml index 32aecb5f149..3a0f5ddb92d 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_inherited_inheritance.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_inherited_inheritance.xml @@ -4,17 +4,17 @@ plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo" priority="4" status="READY" is_template="[false]" template_id="[null]" tags="bug,performance" system_tags="cwe" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/> <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/> <active_rules id="1" profile_id="2" rule_id="10" failure_level="4" inheritance="INHERITED" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <!-- Parent of Active rule 1 --> <active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_overrides_inheritance.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_overrides_inheritance.xml index a20b455e9ef..b5a820cd459 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_overrides_inheritance.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_overrides_inheritance.xml @@ -4,17 +4,17 @@ plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo" priority="4" status="READY" is_template="[false]" template_id="[null]" tags="bug,performance" system_tags="cwe" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/> <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/> <active_rules id="1" profile_id="2" rule_id="10" failure_level="2" inheritance="OVERRIDES" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <!-- Parent of Active rule 1 --> <active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/one_active_rule.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/one_active_rule.xml index a2f2f9503f7..d2a59d2049c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/one_active_rule.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/one_active_rule.xml @@ -4,10 +4,10 @@ plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo" priority="4" status="READY" is_template="[false]" template_id="[null]" tags="bug,performance" system_tags="cwe" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <rules_profiles id="100" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/> <active_rules id="1" profile_id="100" rule_id="10" failure_level="3" inheritance="[null]" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/shared.xml index bda9c4da216..3e6062ccc97 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/shared.xml @@ -6,8 +6,7 @@ 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="11" name="Slow" plugin_rule_key="S002" plugin_config_key="S2" plugin_name="xoo" @@ -15,23 +14,22 @@ priority="3" status="BETA" is_template="[true]" template_id="[null]" tags="[null]" system_tags="[null]" - created_at="2014-05-10" updated_at="2014-05-11" - created_at_ms="2000000000000" updated_at_ms="2100000000000"/> + created_at="2000000000000" updated_at="2100000000000"/> <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/> <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/> <active_rules id="1" profile_id="2" rule_id="10" failure_level="4" inheritance="INHERITED" - created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + created_at="1500000000000" updated_at="1600000000000"/> <!-- Parent of Active rule 1 --> <active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]" - created_at_ms="1700000000000" updated_at_ms="1800000000000"/> + created_at="1700000000000" updated_at="1800000000000"/> <rules_profiles id="3" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/> <active_rules id="3" profile_id="3" rule_id="11" failure_level="3" inheritance="[null]" - created_at_ms="2000000000000" updated_at_ms="2100000000000"/> + created_at="2000000000000" updated_at="2100000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/index.xml index b3e777b7735..58647440cac 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/index.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/index.xml @@ -6,8 +6,7 @@ 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" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/removed_rule.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/removed_rule.xml index 3ab588b95e2..aea85a6b647 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/removed_rule.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/removed_rule.xml @@ -6,8 +6,7 @@ priority="4" status="REMOVED" 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" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/custom_rule.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/custom_rule.xml index 13f34bcd263..dfe3352fd3f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/custom_rule.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/custom_rule.xml @@ -7,8 +7,7 @@ priority="4" status="READY" is_template="[true]" 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" /> <!-- Custom rule --> @@ -18,8 +17,7 @@ priority="3" status="BETA" is_template="[false]" template_id="1" tags="[null]" system_tags="[null]" - created_at="2014-05-10" updated_at="2014-05-11" - created_at_ms="2000000000000" updated_at_ms="2100000000000" + created_at="2000000000000" updated_at="2100000000000" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/one_rule.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/one_rule.xml index b3e777b7735..58647440cac 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/one_rule.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/one_rule.xml @@ -6,8 +6,7 @@ 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" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/removed_rule.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/removed_rule.xml index 3ab588b95e2..aea85a6b647 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/removed_rule.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/removed_rule.xml @@ -6,8 +6,7 @@ priority="4" status="REMOVED" 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" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/shared.xml index 65e7c7a0866..71b57fca060 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/shared.xml @@ -6,8 +6,7 @@ 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" @@ -16,7 +15,6 @@ priority="3" status="BETA" is_template="[true]" template_id="[null]" tags="[null]" system_tags="[null]" - created_at="2014-05-10" updated_at="2014-05-11" - created_at_ms="2000000000000" updated_at_ms="2100000000000" + created_at="2000000000000" updated_at="2100000000000" /> </dataset> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1108_drop_rules_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1108_drop_rules_date_columns.rb new file mode 100644 index 00000000000..066ad47ba6c --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1108_drop_rules_date_columns.rb @@ -0,0 +1,30 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube 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. +# +# SonarQube 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. +# + +# +# SonarQube 5.5 +# SONAR-7330 +# +class DropRulesDateColumns < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v55.DropRulesDateColumns') + end +end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1109_rename_rules_long_dates.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1109_rename_rules_long_dates.rb new file mode 100644 index 00000000000..e5abf30dc33 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1109_rename_rules_long_dates.rb @@ -0,0 +1,33 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube 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. +# +# SonarQube 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. +# + +# +# SonarQube 5.5 +# SONAR-7330 +# +class RenameRulesLongDates < ActiveRecord::Migration + + def self.up + rename_column 'rules', 'created_at_ms', 'created_at' + rename_column 'rules', 'updated_at_ms', 'updated_at' + end + +end + diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1110_drop_active_rules_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1110_drop_active_rules_date_columns.rb new file mode 100644 index 00000000000..dfd018d28cc --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1110_drop_active_rules_date_columns.rb @@ -0,0 +1,30 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube 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. +# +# SonarQube 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. +# + +# +# SonarQube 5.5 +# SONAR-7330 +# +class DropActiveRulesDateColumns < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v55.DropActiveRulesDateColumns') + end +end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1111_rename_active_rules_long_dates.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1111_rename_active_rules_long_dates.rb new file mode 100644 index 00000000000..284d8c8076f --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1111_rename_active_rules_long_dates.rb @@ -0,0 +1,33 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube 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. +# +# SonarQube 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. +# + +# +# SonarQube 5.5 +# SONAR-7330 +# +class RenameActiveRulesLongDates < ActiveRecord::Migration + + def self.up + rename_column 'active_rules', 'created_at_ms', 'created_at' + rename_column 'active_rules', 'updated_at_ms', 'updated_at' + end + +end + 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> |