@Test
public void update_custom_rule() throws Exception {
// Create template rule
RuleDto templateRule = RuleTesting.newTemplateRule(RuleKey.of("java", "S001"));
ruleDao.insert(dbSession, templateRule);
RuleParamDto templateRuleParam1 = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*");
RuleParamDto templateRuleParam2 = RuleParamDto.createFor(templateRule).setName("format").setType("STRING").setDescription("Format");
ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam1);
ruleDao.addRuleParam(dbSession, templateRule, templateRuleParam2);
// Create custom rule
RuleDto customRule = RuleTesting.newCustomRule(templateRule)
.setName("Old name")
.setDescription("Old description")
.setSeverity(Severity.MINOR)
.setStatus(RuleStatus.BETA);
ruleDao.insert(dbSession, customRule);
ruleDao.addRuleParam(dbSession, customRule, templateRuleParam1.setDefaultValue("a.*"));
ruleDao.addRuleParam(dbSession, customRule, templateRuleParam2.setDefaultValue(null));
dbSession.commit();
// Update custom rule
RuleUpdate update = RuleUpdate.createForCustomRule(customRule.getKey())