]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2176 Default value for rule parameter should be updated in database if was...
authorEvgeny Mandrikov <mandrikov@gmail.com>
Fri, 29 Apr 2011 10:25:24 +0000 (14:25 +0400)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Fri, 29 Apr 2011 16:03:10 +0000 (20:03 +0400)
sonar-server/src/main/java/org/sonar/server/startup/RegisterRules.java
sonar-server/src/test/java/org/sonar/server/startup/RegisterRulesTest.java

index 3ad4ae210c9db9d3b5f90134bea3ffd0979e91d6..e45afad60dc91a7fb42123b18a0a8b1f38f37b81 100644 (file)
@@ -134,6 +134,7 @@ public final class RegisterRules {
         }
         persistedParam.setDescription(param.getDescription());
         persistedParam.setType(param.getType());
+        persistedParam.setDefaultValue(param.getDefaultValue());
       }
     }
   }
index f1bf19aa25d90836309bb35b09ed07fb5cdde25d..7d09ffb6690b052b1caecaae6b73c388cb1d9c25 100644 (file)
@@ -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);