diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-03-22 10:49:35 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-03-22 10:49:35 +0100 |
commit | ec15548ef761899b1162f9b8210196e0b4e222be (patch) | |
tree | 0531b15a283d12d98a57855305c8186c0c0e2456 /sonar-plugin-api/src | |
parent | d42c6a3993cc9b1e40b3fd6006008dd9b902822e (diff) | |
download | sonarqube-ec15548ef761899b1162f9b8210196e0b4e222be.tar.gz sonarqube-ec15548ef761899b1162f9b8210196e0b4e222be.zip |
SONAR-3879 Replace rule status enumeration in the annotation by a string
Diffstat (limited to 'sonar-plugin-api/src')
3 files changed, 16 insertions, 14 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java index 38f15ea804d..440d00a2001 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/AnnotationRuleParser.java @@ -69,7 +69,7 @@ public final class AnnotationRuleParser implements ServerComponent { rule.setDescription(description); rule.setSeverity(RulePriority.fromCheckPriority(ruleAnnotation.priority())); rule.setCardinality(ruleAnnotation.cardinality()); - rule.setStatus(ruleAnnotation.status().name()); + rule.setStatus(ruleAnnotation.status()); List<Field> fields = FieldUtils2.getFields(clazz, true); for (Field field : fields) { 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 8fe75c018ee..367ffb730df 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 @@ -31,11 +31,12 @@ import java.util.List; import static org.fest.assertions.Assertions.assertThat; public class AnnotationRuleParserTest { + @org.junit.Rule public final ExpectedException exception = ExpectedException.none(); @Test - public void ruleWithProperty() { + public void rule_with_property() { List<Rule> rules = parseAnnotatedClass(RuleWithProperty.class); assertThat(rules).hasSize(1); Rule rule = rules.get(0); @@ -43,7 +44,9 @@ public class AnnotationRuleParserTest { assertThat(rule.getName()).isEqualTo("bar"); assertThat(rule.getDescription()).isEqualTo("Foo Bar"); assertThat(rule.getSeverity()).isEqualTo(RulePriority.BLOCKER); + assertThat(rule.getStatus()).isEqualTo("READY"); assertThat(rule.getParams()).hasSize(1); + RuleParam prop = rule.getParam("property"); assertThat(prop.getKey()).isEqualTo("property"); assertThat(prop.getDescription()).isEqualTo("Ignore ?"); @@ -52,7 +55,7 @@ public class AnnotationRuleParserTest { } @Test - public void ruleWithIntegerProperty() { + public void rule_with_integer_property() { List<Rule> rules = parseAnnotatedClass(RuleWithIntegerProperty.class); RuleParam prop = rules.get(0).getParam("property"); @@ -62,7 +65,7 @@ public class AnnotationRuleParserTest { } @Test - public void ruleWithTextProperty() { + public void rule_with_text_property() { List<Rule> rules = parseAnnotatedClass(RuleWithTextProperty.class); RuleParam prop = rules.get(0).getParam("property"); @@ -92,7 +95,7 @@ public class AnnotationRuleParserTest { } @Test - public void ruleWithoutNameNorDescription() { + public void rule_without_name_nor_description() { List<Rule> rules = parseAnnotatedClass(RuleWithoutNameNorDescription.class); assertThat(rules).hasSize(1); Rule rule = rules.get(0); @@ -103,7 +106,7 @@ public class AnnotationRuleParserTest { } @Test - public void ruleWithoutKey() { + public void rule_without_key() { List<Rule> rules = parseAnnotatedClass(RuleWithoutKey.class); assertThat(rules).hasSize(1); Rule rule = rules.get(0); @@ -137,7 +140,7 @@ public class AnnotationRuleParserTest { static class RuleWithoutNameNorDescription { } - @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER) + @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER) static class RuleWithProperty { @org.sonar.check.RuleProperty(description = "Ignore ?", defaultValue = "false") private String property; @@ -149,19 +152,19 @@ public class AnnotationRuleParserTest { private String additionalProperty; } - @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER) + @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER) static class RuleWithIntegerProperty { @org.sonar.check.RuleProperty(description = "Max", defaultValue = "12") private Integer property; } - @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER) + @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER) static class RuleWithTextProperty { @org.sonar.check.RuleProperty(description = "text", defaultValue = "Long text", type = "TEXT") protected String property; } - @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", priority = Priority.BLOCKER) + @org.sonar.check.Rule(key = "foo", name = "bar", description = "Foo Bar", status = "READY", priority = Priority.BLOCKER) static class RuleWithInvalidPropertyType { @org.sonar.check.RuleProperty(description = "text", defaultValue = "Long text", type = "INVALID") public String property; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java index 59bd9bf54bd..918a5e3e1b2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.sonar.api.PropertyType; import org.sonar.api.utils.SonarException; import org.sonar.check.Cardinality; -import org.sonar.check.Status; import java.io.File; import java.io.StringReader; @@ -131,8 +130,8 @@ public class XMLRuleParserTest { "<rule><key>foo</key><status>BETA</status></rule>"+ "<rule><key>foo</key><status>DEPRECATED</status></rule>"+ "</rules>")); - assertThat(rules.get(0).getStatus(), is(Status.READY.name())); - assertThat(rules.get(1).getStatus(), is(Status.BETA.name())); - assertThat(rules.get(2).getStatus(), is(Status.DEPRECATED.name())); + assertThat(rules.get(0).getStatus(), is("READY")); + assertThat(rules.get(1).getStatus(), is("BETA")); + assertThat(rules.get(2).getStatus(), is("DEPRECATED")); } } |