@@ -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); | |||
} | |||
@@ -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)); | |||
} |
@@ -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); |
@@ -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()) |
@@ -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); | |||
} | |||
} |
@@ -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 { |
@@ -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); | |||
} | |||
@@ -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(); | |||
@@ -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())); | |||
} | |||
} | |||
@@ -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++; | |||
} |
@@ -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 |
@@ -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()); |
@@ -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(); | |||
@@ -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; | |||
} |
@@ -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 |
@@ -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); | |||
} |
@@ -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"); |
@@ -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(); |
@@ -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(); |
@@ -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(); |
@@ -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> |
@@ -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 |
@@ -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]"/> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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 |
@@ -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 | |||
@@ -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 |
@@ -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 | |||
@@ -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; | |||
} | |||
@@ -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; | |||
} | |||
@@ -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 |
@@ -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 | |||
); | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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> | |||
@@ -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> | |||
@@ -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; |
@@ -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" ( |
@@ -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 |
@@ -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); | |||
} | |||
} |
@@ -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" | |||
); | |||
} | |||
} |
@@ -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" | |||
); | |||
} | |||
} |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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> |
@@ -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"/> | |||
@@ -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> |
@@ -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> |
@@ -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."/> |
@@ -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> |