From f6edb3b39c3a337a4302e6d4a87d8160ecebc11d Mon Sep 17 00:00:00 2001
From: Godin <mandrikov@gmail.com>
Date: Tue, 7 Dec 2010 16:50:21 +0000
Subject: Don't use deprecated API in BackupTest

---
 .../org/sonar/server/configuration/BackupTest.java | 24 ++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

(limited to 'sonar-server/src/test/java')

diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java
index 0a9029e2334..133cfaa649f 100644
--- a/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/configuration/BackupTest.java
@@ -30,7 +30,10 @@ import org.sonar.api.database.configuration.Property;
 import org.sonar.api.measures.Metric;
 import org.sonar.api.profiles.Alert;
 import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rules.*;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.api.rules.ActiveRuleParam;
+import org.sonar.api.rules.Rule;
+import org.sonar.api.rules.RulePriority;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -69,6 +72,7 @@ public class BackupTest {
     sonarConfig.setProfiles(getProfiles());
 
     String xml = backup.getXmlFromSonarConfig(sonarConfig);
+    System.out.println(xml);
     assertXmlAreSimilar(xml, "backup-valid.xml");
   }
 
@@ -219,13 +223,21 @@ public class BackupTest {
 
   private List<RulesProfile> getProfiles() {
     List<RulesProfile> profiles = new ArrayList<RulesProfile>();
-    profiles.add(new RulesProfile("test name", "test language", true, true));
-    profiles.add(new RulesProfile("test2 name", "test2 language", false, false));
 
-    ActiveRule activeRule = new ActiveRule(null, new Rule("test plugin", "test key"), RulePriority.MAJOR);
-    activeRule.getActiveRuleParams().add(new ActiveRuleParam(activeRule, new RuleParam(null, "test param key", null, null), "test value"));
+    RulesProfile profile1 = RulesProfile.create("test name", "test language");
+    profile1.setDefaultProfile(true);
+    profile1.setProvided(true);
+    profiles.add(profile1);
+
+    RulesProfile profile2 = RulesProfile.create("test2 name", "test2 language");
+    profiles.add(profile2);
+
+    Rule rule = Rule.create("test plugin", "test key", null);
+    rule.createParameter("test param key");
+
+    ActiveRule activeRule = profile1.activateRule(rule, RulePriority.MAJOR);
+    activeRule.setParameter("test param key", "test value");
 
-    profiles.get(0).getActiveRules().add(activeRule);
     profiles.get(0).getAlerts().add(new Alert(null, new Metric("test key"), Alert.OPERATOR_GREATER, "testError", "testWarn"));
 
     return profiles;
-- 
cgit v1.2.3