]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10304 use NewRule#addDeprecatedRuleKey in QP notification IT
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 24 Jan 2018 16:40:23 +0000 (17:40 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 8 Feb 2018 12:41:00 +0000 (13:41 +0100)
tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java
tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java
tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java
tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java
tests/src/test/java/org/sonarqube/tests/qualityProfile/BuiltInQualityProfilesNotificationTest.java

index 56f506619091117faa51a0e7a59db9d4ea5e3e93..88b940a0401b1f5942f024d414a58818384d6f57 100644 (file)
@@ -49,6 +49,8 @@ public class FooBasicProfile extends ProfileDefinition {
     activateRule(profile, FOO_REPOSITORY, "RuleWithChangedParameter", MAJOR);
     activateRule(profile, FOO_REPOSITORY, "RuleWithRemovedParameter", MAJOR);
     activateRule(profile, FOO_REPOSITORY, "RuleWithAddedParameter", MAJOR);
+    activateRule(profile, FOO_REPOSITORY, "ToBeRenamed", MAJOR);
+    activateRule(profile, FOO_REPOSITORY, "ToBeRenamedAndMoved", MAJOR);
     return profile;
   }
 
index 12f81a5849060555fbafb76c292097586d040174..3000c39baa4851122274a867f660c75653de8b64 100644 (file)
@@ -32,16 +32,18 @@ public class FooRulesDefinition implements RulesDefinition {
   }
 
   private static void defineRulesXoo(Context context) {
-    NewRepository repo = context.createRepository(FOO_REPOSITORY, Foo.KEY).setName("Foo");
-    createRule(repo, "UnchangedRule");
-    createRule(repo, "ChangedRule");
-    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();
+    NewRepository repoFoo1 = context.createRepository(FOO_REPOSITORY, Foo.KEY).setName("Foo");
+    createRule(repoFoo1, "UnchangedRule");
+    createRule(repoFoo1, "ChangedRule");
+    createRule(repoFoo1, "ToBeDeactivatedRule");
+    createRule(repoFoo1, "ToBeRemovedRule");
+    createRule(repoFoo1, "RuleWithUnchangedParameter").createParam("unchanged").setDefaultValue("10");
+    createRule(repoFoo1, "RuleWithChangedParameter").createParam("toBeChanged").setDefaultValue("10");
+    createRule(repoFoo1, "RuleWithRemovedParameter").createParam("toBeRemoved").setDefaultValue("10");
+    createRule(repoFoo1, "RuleWithAddedParameter").createParam("added");
+    createRule(repoFoo1, "ToBeRenamed");
+    createRule(repoFoo1, "ToBeRenamedAndMoved");
+    repoFoo1.done();
   }
 
   private static NewRule createRule(NewRepository repo, String key) {
index 9c31db02314433a8b6cbabbfba82ce9cba51b406..45293bf3998b00ef57896e431f194d84a831c51c 100644 (file)
@@ -30,6 +30,7 @@ import static org.sonar.api.rules.RulePriority.MAJOR;
 import static org.sonar.api.rules.RulePriority.MINOR;
 import static org.sonar.foo.Foo.KEY;
 import static org.sonar.foo.rule.FooRulesDefinition.FOO_REPOSITORY;
+import static org.sonar.foo.rule.FooRulesDefinition.FOO_REPOSITORY_2;
 
 public class FooBasicProfile extends ProfileDefinition {
 
@@ -51,6 +52,8 @@ public class FooBasicProfile extends ProfileDefinition {
     activateRule(profile, FOO_REPOSITORY, "RuleWithChangedParameter", MAJOR).setParameter("toBeChanged", "20");
     activateRule(profile, FOO_REPOSITORY, "RuleWithRemovedParameter", MAJOR);
     activateRule(profile, FOO_REPOSITORY, "RuleWithAddedParameter", MAJOR);
+    activateRule(profile, FOO_REPOSITORY, "Renamed", MAJOR);
+    activateRule(profile, FOO_REPOSITORY_2, "RenamedAndMoved", MAJOR);
     return profile;
   }
 
index 6054d1d55c4dbdd6d159d08610ca1283c10cbc94..2de82d5dc668d3cb4532728348df64630343923f 100644 (file)
@@ -25,6 +25,7 @@ import org.sonar.foo.Foo;
 public class FooRulesDefinition implements RulesDefinition {
 
   public static final String FOO_REPOSITORY = "foo";
+  public static final String FOO_REPOSITORY_2 = "foo2";
 
   @Override
   public void define(Context context) {
@@ -32,17 +33,22 @@ public class FooRulesDefinition implements RulesDefinition {
   }
 
   private static void defineRulesXoo(Context context) {
-    NewRepository repo = context.createRepository(FOO_REPOSITORY, Foo.KEY).setName("Foo");
-    createRule(repo, "UnchangedRule");
-    createRule(repo, "ChangedRule");
-    createRule(repo, "NewRule");
-    createRule(repo, "ToBeDeactivatedRule");
-    createRule(repo, "RuleWithUnchangedParameter").createParam("unchanged").setDefaultValue("10");
+    NewRepository repoFoo1 = context.createRepository(FOO_REPOSITORY, Foo.KEY).setName("Foo");
+    createRule(repoFoo1, "UnchangedRule");
+    createRule(repoFoo1, "ChangedRule");
+    createRule(repoFoo1, "NewRule");
+    createRule(repoFoo1, "ToBeDeactivatedRule");
+    createRule(repoFoo1, "RuleWithUnchangedParameter").createParam("unchanged").setDefaultValue("10");
     // Update of the default value of a parameter is not taken into account in quality profile as long as it's not also explicitly set in the quality profile
-    createRule(repo, "RuleWithChangedParameter").createParam("toBeChanged").setDefaultValue("20");
-    createRule(repo, "RuleWithRemovedParameter");
-    createRule(repo, "RuleWithAddedParameter").createParam("added").setDefaultValue("10");
-    repo.done();
+    createRule(repoFoo1, "RuleWithChangedParameter").createParam("toBeChanged").setDefaultValue("20");
+    createRule(repoFoo1, "RuleWithRemovedParameter");
+    createRule(repoFoo1, "RuleWithAddedParameter").createParam("added").setDefaultValue("10");
+    createRule(repoFoo1, "Renamed").addDeprecatedRuleKey(FOO_REPOSITORY, "ToBeRenamed");
+    repoFoo1.done();
+
+    NewRepository repoFoo2 = context.createRepository(FOO_REPOSITORY_2, Foo.KEY).setName("Foo2");
+    createRule(repoFoo2, "RenamedAndMoved").addDeprecatedRuleKey(FOO_REPOSITORY, "ToBeRenamedAndMoved");
+    repoFoo2.done();
   }
 
   private static NewRule createRule(NewRepository repo, String key) {
index 042430e63b21a9a6375abbc09552977b3401476f..3f81750e2db374247206a48dac09cb6a78bfe9e8 100644 (file)
@@ -136,7 +136,7 @@ public class BuiltInQualityProfilesNotificationTest {
       .containsSubsequence(
         "The following built-in profiles have been updated:",
         "\"Basic\" - Foo: " + url + "/profiles/changelog?language=foo&name=Basic&since=", "&to=",
-        " 1 new rule",
+        " 3 new rules",
         " 3 rules have been updated",
         " 1 rule removed",
         "This is a good time to review your quality profiles and update them to benefit from the latest evolutions: " + url + "/profiles")