summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/test/java/org
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-07-26 23:37:58 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-07-26 23:37:58 +0200
commit84c0fbaa08bc8f5db140e26395a37ce27568cb27 (patch)
tree8a746617bda0b8755e2ca4820e75abe3f8be186a /sonar-plugin-api/src/test/java/org
parentcce3d90c338798f2ce6005f7f3d5d6e2fd808482 (diff)
downloadsonarqube-84c0fbaa08bc8f5db140e26395a37ce27568cb27.tar.gz
sonarqube-84c0fbaa08bc8f5db140e26395a37ce27568cb27.zip
SONAR-3702 API : AnnotationRuleParser does not detect overridden rule parameters
Diffstat (limited to 'sonar-plugin-api/src/test/java/org')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java
index 2fa2b5c30de..74877514357 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotationRuleParserTest.java
@@ -19,11 +19,10 @@
*/
package org.sonar.api.rules;
-import org.sonar.api.utils.SonarException;
-
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.PropertyType;
+import org.sonar.api.utils.SonarException;
import org.sonar.check.IsoCategory;
import org.sonar.check.Priority;
@@ -116,6 +115,18 @@ public class AnnotationRuleParserTest {
}
@Test
+ public void overridden_rule() {
+ List<Rule> rules = parseAnnotatedClass(OverridingRule.class);
+ assertThat(rules).hasSize(1);
+ Rule rule = rules.get(0);
+ assertThat(rule.getKey()).isEqualTo("overriding_foo");
+ assertThat(rule.getName()).isEqualTo("Overriding Foo");
+ assertThat(rule.getDescription()).isNull();
+ assertThat(rule.getSeverity()).isEqualTo(RulePriority.MAJOR);
+ assertThat(rule.getParams()).hasSize(2);
+ }
+
+ @Test
public void supportDeprecatedAnnotations() {
List<Rule> rules = parseAnnotatedClass(Check.class);
assertThat(rules).hasSize(1);
@@ -141,19 +152,25 @@ public class AnnotationRuleParserTest {
@org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER)
static class RuleWithProperty {
@org.sonar.check.RuleProperty(description = "Ignore ?", defaultValue = "false")
- public String property;
+ private String property;
+ }
+
+ @org.sonar.check.Rule(key = "overriding_foo", name = "Overriding Foo")
+ static class OverridingRule extends RuleWithProperty {
+ @org.sonar.check.RuleProperty
+ private String additionalProperty;
}
@org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER)
static class RuleWithIntegerProperty {
@org.sonar.check.RuleProperty(description = "Max", defaultValue = "12")
- public Integer property;
+ private Integer property;
}
@org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER)
static class RuleWithTextProperty {
@org.sonar.check.RuleProperty(description = "text", defaultValue = "Long text", type = "TEXT")
- public String property;
+ protected String property;
}
@org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER)