rule.setRemediationFunction(null);
rule.setRemediationCoefficient(null);
rule.setRemediationOffset(null);
- rule.setUpdatedAtInMs(updateDate.getTime());
+ rule.setUpdatedAt(updateDate.getTime());
dbClient.ruleDao().update(session, rule);
}
}
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);
}
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) {
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()) {
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));
}
"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 " +
"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);
.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())
.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);
}
private void update(DbSession session, RuleDto rule){
- rule.setUpdatedAtInMs(system2.now());
+ rule.setUpdatedAt(system2.now());
dbClient.ruleDao().update(session, rule);
}
}
.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())) {
.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;
}
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 {
}
private void update(DbSession session, RuleDto rule) {
- rule.setUpdatedAtInMs(system.now());
+ rule.setUpdatedAt(system.now());
dbClient.ruleDao().update(session, rule);
}
"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();
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()));
}
}
rule.setRemediationFunction(null);
rule.setRemediationCoefficient(null);
rule.setRemediationOffset(null);
- rule.setUpdatedAtInMs(system2.now());
+ rule.setUpdatedAt(system2.now());
dbClient.ruleDao().update(session, rule);
countClearedRules++;
}
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
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
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
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());
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();
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();
.setLanguage(lang)
.setSeverity(Severity.BLOCKER)
.setStatus(RuleStatus.READY)
- .setUpdatedAtInMs(now)
- .setCreatedAtInMs(now);
+ .setUpdatedAt(now)
+ .setCreatedAt(now);
db.ruleDao().insert(session, rule);
return rule;
}
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;
}
.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
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");
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);
// 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);
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
// -> 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);
}
.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);
.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");
.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");
// 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();
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();
@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();
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();
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>
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
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]"/>
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>
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>
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>
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>
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"
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>
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>
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>
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 -->
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>
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>
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>
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"
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>
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
+
--- /dev/null
+#
+# 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
--- /dev/null
+#
+# 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
+
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;
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;
}
private RuleKey key;
- private long createdAtInMs;
- private long updatedAtInMs;
+ private long createdAt;
+ private long updatedAt;
public RuleKey getKey() {
if (key == null) {
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;
}
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
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;
DeleteMeasuresWithCharacteristicId.class,
AddActiveRulesLongDateColumns.class,
FeedActiveRulesLongDateColumns.class,
- DeleteMeasuresWithCharacteristicId.class,
AddIssuesType.class,
- FeedIssueTypes.class
+ FeedIssueTypes.class,
+ DropRulesDateColumns.class,
+ DropActiveRulesDateColumns.class
);
}
}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+}
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">
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 -->
</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">
rule_id=#{ruleId},
failure_level=#{severity},
inheritance=#{inheritance},
- updated_at_ms=#{updatedAtInMs}
+ updated_at=#{updatedAt}
WHERE id=#{id}
</update>
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">
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">
effort_to_fix_description=#{effortToFixDescription},
tags=#{tagsField},
system_tags=#{systemTagsField},
- updated_at_ms=#{updatedAtInMs}
+ updated_at=#{updatedAt}
WHERE id=#{id}
</update>
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">
#{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">
#{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>
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;
"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
);
"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" (
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
- .setCreatedAtInMs(1500000000000L)
- .setUpdatedAtInMs(2000000000000L);
+ .setCreatedAt(1500000000000L)
+ .setUpdatedAt(2000000000000L);
underTest.insert(dbTester.getSession(), newRule);
dbTester.getSession().commit();
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
.setRemediationOffset("5min")
.setDefaultRemediationOffset("10h")
.setEffortToFixDescription("squid.S115.effortToFix")
- .setUpdatedAtInMs(2000000000000L);
+ .setUpdatedAt(2000000000000L);
underTest.update(dbTester.getSession(), ruleToUpdate);
dbTester.getSession().commit();
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
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);
}
}
--- /dev/null
+/*
+ * 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"
+ );
+ }
+
+}
--- /dev/null
+/*
+ * 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"
+ );
+ }
+
+}
<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>
<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>
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"
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"
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>
<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>
<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"/>
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>
<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>
<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."/>
<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>