aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins/foo-plugin-v1
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-06-21 11:18:26 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-06-29 17:23:19 +0200
commita624a9cc04c37176e311c39cf250f5ff19e6cf42 (patch)
tree4c853fc820b5257f0f6069ab96c17602c6c63286 /tests/plugins/foo-plugin-v1
parente5eb765a319edacb43ab7cfa5714659deb1fcad0 (diff)
downloadsonarqube-a624a9cc04c37176e311c39cf250f5ff19e6cf42.tar.gz
sonarqube-a624a9cc04c37176e311c39cf250f5ff19e6cf42.zip
SONAR-9442 Add details of added/updated/disabled rules in notification
Diffstat (limited to 'tests/plugins/foo-plugin-v1')
-rw-r--r--tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java26
-rw-r--r--tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java7
2 files changed, 28 insertions, 5 deletions
diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java
index 3a53e9293ff..73f54dc30f4 100644
--- a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java
+++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java
@@ -21,7 +21,9 @@ package org.sonar.foo.rule;
import org.sonar.api.profiles.ProfileDefinition;
import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.api.rules.RuleFinder;
+import org.sonar.api.rules.RulePriority;
import org.sonar.api.utils.ValidationMessages;
import static org.sonar.api.rules.RulePriority.MAJOR;
@@ -30,12 +32,28 @@ import static org.sonar.foo.rule.FooRulesDefinition.FOO_REPOSITORY;
public class FooBasicProfile extends ProfileDefinition {
+ private final RuleFinder ruleFinder;
+
+ public FooBasicProfile(RuleFinder ruleFinder) {
+ this.ruleFinder = ruleFinder;
+ }
+
@Override
public RulesProfile createProfile(ValidationMessages validation) {
final RulesProfile profile = RulesProfile.create("Basic", KEY);
- profile.activateRule(Rule.create(FOO_REPOSITORY, "UnchangedRule"), MAJOR);
- profile.activateRule(Rule.create(FOO_REPOSITORY, "ChangedRule"), MAJOR);
- profile.activateRule(Rule.create(FOO_REPOSITORY, "RemovedRule"), MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "UnchangedRule", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "ChangedRule", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "ToBeDeactivatedRule", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "ToBeRemovedRule", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "RuleWithUnchangedParameter", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "RuleWithChangedParameter", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "RuleWithRemovedParameter", MAJOR);
+ activateRule(profile, FOO_REPOSITORY, "RuleWithAddedParameter", MAJOR);
return profile;
}
+
+ private ActiveRule activateRule(RulesProfile profile, String repo, String key, RulePriority severity) {
+ return profile.activateRule(ruleFinder.findByKey(repo, key), severity);
+ }
+
}
diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java
index 7257dd72681..039cea9fd2b 100644
--- a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java
+++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java
@@ -35,7 +35,12 @@ public class FooRulesDefinition implements RulesDefinition {
NewRepository repo = context.createRepository(FOO_REPOSITORY, Foo.KEY).setName("Foo");
createRule(repo, "UnchangedRule");
createRule(repo, "ChangedRule");
- createRule(repo, "RemovedRule");
+ createRule(repo, "ToBeDeactivatedRule");
+ createRule(repo, "ToBeRemovedRule");
+ createRule(repo, "RuleWithUnchangedParameter").createParam("unchanged").setDefaultValue("10");
+ createRule(repo, "RuleWithChangedParameter").createParam("toBeChanged").setDefaultValue("10");
+ createRule(repo, "RuleWithRemovedParameter").createParam("toBeRemoved").setDefaultValue("10");
+ createRule(repo, "RuleWithAddedParameter").createParam("added");
repo.done();
}