From 6ef3cc3c65f9bbbb50aecc4e144a4a6efb5829b2 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Fri, 29 Apr 2011 14:25:24 +0400 Subject: [PATCH] SONAR-2176 Default value for rule parameter should be updated in database if was updated in repository --- .../main/java/org/sonar/server/startup/RegisterRules.java | 1 + .../java/org/sonar/server/startup/RegisterRulesTest.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java index 3ad4ae210c9..e45afad60dc 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java @@ -134,6 +134,7 @@ public final class RegisterRules { } persistedParam.setDescription(param.getDescription()); persistedParam.setType(param.getType()); + persistedParam.setDefaultValue(param.getDefaultValue()); } } } diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java index f1bf19aa25d..7d09ffb6690 100644 --- a/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java +++ b/sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java @@ -132,9 +132,13 @@ public class RegisterRulesTest extends AbstractDbUnitTestCase { // new parameter assertNotNull(rule.getParam("param2")); + assertThat(rule.getParam("param2").getDescription(), is("parameter two")); + assertThat(rule.getParam("param2").getDefaultValue(), is("default value two")); // updated parameter + assertNotNull(rule.getParam("param1")); assertThat(rule.getParam("param1").getDescription(), is("parameter one")); + assertThat(rule.getParam("param1").getDefaultValue(), is("default value one")); // deleted parameter assertNull(rule.getParam("deprecated_param")); @@ -182,8 +186,8 @@ class FakeRepository extends RuleRepository { rule1.setDescription("Description of One"); rule1.setSeverity(RulePriority.BLOCKER); rule1.setConfigKey("config1"); - rule1.createParameter("param1").setDescription("parameter one"); - rule1.createParameter("param2").setDescription("parameter two"); + rule1.createParameter("param1").setDescription("parameter one").setDefaultValue("default value one"); + rule1.createParameter("param2").setDescription("parameter two").setDefaultValue("default value two"); Rule rule2 = Rule.create("fake", "rule2", "Two"); rule2.setSeverity(RulePriority.INFO); -- 2.39.5