]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5056 Add debt columns on rules and update Rule API to define some debt data
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 5 Mar 2014 13:33:37 +0000 (14:33 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 5 Mar 2014 17:46:29 +0000 (18:46 +0100)
71 files changed:
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/java/org/sonar/core/rule/RuleDto.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml
sonar-core/src/test/java/org/sonar/core/rule/RuleDaoTest.java
sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/empty.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert-result.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert.xml [deleted file]
sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert_all-result.xml [new file with mode: 0644]
sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/selectAll.xml
sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/update-result.xml
sonar-plugin-api/src/main/java/org/sonar/api/rule/RemediationFunction.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleDefinitions.java
sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleDefinitionsTest.java
sonar-server/src/main/java/org/sonar/server/rule/RuleRegistration.java
sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/rule/RuleRegistrationTest.java
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disableUserRulesIfParentIsDisabled-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disableUserRulesIfParentIsDisabled.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rule_params-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rule_params.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rules-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rules.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_repositories-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_rules-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_rules.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_template_rules_if_parent_is_disabled-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_template_rules_if_parent_is_disabled.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/doNotDisableUserRulesIfParentIsEnabled-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/doNotDisableUserRulesIfParentIsEnabled.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_extended_repositories-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_manual_rules-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_manual_rules.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_template_rules_if_parent_is_enabled-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_template_rules_if_parent_is_enabled.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_update_already_disabled_rules-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_update_already_disabled_rules.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/reactivate_disabled_rules-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/reactivate_disabled_rules.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shared.xml
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shouldNotDisableManualRules-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shouldNotDisableManualRules.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rule_params-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rule_params.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rules-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rules.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_repositories-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_rules-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_rules.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_insert_extended_repositories-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_insert_new_rules-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_not_update_already_disabled_rules-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_not_update_already_disabled_rules.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_reactivate_disabled_rules-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_reactivate_disabled_rules.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_store_bundle_name_and_description_in_database-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_rule_parameters-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_rule_parameters.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_template_rule_language-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_template_rule_language.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/store_bundle_name_and_description_in_database-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/updadeRuleFields-result.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/updadeRuleFields.xml [deleted file]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_parameters-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_parameters.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml [new file with mode: 0644]
sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml [new file with mode: 0644]

index f4109954865f1cc5c59644cfc490bfface6def62..c7c6fa7bb118ab96d2d9b1a4f4bd3b5b4dbd2604 100644 (file)
@@ -33,7 +33,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 519;
+  public static final int LAST_VERSION = 520;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 05ab52775ca878e9a9a2f2f854265c0ab32553f9..fd84664a57f20df5ca7a8ae6716675bc517f8c09 100644 (file)
@@ -21,10 +21,13 @@ package org.sonar.core.rule;
 
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ReflectionToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.sonar.check.Cardinality;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
 import java.util.Date;
 
 public final class RuleDto {
@@ -39,12 +42,21 @@ public final class RuleDto {
   private Cardinality cardinality;
   private String language;
   private Integer parentId;
-  private Date createdAt;
-  private Date updatedAt;
   private String noteData;
   private String noteUserLogin;
   private Date noteCreatedAt;
   private Date noteUpdatedAt;
+  private Integer characteristicId;
+  private Integer defaultCharacteristicId;
+  private String remediationFunction;
+  private String defaultRemediationFunction;
+  private String remediationFactor;
+  private String defaultRemediationFactor;
+  private String remediationOffset;
+  private String defaultRemediationOffset;
+  private String effortToFixL10nKey;
+  private Date createdAt;
+  private Date updatedAt;
 
   public Integer getId() {
     return id;
@@ -155,24 +167,6 @@ public final class RuleDto {
     return this;
   }
 
-  public Date getCreatedAt() {
-    return createdAt;
-  }
-
-  public RuleDto setCreatedAt(Date createdAt) {
-    this.createdAt = createdAt;
-    return this;
-  }
-
-  public Date getUpdatedAt() {
-    return updatedAt;
-  }
-
-  public RuleDto setUpdatedAt(Date updatedAt) {
-    this.updatedAt = updatedAt;
-    return this;
-  }
-
   public String getNoteData() {
     return noteData;
   }
@@ -209,6 +203,114 @@ public final class RuleDto {
     return this;
   }
 
+  @CheckForNull
+  public Integer getCharacteristicId() {
+    return characteristicId;
+  }
+
+  public RuleDto setCharacteristicId(@Nullable Integer characteristicId) {
+    this.characteristicId = characteristicId;
+    return this;
+  }
+
+  @CheckForNull
+  public Integer getDefaultCharacteristicId() {
+    return defaultCharacteristicId;
+  }
+
+  public RuleDto setDefaultCharacteristicId(@Nullable Integer defaultCharacteristicId) {
+    this.defaultCharacteristicId = defaultCharacteristicId;
+    return this;
+  }
+
+  @CheckForNull
+  public String getRemediationFunction() {
+    return remediationFunction;
+  }
+
+  public RuleDto setRemediationFunction(@Nullable String remediationFunction) {
+    this.remediationFunction = remediationFunction;
+    return this;
+  }
+
+  @CheckForNull
+  public String getDefaultRemediationFunction() {
+    return defaultRemediationFunction;
+  }
+
+  public RuleDto setDefaultRemediationFunction(@Nullable String defaultRemediationFunction) {
+    this.defaultRemediationFunction = defaultRemediationFunction;
+    return this;
+  }
+
+  @CheckForNull
+  public String getRemediationFactor() {
+    return remediationFactor;
+  }
+
+  public RuleDto setRemediationFactor(@Nullable String remediationFactor) {
+    this.remediationFactor = remediationFactor;
+    return this;
+  }
+
+  @CheckForNull
+  public String getDefaultRemediationFactor() {
+    return defaultRemediationFactor;
+  }
+
+  public RuleDto setDefaultRemediationFactor(@Nullable String defaultRemediationFactor) {
+    this.defaultRemediationFactor = defaultRemediationFactor;
+    return this;
+  }
+
+  @CheckForNull
+  public String getRemediationOffset() {
+    return remediationOffset;
+  }
+
+  public RuleDto setRemediationOffset(@Nullable String remediationOffset) {
+    this.remediationOffset = remediationOffset;
+    return this;
+  }
+
+  @CheckForNull
+  public String getDefaultRemediationOffset() {
+    return defaultRemediationOffset;
+  }
+
+  public RuleDto setDefaultRemediationOffset(@Nullable String defaultRemediationOffset) {
+    this.defaultRemediationOffset = defaultRemediationOffset;
+    return this;
+  }
+
+  @CheckForNull
+  public String getEffortToFixL10nKey() {
+    return effortToFixL10nKey;
+  }
+
+  public RuleDto setEffortToFixL10nKey(@Nullable String effortToFixL10nKey) {
+    this.effortToFixL10nKey = effortToFixL10nKey;
+    return this;
+  }
+
+  public Date getCreatedAt() {
+    return createdAt;
+  }
+
+  public RuleDto setCreatedAt(Date createdAt) {
+    this.createdAt = createdAt;
+    return this;
+  }
+
+  public Date getUpdatedAt() {
+    return updatedAt;
+  }
+
+  public RuleDto setUpdatedAt(Date updatedAt) {
+    this.updatedAt = updatedAt;
+    return this;
+  }
+
   @Override
   public boolean equals(Object obj) {
     if (!(obj instanceof RuleDto)) {
@@ -234,18 +336,6 @@ public final class RuleDto {
 
   @Override
   public String toString() {
-    // Note that ReflectionToStringBuilder will not work here - see SONAR-3077
-    return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
-      .append("id", id)
-      .append("name", name)
-      .append("key", ruleKey)
-      .append("configKey", configKey)
-      .append("plugin", repositoryKey)
-      .append("severity", getSeverityString())
-      .append("cardinality", cardinality)
-      .append("status", status)
-      .append("language", language)
-      .append("parentId", parentId)
-      .toString();
+    return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
   }
 }
index a7fa6bb25116cc12c9760809210edf5ecfcde813..01b91d42ffc6567401a8489ac649208dc40802d5 100644 (file)
@@ -217,6 +217,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('516');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('517');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('518');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('519');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('520');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 3525e9b4acf8b7b94b5fd7b46239369c18abdeee..7292b42d6d9760ca956d3fd562b6731fced4b6c2 100644 (file)
@@ -151,12 +151,21 @@ CREATE TABLE "RULES" (
   "NAME" VARCHAR(200),
   "STATUS" VARCHAR(40),
   "LANGUAGE" VARCHAR(20),
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP,
+  "NOTE_DATA" CLOB(2147483647),
+  "NOTE_USER_LOGIN" VARCHAR(40),
   "NOTE_CREATED_AT" TIMESTAMP,
   "NOTE_UPDATED_AT" TIMESTAMP,
-  "NOTE_USER_LOGIN" VARCHAR(40),
-  "NOTE_DATA" CLOB(2147483647)
+  "CHARACTERISTIC_ID" INTEGER,
+  "DEFAULT_CHARACTERISTIC_ID" INTEGER,
+  "REMEDIATION_FUNCTION" VARCHAR(20),
+  "DEFAULT_REMEDIATION_FUNCTION" VARCHAR(20),
+  "REMEDIATION_FACTOR" VARCHAR(20),
+  "DEFAULT_REMEDIATION_FACTOR" VARCHAR(20),
+  "REMEDIATION_OFFSET" VARCHAR(20),
+  "DEFAULT_REMEDIATION_OFFSET" VARCHAR(20),
+  "EFFORT_TO_FIX_L10N_KEY" VARCHAR(100),
+  "CREATED_AT" TIMESTAMP,
+  "UPDATED_AT" TIMESTAMP
 );
 
 CREATE TABLE "RULE_TAGS" (
index 95b931b3bf2783d38a3912a245e28a7bab0c2555..c4d558add8e717bf70b5a1185adaa13677ce32fe 100644 (file)
     cardinality,
     language as "language",
     parent_id as "parentId",
-    created_at as "createdAt",
-    updated_at as "updatedAt",
     note_data as "noteData",
     note_user_login as "noteUserLogin",
     note_created_at as "noteCreatedAt",
-    note_updated_at as "noteUpdatedAt"
+    note_updated_at as "noteUpdatedAt",
+    characteristic_id as "characteristicId",
+    default_characteristic_id as "defaultCharacteristicId",
+    remediation_function as "remediationFunction",
+    default_remediation_function as "defaultRemediationFunction",
+    remediation_factor as "remediationFactor",
+    default_remediation_factor as "defaultRemediationFactor",
+    remediation_offset as "remediationOffset",
+    default_remediation_offset as "defaultRemediationOffset",
+    effort_to_fix_l10n_key as "effortToFixL10nKey",
+    created_at as "createdAt",
+    updated_at as "updatedAt"
   </sql>
 
   <select id="selectAll" resultType="Rule">
     cardinality=#{cardinality},
     language=#{language},
     parent_id=#{parentId},
-    updated_at=#{updatedAt},
     note_data=#{noteData},
     note_user_login=#{noteUserLogin},
     note_created_at=#{noteCreatedAt},
-    note_updated_at=#{noteUpdatedAt}
+    note_updated_at=#{noteUpdatedAt},
+    characteristic_id=#{characteristicId},
+    default_characteristic_id=#{defaultCharacteristicId},
+    remediation_function=#{remediationFunction},
+    default_remediation_function=#{defaultRemediationFunction},
+    remediation_factor=#{remediationFactor},
+    default_remediation_factor=#{defaultRemediationFactor},
+    remediation_offset=#{remediationOffset},
+    default_remediation_offset=#{defaultRemediationOffset},
+    effort_to_fix_l10n_key=#{effortToFixL10nKey},
+    updated_at=#{updatedAt}
     WHERE id=#{id}
   </update>
 
   <sql id="insertColumns">
-    (plugin_rule_key, plugin_name, description, status, name, plugin_config_key, priority, cardinality, language,
-      parent_id, created_at, updated_at)
+    (plugin_rule_key, plugin_name, description, status, name, plugin_config_key, priority, cardinality, language, parent_id,
+    characteristic_id, default_characteristic_id, remediation_function, default_remediation_function,
+    remediation_factor, default_remediation_factor, remediation_offset, default_remediation_offset,
+    effort_to_fix_l10n_key,
+    created_at, updated_at)
   </sql>
 
   <insert id="insert" parameterType="Rule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
     insert into rules <include refid="insertColumns"/>
     values (#{ruleKey}, #{repositoryKey}, #{description}, #{status}, #{name}, #{configKey},
-      #{severity}, #{cardinality}, #{language}, #{parentId}, #{createdAt}, #{updatedAt})
+      #{severity}, #{cardinality}, #{language}, #{parentId},
+      #{characteristicId}, #{defaultCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
+      #{remediationFactor}, #{defaultRemediationFactor}, #{remediationOffset}, #{defaultRemediationOffset},
+      #{effortToFixL10nKey},
+      #{createdAt}, #{updatedAt})
   </insert>
 
   <insert id="batchInsert" parameterType="Rule" useGeneratedKeys="false">
     insert into rules <include refid="insertColumns"/>
     values (#{ruleKey}, #{repositoryKey}, #{description}, #{status}, #{name}, #{configKey},
-    #{severity}, #{cardinality}, #{language}, #{parentId}, #{createdAt}, #{updatedAt})
+    #{severity}, #{cardinality}, #{language}, #{parentId},
+    #{characteristicId}, #{defaultCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
+    #{remediationFactor}, #{defaultRemediationFactor}, #{remediationOffset}, #{defaultRemediationOffset},
+    #{effortToFixL10nKey},
+    #{createdAt}, #{updatedAt})
   </insert>
 
   <delete id="deleteParams" parameterType="Integer" >
index 61ff4eaced99cc40f6886d042494123245d60cf6..f30352b988b19184253d43fe486494755d0650ea 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.check.Cardinality;
 import org.sonar.core.persistence.AbstractDaoTestCase;
 
-import java.util.Date;
 import java.util.List;
 
 import static org.fest.assertions.Assertions.assertThat;
@@ -44,7 +43,7 @@ public class RuleDaoTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void testSelectAll() throws Exception {
+  public void select_all() throws Exception {
     setupData("selectAll");
     List<RuleDto> ruleDtos = dao.selectAll();
 
@@ -56,10 +55,19 @@ public class RuleDaoTest extends AbstractDaoTestCase {
     assertThat(ruleDto.getStatus()).isEqualTo(Rule.STATUS_READY);
     assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
     assertThat(ruleDto.getNoteData()).isEqualTo("Rule note with accents \u00e9\u00e8\u00e0");
+    assertThat(ruleDto.getCharacteristicId()).isEqualTo(100);
+    assertThat(ruleDto.getDefaultCharacteristicId()).isEqualTo(101);
+    assertThat(ruleDto.getRemediationFunction()).isEqualTo("linear");
+    assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("linear_offset");
+    assertThat(ruleDto.getRemediationFactor()).isEqualTo("1h");
+    assertThat(ruleDto.getDefaultRemediationFactor()).isEqualTo("5d");
+    assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min");
+    assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h");
+    assertThat(ruleDto.getEffortToFixL10nKey()).isEqualTo("squid.S115.effortToFix");
   }
 
   @Test
-  public void testSelectById() throws Exception {
+  public void select_by_id() throws Exception {
     setupData("selectById");
     RuleDto ruleDto = dao.selectById(2);
 
@@ -83,7 +91,7 @@ public class RuleDaoTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void testSelectNonManual() throws Exception {
+  public void select_non_manual() throws Exception {
     setupData("selectNonManual");
     SqlSession session = getMyBatis().openSession();
     List<RuleDto> ruleDtos = dao.selectNonManual(session);
@@ -115,11 +123,20 @@ public class RuleDaoTest extends AbstractDaoTestCase {
       .setCardinality(Cardinality.MULTIPLE)
       .setLanguage("dart")
       .setParentId(3)
-      .setUpdatedAt(DateUtils.parseDate("2013-12-17"))
       .setNoteData("My note")
       .setNoteUserLogin("admin")
       .setNoteCreatedAt(DateUtils.parseDate("2013-12-19"))
-      .setNoteUpdatedAt(DateUtils.parseDate("2013-12-20"));
+      .setNoteUpdatedAt(DateUtils.parseDate("2013-12-20"))
+      .setCharacteristicId(100)
+      .setDefaultCharacteristicId(101)
+      .setRemediationFunction("linear")
+      .setDefaultRemediationFunction("linear_offset")
+      .setRemediationFactor("1h")
+      .setDefaultRemediationFactor("5d")
+      .setRemediationOffset("5min")
+      .setDefaultRemediationOffset("10h")
+      .setEffortToFixL10nKey("squid.S115.effortToFix")
+      .setUpdatedAt(DateUtils.parseDate("2013-12-17"));
 
     dao.update(ruleToUpdate);
 
@@ -127,114 +144,97 @@ public class RuleDaoTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void testInsert() {
-    setupData("insert");
-    RuleDto ruleToInsert = new RuleDto();
-    String newRuleKey = "NewRuleKey";
-    String newRepositoryKey = "plugin";
-    String newName = "new name";
-    String newDescription = "new description";
-    String newStatus = Rule.STATUS_DEPRECATED;
-    String newConfigKey = "NewConfigKey";
-    String newSeverity = Severity.INFO;
-    Cardinality newCardinality = Cardinality.MULTIPLE;
-    String newLanguage = "dart";
-    Date updatedAt = new Date();
-    Integer newParentId = 3;
-
-    ruleToInsert.setRuleKey(newRuleKey);
-    ruleToInsert.setRepositoryKey(newRepositoryKey);
-    ruleToInsert.setName(newName);
-    ruleToInsert.setDescription(newDescription);
-    ruleToInsert.setStatus(newStatus);
-    ruleToInsert.setConfigKey(newConfigKey);
-    ruleToInsert.setSeverity(Severity.INFO);
-    ruleToInsert.setCardinality(newCardinality);
-    ruleToInsert.setLanguage(newLanguage);
-    ruleToInsert.setUpdatedAt(updatedAt);
-    ruleToInsert.setParentId(newParentId);
+  public void insert() {
+    setupData("empty");
+
+    RuleDto ruleToInsert = new RuleDto()
+      .setId(1)
+      .setRuleKey("NewRuleKey")
+      .setRepositoryKey("plugin")
+      .setName("new name")
+      .setDescription("new description")
+      .setStatus(Rule.STATUS_DEPRECATED)
+      .setConfigKey("NewConfigKey")
+      .setSeverity(Severity.INFO)
+      .setCardinality(Cardinality.MULTIPLE)
+      .setLanguage("dart")
+      .setParentId(3)
+      .setCharacteristicId(100)
+      .setDefaultCharacteristicId(101)
+      .setRemediationFunction("linear")
+      .setDefaultRemediationFunction("linear_offset")
+      .setRemediationFactor("1h")
+      .setDefaultRemediationFactor("5d")
+      .setRemediationOffset("5min")
+      .setDefaultRemediationOffset("10h")
+      .setEffortToFixL10nKey("squid.S115.effortToFix")
+      .setCreatedAt(DateUtils.parseDate("2013-12-16"))
+      .setUpdatedAt(DateUtils.parseDate("2013-12-17"));
+
     dao.insert(ruleToInsert);
 
-    List<RuleDto> ruleDtos = dao.selectAll();
-    assertThat(ruleDtos.size()).isEqualTo(1);
-    RuleDto insertedRule = ruleDtos.get(0);
-    // First inserted rule, auto generated ID should be 1
-    assertThat(insertedRule.getId()).isEqualTo(1);
-    assertThat(insertedRule.getRuleKey()).isEqualTo(newRuleKey);
-    assertThat(insertedRule.getRepositoryKey()).isEqualTo(newRepositoryKey);
-    assertThat(insertedRule.getName()).isEqualTo(newName);
-    assertThat(insertedRule.getDescription()).isEqualTo(newDescription);
-    assertThat(insertedRule.getStatus()).isEqualTo(newStatus);
-    assertThat(insertedRule.getConfigKey()).isEqualTo(newConfigKey);
-    assertThat(insertedRule.getSeverityString()).isEqualTo(newSeverity);
-    assertThat(insertedRule.getCardinality()).isEqualTo(newCardinality);
-    assertThat(insertedRule.getLanguage()).isEqualTo(newLanguage);
-    assertThat(insertedRule.getParentId()).isEqualTo(newParentId);
+    checkTables("insert", "rules");
   }
 
   @Test
-  public void testInsertAll() {
-    setupData("insert");
-    RuleDto ruleToInsert1 = new RuleDto();
-    String newRuleKey = "NewRuleKey1";
-    String newRepositoryKey = "plugin1";
-    String newName = "new name1";
-    String newDescription = "new description1";
-    String newStatus = Rule.STATUS_DEPRECATED;
-    String newConfigKey = "NewConfigKey1";
-    String newSeverity = Severity.INFO;
-    Cardinality newCardinality = Cardinality.MULTIPLE;
-    String newLanguage = "dart";
-    Date createdAt = new Date();
-    Date updatedAt = new Date();
-
-    ruleToInsert1.setRuleKey(newRuleKey);
-    ruleToInsert1.setRepositoryKey(newRepositoryKey);
-    ruleToInsert1.setName(newName);
-    ruleToInsert1.setDescription(newDescription);
-    ruleToInsert1.setStatus(newStatus);
-    ruleToInsert1.setConfigKey(newConfigKey);
-    ruleToInsert1.setSeverity(newSeverity);
-    ruleToInsert1.setCardinality(newCardinality);
-    ruleToInsert1.setLanguage(newLanguage);
-    ruleToInsert1.setCreatedAt(createdAt);
-    ruleToInsert1.setUpdatedAt(updatedAt);
-
-    RuleDto ruleToInsert2 = new RuleDto();
-    String newRuleKey1 = "NewRuleKey2";
-    String newRepositoryKey1 = "plugin2";
-    String newName1 = "new name2";
-    String newDescription1 = "new description2";
-    String newStatus1 = Rule.STATUS_DEPRECATED;
-    String newConfigKey1 = "NewConfigKey2";
-    String newSeverity1 = Severity.INFO;
-    Cardinality newCardinality1 = Cardinality.MULTIPLE;
-    String newLanguage1 = "dart";
-    Date createdAt1 = new Date();
-    Date updatedAt1 = new Date();
-
-    ruleToInsert2.setRuleKey(newRuleKey1);
-    ruleToInsert2.setRepositoryKey(newRepositoryKey1);
-    ruleToInsert2.setName(newName1);
-    ruleToInsert2.setDescription(newDescription1);
-    ruleToInsert2.setStatus(newStatus1);
-    ruleToInsert2.setConfigKey(newConfigKey1);
-    ruleToInsert2.setSeverity(newSeverity1);
-    ruleToInsert2.setCardinality(newCardinality1);
-    ruleToInsert2.setLanguage(newLanguage1);
-    ruleToInsert2.setCreatedAt(createdAt1);
-    ruleToInsert2.setUpdatedAt(updatedAt1);
+  public void insert_all() {
+    setupData("empty");
+
+    RuleDto ruleToInsert1 = new RuleDto()
+      .setId(1)
+      .setRuleKey("NewRuleKey")
+      .setRepositoryKey("plugin")
+      .setName("new name")
+      .setDescription("new description")
+      .setStatus(Rule.STATUS_DEPRECATED)
+      .setConfigKey("NewConfigKey")
+      .setSeverity(Severity.INFO)
+      .setCardinality(Cardinality.MULTIPLE)
+      .setLanguage("dart")
+      .setParentId(3)
+      .setCharacteristicId(100)
+      .setDefaultCharacteristicId(101)
+      .setRemediationFunction("linear")
+      .setDefaultRemediationFunction("linear_offset")
+      .setRemediationFactor("1h")
+      .setDefaultRemediationFactor("5d")
+      .setRemediationOffset("5min")
+      .setDefaultRemediationOffset("10h")
+      .setEffortToFixL10nKey("squid.S115.effortToFix")
+      .setCreatedAt(DateUtils.parseDate("2013-12-16"))
+      .setUpdatedAt(DateUtils.parseDate("2013-12-17"));
+
+    RuleDto ruleToInsert2 = new RuleDto()
+      .setId(2)
+      .setRuleKey("NewRuleKey2")
+      .setRepositoryKey("plugin2")
+      .setName("new name2")
+      .setDescription("new description2")
+      .setStatus(Rule.STATUS_BETA)
+      .setConfigKey("NewConfigKey2")
+      .setSeverity(Severity.MAJOR)
+      .setCardinality(Cardinality.SINGLE)
+      .setLanguage("js")
+      .setParentId(null)
+      .setCharacteristicId(102)
+      .setDefaultCharacteristicId(103)
+      .setRemediationFunction("linear_offset")
+      .setDefaultRemediationFunction("linear")
+      .setRemediationFactor("5d")
+      .setDefaultRemediationFactor("1h")
+      .setRemediationOffset("10h")
+      .setDefaultRemediationOffset("5min")
+      .setEffortToFixL10nKey("squid.S115.effortToFix2")
+      .setCreatedAt(DateUtils.parseDate("2013-12-14"))
+      .setUpdatedAt(DateUtils.parseDate("2013-12-15"));
 
     dao.insert(ImmutableList.of(ruleToInsert1, ruleToInsert2));
 
-    List<RuleDto> ruleDtos = dao.selectAll();
-    assertThat(ruleDtos.size()).isEqualTo(2);
-    assertThat(ruleDtos.get(0).getId()).isEqualTo(1);
-    assertThat(ruleDtos.get(1).getId()).isEqualTo(2);
+    checkTables("insert_all", "rules");
   }
 
   @Test
-  public void testSelectParameters() throws Exception {
+  public void select_parameters() throws Exception {
     setupData("selectParameters");
     List<RuleParamDto> ruleDtos = dao.selectParameters();
 
@@ -248,7 +248,7 @@ public class RuleDaoTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void testSelectParamsForRule() throws Exception {
+  public void select_params_for_rule() throws Exception {
     setupData("selectParamsForRule");
     int ruleId = 1;
     List<RuleParamDto> ruleDtos = dao.selectParameters(ruleId);
diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/empty.xml b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/empty.xml
new file mode 100644 (file)
index 0000000..871dedc
--- /dev/null
@@ -0,0 +1,3 @@
+<dataset>
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert-result.xml
new file mode 100644 (file)
index 0000000..d277a75
--- /dev/null
@@ -0,0 +1,33 @@
+<!--
+  ~ SonarQube, open source software quality management tool.
+  ~ Copyright (C) 2008-2013 SonarSource
+  ~ mailto:contact AT sonarsource DOT com
+  ~
+  ~ SonarQube is free software; you can redistribute it and/or
+  ~ modify it under the terms of the GNU Lesser General Public
+  ~ License as published by the Free Software Foundation; either
+  ~ version 3 of the License, or (at your option) any later version.
+  ~
+  ~ SonarQube is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public License
+  ~ along with this program; if not, write to the Free Software Foundation,
+  ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+  -->
+
+<dataset>
+
+  <rules id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
+         plugin_config_key="NewConfigKey" priority="0" cardinality="MULTIPLE" language="dart" created_at="2013-12-16" updated_at="2013-12-17" parent_id="3"
+         note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
+         characteristic_id="100" default_characteristic_id="101"
+         remediation_function="linear" default_remediation_function="linear_offset"
+         remediation_factor="1h" default_remediation_factor="5d"
+         remediation_offset="5min" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix"
+      />
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert.xml b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert.xml
deleted file mode 100644 (file)
index 871dedc..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<dataset>
-
-</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert_all-result.xml b/sonar-core/src/test/resources/org/sonar/core/rule/RuleDaoTest/insert_all-result.xml
new file mode 100644 (file)
index 0000000..f15d834
--- /dev/null
@@ -0,0 +1,43 @@
+<!--
+  ~ SonarQube, open source software quality management tool.
+  ~ Copyright (C) 2008-2013 SonarSource
+  ~ mailto:contact AT sonarsource DOT com
+  ~
+  ~ SonarQube is free software; you can redistribute it and/or
+  ~ modify it under the terms of the GNU Lesser General Public
+  ~ License as published by the Free Software Foundation; either
+  ~ version 3 of the License, or (at your option) any later version.
+  ~
+  ~ SonarQube is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public License
+  ~ along with this program; if not, write to the Free Software Foundation,
+  ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+  -->
+
+<dataset>
+
+  <rules id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
+         plugin_config_key="NewConfigKey" priority="0" cardinality="MULTIPLE" language="dart" created_at="2013-12-16" updated_at="2013-12-17" parent_id="3"
+         note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
+         characteristic_id="100" default_characteristic_id="101"
+         remediation_function="linear" default_remediation_function="linear_offset"
+         remediation_factor="1h" default_remediation_factor="5d"
+         remediation_offset="5min" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix"
+      />
+
+  <rules id="2" plugin_rule_key="NewRuleKey2" plugin_name="plugin2" name="new name2" description="new description2" status="BETA"
+         plugin_config_key="NewConfigKey2" priority="2" cardinality="SINGLE" language="js" created_at="2013-12-14" updated_at="2013-12-15" parent_id="[null]"
+         note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
+         characteristic_id="102" default_characteristic_id="103"
+         remediation_function="linear_offset" default_remediation_function="linear"
+         remediation_factor="5d" default_remediation_factor="1h"
+         remediation_offset="10h" default_remediation_offset="5min"
+         effort_to_fix_l10n_key="squid.S115.effortToFix2"
+      />
+
+</dataset>
index 48221d99f1d752b06133e759b472fb13a1e629e8..2f26ad3f588ca904eace38dd94359e016e302026 100644 (file)
@@ -2,6 +2,12 @@
 <dataset>
 
   <rules id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"
-    note_data="Rule note with accents Ã©Ã¨Ã " note_user_login="polop.palap" note_created_at="2013-12-25"/>
+    note_data="Rule note with accents Ã©Ã¨Ã " note_user_login="polop.palap" note_created_at="2013-12-25"
+    characteristic_id="100" default_characteristic_id="101"
+    remediation_function="linear" default_remediation_function="linear_offset"
+    remediation_factor="1h" default_remediation_factor="5d"
+    remediation_offset="5min" default_remediation_offset="10h"
+    effort_to_fix_l10n_key="squid.S115.effortToFix"
+  />
 
 </dataset>
index 16595425ecf583b05225eeda8d8ec46d439f19cc..206ac65e85c2e95654cfc4f0870194f162cdeae4 100644 (file)
@@ -2,7 +2,13 @@
 
   <rules id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
     plugin_config_key="NewConfigKey" priority="0" cardinality="MULTIPLE" language="dart" created_at="2011-04-25 01:05:00" updated_at="2013-12-17" parent_id="3"
-    note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20" />
+    note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20"
+    characteristic_id="100" default_characteristic_id="101"
+    remediation_function="linear" default_remediation_function="linear_offset"
+    remediation_factor="1h" default_remediation_factor="5d"
+    remediation_offset="5min" default_remediation_offset="10h"
+    effort_to_fix_l10n_key="squid.S115.effortToFix"
+  />
 
   <rules id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY"
     plugin_config_key="Parent1" priority="2" cardinality="SINGLE" language="golo" created_at="1981-10-24 15:20:00" updated_at="[null]" parent_id="[null]"
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rule/RemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/rule/RemediationFunction.java
new file mode 100644 (file)
index 0000000..8517002
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.api.rule;
+
+/**
+ * @since 4.3
+ */
+public enum RemediationFunction {
+  LINEAR, LINEAR_OFFSET, CONSTANT_ISSUE
+}
index 596982289baf69484688bf73f077112547cc1aaa..cbb5f213d1b4eabbea800a0ab9bd94b3403a4b92 100644 (file)
@@ -24,12 +24,14 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.ServerExtension;
+import org.sonar.api.rule.RemediationFunction;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -310,6 +312,11 @@ public interface RuleDefinitions extends ServerExtension {
     private String name, htmlDescription, internalKey, severity = Severity.MAJOR;
     private boolean template;
     private RuleStatus status = RuleStatus.defaultStatus();
+    private String characteristicKey;
+    private RemediationFunction remediationFunction;
+    private String remediationFactor;
+    private String remediationOffset;
+    private String effortToFixL10nKey;
     private final Set<String> tags = Sets.newTreeSet();
     private final Map<String, NewParam> paramsByKey = Maps.newHashMap();
 
@@ -369,6 +376,34 @@ public interface RuleDefinitions extends ServerExtension {
       return this;
     }
 
+    public NewRule setCharacteristicKey(@Nullable String characteristicKey) {
+      // TODO validate characteristic exists and it's a sub characteristic
+      this.characteristicKey = characteristicKey;
+      return this;
+    }
+
+    public NewRule setRemediationFunction(@Nullable RemediationFunction remediationFunction) {
+      this.remediationFunction = remediationFunction;
+      return this;
+    }
+
+    public NewRule setRemediationFactor(@Nullable String remediationFactor) {
+      // TODO validate format
+      this.remediationFactor = remediationFactor;
+      return this;
+    }
+
+    public NewRule setRemediationOffset(@Nullable String remediationOffset) {
+      // TODO validate format
+      this.remediationOffset = remediationOffset;
+      return this;
+    }
+
+    public NewRule setEffortToFixL10nKey(@Nullable String effortToFixL10nKey) {
+      this.effortToFixL10nKey = effortToFixL10nKey;
+      return this;
+    }
+
     public NewParam newParam(String paramKey) {
       if (paramsByKey.containsKey(paramKey)) {
         throw new IllegalArgumentException(String.format("The parameter '%s' is declared several times on the rule %s", paramKey, this));
@@ -433,6 +468,11 @@ public interface RuleDefinitions extends ServerExtension {
     private final Repository repository;
     private final String repoKey, key, name, htmlDescription, internalKey, severity;
     private final boolean template;
+    private final String characteristicKey;
+    private final RemediationFunction remediationFunction;
+    private final String remediationFactor;
+    private final String remediationOffset;
+    private final String effortToFixL10nKey;
     private final Set<String> tags;
     private final Map<String, Param> params;
     private final RuleStatus status;
@@ -447,6 +487,11 @@ public interface RuleDefinitions extends ServerExtension {
       this.severity = newRule.severity;
       this.template = newRule.template;
       this.status = newRule.status;
+      this.characteristicKey = newRule.characteristicKey;
+      this.remediationFunction = newRule.remediationFunction;
+      this.remediationFactor = newRule.remediationFactor;
+      this.remediationOffset = newRule.remediationOffset;
+      this.effortToFixL10nKey = newRule.effortToFixL10nKey;
       this.tags = ImmutableSortedSet.copyOf(newRule.tags);
       ImmutableMap.Builder<String, Param> paramsBuilder = ImmutableMap.builder();
       for (NewParam newParam : newRule.paramsByKey.values()) {
@@ -484,6 +529,31 @@ public interface RuleDefinitions extends ServerExtension {
       return status;
     }
 
+    @CheckForNull
+    public String characteristicKey() {
+      return characteristicKey;
+    }
+
+    @CheckForNull
+    public RemediationFunction remediationFunction() {
+      return remediationFunction;
+    }
+
+    @CheckForNull
+    public String remediationFactor() {
+      return remediationFactor;
+    }
+
+    @CheckForNull
+    public String remediationOffset() {
+      return remediationOffset;
+    }
+
+    @CheckForNull
+    public String effortToFixL10nKey() {
+      return effortToFixL10nKey;
+    }
+
     @CheckForNull
     public Param param(String key) {
       return params.get(key);
index 5fb81e7ccab8aee76a6b6a47744dbb84bf77e1c4..a8c57ad30e0e0465a6801e3acca2890fe19123c8 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.api.server.rule;
 
 import org.junit.Test;
+import org.sonar.api.rule.RemediationFunction;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 
@@ -71,6 +72,11 @@ public class RuleDefinitionsTest {
       .setSeverity(Severity.BLOCKER)
       .setInternalKey("/something")
       .setStatus(RuleStatus.BETA)
+      .setCharacteristicKey("COMPILER")
+      .setRemediationFunction(RemediationFunction.LINEAR_OFFSET)
+      .setRemediationFactor("1h")
+      .setRemediationOffset("10min")
+      .setEffortToFixL10nKey("squid.S115.effortToFix")
       .setTags("one", "two")
       .addTags("two", "three", "four");
     newFindbugs.newRule("ABC").setName("ABC").setHtmlDescription("ABC");
@@ -89,6 +95,11 @@ public class RuleDefinitionsTest {
     assertThat(npeRule.internalKey()).isEqualTo("/something");
     assertThat(npeRule.template()).isFalse();
     assertThat(npeRule.status()).isEqualTo(RuleStatus.BETA);
+    assertThat(npeRule.characteristicKey()).isEqualTo("COMPILER");
+    assertThat(npeRule.remediationFunction()).isEqualTo(RemediationFunction.LINEAR_OFFSET);
+    assertThat(npeRule.remediationFactor()).isEqualTo("1h");
+    assertThat(npeRule.remediationOffset()).isEqualTo("10min");
+    assertThat(npeRule.effortToFixL10nKey()).isEqualTo("squid.S115.effortToFix");
     assertThat(npeRule.toString()).isEqualTo("[repository=findbugs, key=NPE]");
     assertThat(npeRule.repository()).isSameAs(findbugs);
 
@@ -111,6 +122,10 @@ public class RuleDefinitionsTest {
     assertThat(rule.internalKey()).isNull();
     assertThat(rule.status()).isEqualTo(RuleStatus.defaultStatus());
     assertThat(rule.tags()).isEmpty();
+    assertThat(rule.characteristicKey()).isNull();
+    assertThat(rule.remediationFunction()).isNull();
+    assertThat(rule.remediationFactor()).isNull();
+    assertThat(rule.remediationOffset()).isNull();
   }
 
   @Test
index c9641831cb91318f4b72d0458f8991f2659468da..3356625a8690132c37b488946ac1e10a6a3e0004 100644 (file)
@@ -27,9 +27,9 @@ import org.apache.ibatis.session.SqlSession;
 import org.picocontainer.Startable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.rule.RemediationFunction;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.RulePriority;
 import org.sonar.api.server.rule.RuleDefinitions;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.TimeProfiler;
@@ -152,6 +152,7 @@ public class RuleRegistration implements Startable {
   }
 
   private RuleDto enableAndInsert(Buffer buffer, SqlSession sqlSession, RuleDefinitions.Rule ruleDef) {
+    RemediationFunction remediationFunction = ruleDef.remediationFunction();
     RuleDto ruleDto = new RuleDto()
       .setCardinality(ruleDef.template() ? Cardinality.MULTIPLE : Cardinality.SINGLE)
       .setConfigKey(ruleDef.internalKey())
@@ -160,10 +161,15 @@ public class RuleRegistration implements Startable {
       .setName(ruleDef.name())
       .setRepositoryKey(ruleDef.repository().key())
       .setRuleKey(ruleDef.key())
-      .setSeverity(RulePriority.valueOf(ruleDef.severity()).name())
+      .setSeverity(ruleDef.severity())
       .setCreatedAt(buffer.now())
       .setUpdatedAt(buffer.now())
-      .setStatus(ruleDef.status().name());
+      .setStatus(ruleDef.status().name())
+      // TODO set default characteristic id
+      .setDefaultRemediationFunction(remediationFunction != null ? remediationFunction.name() : null)
+      .setDefaultRemediationFactor(ruleDef.remediationFactor())
+      .setDefaultRemediationOffset(ruleDef.remediationOffset())
+      .setEffortToFixL10nKey(ruleDef.effortToFixL10nKey());
     ruleDao.insert(ruleDto, sqlSession);
     buffer.add(ruleDto);
 
@@ -204,7 +210,7 @@ public class RuleRegistration implements Startable {
       dto.setConfigKey(def.internalKey());
       changed = true;
     }
-    String severity = RulePriority.valueOf(def.severity()).name();
+    String severity = def.severity();
     if (!ObjectUtils.equals(dto.getSeverityString(), severity)) {
       dto.setSeverity(severity);
       changed = true;
@@ -219,6 +225,28 @@ public class RuleRegistration implements Startable {
       dto.setStatus(status);
       changed = true;
     }
+
+    // TODO add characteristic id change verification
+
+    RemediationFunction remediationFunction = def.remediationFunction();
+    String remediationFunctionString = remediationFunction != null ? remediationFunction.name() : null;
+    if (!StringUtils.equals(dto.getDefaultRemediationFunction(), remediationFunctionString)) {
+      dto.setDefaultRemediationFunction(remediationFunctionString);
+      changed = true;
+    }
+    if (!StringUtils.equals(dto.getDefaultRemediationFactor(), def.remediationFactor())) {
+      dto.setDefaultRemediationFactor(def.remediationFactor());
+      changed = true;
+    }
+    if (!StringUtils.equals(dto.getDefaultRemediationOffset(), def.remediationOffset())) {
+      dto.setDefaultRemediationOffset(def.remediationOffset());
+      changed = true;
+    }
+    if (!StringUtils.equals(dto.getEffortToFixL10nKey(), def.effortToFixL10nKey())) {
+      dto.setEffortToFixL10nKey(def.effortToFixL10nKey());
+      changed = true;
+    }
+
     if (!StringUtils.equals(dto.getLanguage(), def.repository().language())) {
       dto.setLanguage(def.repository().language());
       changed = true;
@@ -345,6 +373,11 @@ public class RuleRegistration implements Startable {
           // TODO merge params and tags ?
           ruleDto.setLanguage(parent.getLanguage());
           ruleDto.setStatus(parent.getStatus());
+          ruleDto.setDefaultCharacteristicId(parent.getDefaultCharacteristicId());
+          ruleDto.setDefaultRemediationFunction(parent.getDefaultRemediationFunction());
+          ruleDto.setDefaultRemediationFactor(parent.getDefaultRemediationFactor());
+          ruleDto.setDefaultRemediationOffset(parent.getDefaultRemediationOffset());
+          ruleDto.setEffortToFixL10nKey(parent.getEffortToFixL10nKey());
           ruleDto.setUpdatedAt(buffer.now());
           ruleDao.update(ruleDto, sqlSession);
           toBeRemoved = false;
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/520_add_debt_columns_to_rules.rb
new file mode 100644 (file)
index 0000000..f78d609
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+
+#
+# Sonar 4.3
+# SONAR-5056
+#
+class AddDebtColumnsToRules < ActiveRecord::Migration
+
+  def self.up
+    add_column 'rules', :characteristic_id,             :integer,   :null => true
+    add_column 'rules', :default_characteristic_id,     :integer,   :null => true
+    add_column 'rules', :remediation_function,          :string,    :null => true,   :limit => 20
+    add_column 'rules', :default_remediation_function,  :string,    :null => true,   :limit => 20
+    add_column 'rules', :remediation_factor,            :string,    :null => true,   :limit => 20
+    add_column 'rules', :default_remediation_factor,    :string,    :null => true,   :limit => 20
+    add_column 'rules', :remediation_offset,            :string,    :null => true,   :limit => 20
+    add_column 'rules', :default_remediation_offset,    :string,    :null => true,   :limit => 20
+    add_column 'rules', :effort_to_fix_l10n_key,        :string,    :null => true,   :limit => 100
+    end
+
+end
+
index a4f125a0867ef4fda48580a0d4c981f7a9e694e0..3853bff4914285e6e96c8be9ed37a1281c5f7cf1 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.server.rule;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.sonar.api.rule.RemediationFunction;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.server.rule.RuleDefinitions;
@@ -37,8 +38,11 @@ import static org.mockito.Mockito.*;
 
 public class RuleRegistrationTest extends AbstractDaoTestCase {
 
-  private static final String[] EXCLUDED_COLUMN_NAMES = {
-      "created_at", "updated_at", "note_data", "note_user_login", "note_created_at", "note_updated_at"};
+  private static final String[] EXCLUDED_COLUMN_NAMES = {"created_at", "updated_at", "note_data", "note_user_login", "note_created_at", "note_updated_at"};
+  private static final String[] EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT = {"created_at", "updated_at", "note_data", "note_user_login", "note_created_at", "note_updated_at",
+    "characteristic_id", "default_characteristic_id",
+    "remediation_function", "default_remediation_function", "remediation_factor", "default_remediation_factor", "remediation_offset", "default_remediation_offset",
+    "effort_to_fix_l10n_key"};
 
   RuleRegistration task;
   ProfilesManager profilesManager = mock(ProfilesManager.class);
@@ -62,19 +66,19 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void should_insert_new_rules() {
+  public void insert_new_rules() {
     setupData("shared");
     task.start();
 
-    checkTables("should_insert_new_rules", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters", "rules_rule_tags", "rule_tags");
+    checkTables("insert_new_rules", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters", "rules_rule_tags", "rule_tags");
   }
 
   @Test
-  public void should_update_template_rule_language() {
-    setupData("should_update_template_rule_language");
+  public void update_template_rule_language() {
+    setupData("update_template_rule_language");
     task.start();
 
-    checkTables("should_update_template_rule_language", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("update_template_rule_language", EXCLUDED_COLUMN_NAMES, "rules");
   }
 
   /**
@@ -100,11 +104,11 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void should_reactivate_disabled_rules() {
-    setupData("should_reactivate_disabled_rules");
+  public void reactivate_disabled_rules() {
+    setupData("reactivate_disabled_rules");
     task.start();
 
-    checkTables("should_reactivate_disabled_rules", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("reactivate_disabled_rules", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
 
     assertThat(ruleDao.selectById(1).getUpdatedAt()).isNotNull();
   }
@@ -114,72 +118,72 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
     setupData("reactivate_disabled_template_rules");
     task.start();
 
-    checkTables("reactivate_disabled_template_rules", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("reactivate_disabled_template_rules", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
   }
 
   @Test
-  public void should_disable_deprecated_active_rules() {
-    setupData("should_disable_deprecated_active_rules");
+  public void disable_deprecated_active_rules() {
+    setupData("disable_deprecated_active_rules");
     task.start();
 
-    checkTables("should_disable_deprecated_active_rules", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("disable_deprecated_active_rules", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
   }
 
   @Test
-  public void should_disable_deprecated_active_rule_params() {
-    setupData("should_disable_deprecated_active_rule_params");
+  public void disable_deprecated_active_rule_params() {
+    setupData("disable_deprecated_active_rule_params");
     task.start();
 
-    checkTables("should_disable_deprecated_active_rule_params", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters", "active_rules", "active_rule_parameters");
+    checkTables("disable_deprecated_active_rule_params", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules", "rules_parameters", "active_rules", "active_rule_parameters");
   }
 
   @Test
-  public void should_disable_deprecated_rules() {
-    setupData("should_disable_deprecated_rules");
+  public void disable_deprecated_rules() {
+    setupData("disable_deprecated_rules");
     task.start();
 
-    checkTables("should_disable_deprecated_rules", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters", "rules_rule_tags", "rule_tags");
+    checkTables("disable_deprecated_rules", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules", "rules_parameters", "rules_rule_tags", "rule_tags");
   }
 
   @Test
-  public void should_update_rule_fields() {
-    setupData("updadeRuleFields");
+  public void update_rule_fields() {
+    setupData("update_rule_fields");
     task.start();
 
-    checkTables("updadeRuleFields", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters", "rule_tags", "rules_rule_tags");
+    checkTables("update_rule_fields", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters", "rule_tags", "rules_rule_tags");
   }
 
   @Test
-  public void should_update_rule_parameters() {
-    setupData("should_update_rule_parameters");
+  public void update_rule_parameters() {
+    setupData("update_rule_parameters");
     task.start();
 
-    checkTables("should_update_rule_parameters", EXCLUDED_COLUMN_NAMES, "rules", "rules_parameters");
+    checkTables("update_rule_parameters", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules", "rules_parameters");
   }
 
   @Test
-  public void should_not_disable_template_rules_if_parent_is_enabled() {
-    setupData("doNotDisableUserRulesIfParentIsEnabled");
+  public void not_disable_template_rules_if_parent_is_enabled() {
+    setupData("not_disable_template_rules_if_parent_is_enabled");
     task.start();
 
-    checkTables("doNotDisableUserRulesIfParentIsEnabled", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("not_disable_template_rules_if_parent_is_enabled", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
   }
 
   @Test
-  public void should_disable_template_rules_if_parent_is_disabled() {
-    setupData("disableUserRulesIfParentIsDisabled");
+  public void disable_template_rules_if_parent_is_disabled() {
+    setupData("disable_template_rules_if_parent_is_disabled");
     task.start();
 
-    checkTables("disableUserRulesIfParentIsDisabled", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("disable_template_rules_if_parent_is_disabled", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
   }
 
   @Test
-  public void should_not_disable_manual_rules() {
+  public void not_disable_manual_rules() {
     // the hardcoded repository "manual" is used for manual violations
-    setupData("shouldNotDisableManualRules");
+    setupData("not_disable_manual_rules");
     task.start();
 
-    checkTables("shouldNotDisableManualRules", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("not_disable_manual_rules", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
   }
 
   @Test
@@ -197,15 +201,15 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
   }
 
   @Test
-  public void should_insert_extended_repositories() {
+  public void insert_extended_repositories() {
     task = new RuleRegistration(new RuleDefinitionsLoader(mock(RuleRepositories.class), new RuleDefinitions[]{
-        new FindbugsRepository(), new FbContribRepository()}),
+      new FindbugsRepository(), new FbContribRepository()}),
       profilesManager, ruleRegistry, esRuleTags, ruleTagOperations, myBatis, ruleDao, ruleTagDao, activeRuleDao);
 
     setupData("empty");
     task.start();
 
-    checkTables("should_insert_extended_repositories", EXCLUDED_COLUMN_NAMES, "rules");
+    checkTables("insert_extended_repositories", EXCLUDED_COLUMN_NAMES_INCLUDING_DEBT, "rules");
   }
 
   static class FakeRepository implements RuleDefinitions {
@@ -214,19 +218,24 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
       NewRepository repo = context.newRepository("fake", "java");
 
       NewRule rule1 = repo.newRule("rule1")
-          .setName("One")
-          .setHtmlDescription("Description of One")
-          .setSeverity(Severity.BLOCKER)
-          .setInternalKey("config1")
-          .setTags("tag1", "tag3", "tag5");
+        .setName("One")
+        .setHtmlDescription("Description of One")
+        .setSeverity(Severity.BLOCKER)
+        .setCharacteristicKey("COMPILER")
+        .setRemediationFunction(RemediationFunction.LINEAR_OFFSET)
+        .setRemediationFactor("5d")
+        .setRemediationOffset("10h")
+        .setEffortToFixL10nKey("squid.S115.effortToFix")
+        .setInternalKey("config1")
+        .setTags("tag1", "tag3", "tag5");
       rule1.newParam("param1").setDescription("parameter one").setDefaultValue("default value one");
       rule1.newParam("param2").setDescription("parameter two").setDefaultValue("default value two");
 
       repo.newRule("rule2")
-          .setName("Two")
-          .setHtmlDescription("Description of Two")
-          .setSeverity(Severity.INFO)
-          .setStatus(RuleStatus.DEPRECATED);
+        .setName("Two")
+        .setHtmlDescription("Description of Two")
+        .setSeverity(Severity.INFO)
+        .setStatus(RuleStatus.DEPRECATED);
       repo.done();
     }
   }
@@ -239,11 +248,11 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
       NewRepository repo = context.newRepository("big", "java");
       for (int i = 0; i < SIZE; i++) {
         NewRule rule = repo.newRule("rule" + i)
-            .setName("name of " + i)
-            .setHtmlDescription("description of " + i)
-            .setSeverity(Severity.BLOCKER)
-            .setInternalKey("config1")
-            .setTags("tag1", "tag3", "tag5");
+          .setName("name of " + i)
+          .setHtmlDescription("description of " + i)
+          .setSeverity(Severity.BLOCKER)
+          .setInternalKey("config1")
+          .setTags("tag1", "tag3", "tag5");
         for (int j = 0; j < 20; j++) {
           rule.newParam("param" + j);
         }
@@ -258,8 +267,8 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
     public void define(Context context) {
       NewRepository repo = context.newRepository("findbugs", "java");
       repo.newRule("rule1")
-          .setName("Rule One")
-          .setHtmlDescription("Description of Rule One");
+        .setName("Rule One")
+        .setHtmlDescription("Description of Rule One");
       repo.done();
     }
   }
@@ -269,8 +278,8 @@ public class RuleRegistrationTest extends AbstractDaoTestCase {
     public void define(Context context) {
       NewExtendedRepository repo = context.extendRepository("findbugs", "java");
       repo.newRule("rule2")
-          .setName("Rule Two")
-          .setHtmlDescription("Description of Rule Two");
+        .setName("Rule Two")
+        .setHtmlDescription("Description of Rule Two");
       repo.done();
     }
   }
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disableUserRulesIfParentIsDisabled-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disableUserRulesIfParentIsDisabled-result.xml
deleted file mode 100644 (file)
index 9b4c8e7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="disabled_rule" plugin_name="fake" plugin_config_key="[null]" name="Disabled rule" description="[null]"
-         status="REMOVED" priority="4" cardinality="MULTIPLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="1" language="[null]"/>
-
-  <rules id="3" plugin_rule_key="disabled_rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
-         status="REMOVED" priority="1" cardinality="SINGLE" parent_id="[null]"  language="[null]"/>
-
-  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="3" language="[null]"/>
-
-  <rules id="5" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="6" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disableUserRulesIfParentIsDisabled.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disableUserRulesIfParentIsDisabled.xml
deleted file mode 100644 (file)
index 3d583d9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<dataset>
-
-  <!-- Rule as been removed -->
-  <rules id="1" plugin_rule_key="disabled_rule" plugin_name="fake" plugin_config_key="[null]" name="Disabled rule" description="[null]"
-         status="REMOVED" priority="4" cardinality="MULTIPLE" parent_id="[null]"/>
-
-  <!-- user rule duplicated from rule 1. It is currently enabled. -->
-  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="1"/>
-
-  <!-- This rule will be removed... -->
-  <rules id="3" plugin_rule_key="disabled_rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
-         status="READY" priority="1" cardinality="SINGLE" parent_id="[null]" />
-
-  <!-- ...so this template will be removed too -->
-  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="3"/>
-
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rule_params-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rule_params-result.xml
new file mode 100644 (file)
index 0000000..d802714
--- /dev/null
@@ -0,0 +1,17 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
+  <rules_parameters id="2" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
+
+  <rules_profiles id="1" version="1" used_profile="true" name="profile name" language="java" />
+  <active_rules id="1" rule_id="1" profile_id="1" failure_level="4" inheritance="[null]" />
+  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="one" rules_parameter_key="[null]"/>
+  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" value="two" rules_parameter_key="[null]"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rule_params.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rule_params.xml
new file mode 100644 (file)
index 0000000..8b124e9
--- /dev/null
@@ -0,0 +1,21 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description"
+         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" />
+
+  <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/>
+  <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="STRING"/>
+
+  <!-- to be removed -->
+  <rules_parameters id="3" rule_id="1" name="param3" description="[null]" param_type="STRING"/>
+
+
+  <rules_profiles id="1" version="1" used_profile="true" name="profile name" language="java" />
+  <active_rules id="1" rule_id="1" profile_id="1" failure_level="4" />
+  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="one" />
+  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" value="two" />
+
+  <!-- to be removed -->
+  <active_rule_parameters id="3" active_rule_id="1" rules_parameter_id="3" value="three" />
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rules-result.xml
new file mode 100644 (file)
index 0000000..9d78242
--- /dev/null
@@ -0,0 +1,15 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="3" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_active_rules.xml
new file mode 100644 (file)
index 0000000..1e4bfe7
--- /dev/null
@@ -0,0 +1,15 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/>
+
+  <rules_profiles id="1" version="1" used_profile="true" name="sonar way" language="java" />
+  <active_rules id="1" rule_id="1" profile_id="1" failure_level="4" />
+  <active_rules id="2" rule_id="2" profile_id="1" failure_level="0" />
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_repositories-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_repositories-result.xml
new file mode 100644 (file)
index 0000000..c360f76
--- /dev/null
@@ -0,0 +1,17 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+     status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="2" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+  <rules_parameters id="1" rule_id="2" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
+  <rules_parameters id="2" rule_id="2" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
+  <rule_tags id="1" rule_id="2" tag="tag1" tag_type="SYSTEM"/>
+  <rule_tags id="2" rule_id="2" tag="tag3" tag_type="SYSTEM"/>
+  <rule_tags id="3" rule_id="2" tag="tag5" tag_type="SYSTEM"/>
+
+  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="rule2" name="Two" description="Description of Two"
+                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+  
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_rules-result.xml
new file mode 100644 (file)
index 0000000..6fbbd45
--- /dev/null
@@ -0,0 +1,28 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING" default_value="[null]"/>
+
+  <rules id="3" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules_parameters id="2" rule_id="3" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
+  <rules_parameters id="3" rule_id="3" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
+
+  <rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rule_tags id="3" tag="tag1"/>
+  <rule_tags id="4" tag="tag3"/>
+  <rule_tags id="5" tag="tag5"/>
+
+  <rules_rule_tags id="3" rule_id="3" rule_tag_id="3" tag_type="SYSTEM"/>
+  <rules_rule_tags id="4" rule_id="3" rule_tag_id="4" tag_type="SYSTEM"/>
+  <rules_rule_tags id="5" rule_id="3" rule_tag_id="5" tag_type="SYSTEM"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_deprecated_rules.xml
new file mode 100644 (file)
index 0000000..02da4a3
--- /dev/null
@@ -0,0 +1,17 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/>
+
+  <rule_tags id="1" tag="formertag1"/>
+  <rule_tags id="2" tag="formertag2"/>
+
+  <rules_rule_tags id="1" rule_id="1" rule_tag_id="1" tag_type="SYSTEM"/>
+  <rules_rule_tags id="2" rule_id="1" rule_tag_id="2" tag_type="ADMIN"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_template_rules_if_parent_is_disabled-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_template_rules_if_parent_is_disabled-result.xml
new file mode 100644 (file)
index 0000000..9b4c8e7
--- /dev/null
@@ -0,0 +1,21 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="disabled_rule" plugin_name="fake" plugin_config_key="[null]" name="Disabled rule" description="[null]"
+         status="REMOVED" priority="4" cardinality="MULTIPLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="1" language="[null]"/>
+
+  <rules id="3" plugin_rule_key="disabled_rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
+         status="REMOVED" priority="1" cardinality="SINGLE" parent_id="[null]"  language="[null]"/>
+
+  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="3" language="[null]"/>
+
+  <rules id="5" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="6" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_template_rules_if_parent_is_disabled.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/disable_template_rules_if_parent_is_disabled.xml
new file mode 100644 (file)
index 0000000..3ec546d
--- /dev/null
@@ -0,0 +1,19 @@
+<dataset>
+
+  <!-- Rule as been removed -->
+  <rules id="1" plugin_rule_key="disabled_rule" plugin_name="fake" plugin_config_key="[null]" name="Disabled rule" description="[null]"
+         status="REMOVED" priority="4" cardinality="MULTIPLE" parent_id="[null]"/>
+
+  <!-- user rule duplicated from rule 1. It is currently enabled. -->
+  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="1"/>
+
+  <!-- This rule will be removed... -->
+  <rules id="3" plugin_rule_key="disabled_rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
+         status="READY" priority="1" cardinality="SINGLE" parent_id="[null]" />
+
+  <!-- ...so this template will be removed too -->
+  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="3"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/doNotDisableUserRulesIfParentIsEnabled-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/doNotDisableUserRulesIfParentIsEnabled-result.xml
deleted file mode 100644 (file)
index ddc9c94..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-     status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-     status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
-
-  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-     status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/doNotDisableUserRulesIfParentIsEnabled.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/doNotDisableUserRulesIfParentIsEnabled.xml
deleted file mode 100644 (file)
index e45fb2e..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Rule one" description="[null]"
-         status="READY" priority="4" cardinality="MULTIPLE" parent_id="[null]"/>
-
-  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="1"/>
-
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_extended_repositories-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_extended_repositories-result.xml
new file mode 100644 (file)
index 0000000..c8b08ab
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="findbugs" plugin_config_key="[null]" name="Rule One" description="Description of Rule One"
+     status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+    <rules id="2" plugin_rule_key="rule2" plugin_name="findbugs" plugin_config_key="[null]" name="Rule Two" description="Description of Rule Two"
+         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/insert_new_rules-result.xml
new file mode 100644 (file)
index 0000000..050c8b4
--- /dev/null
@@ -0,0 +1,58 @@
+<!--
+  ~ SonarQube, open source software quality management tool.
+  ~ Copyright (C) 2008-2013 SonarSource
+  ~ mailto:contact AT sonarsource DOT com
+  ~
+  ~ SonarQube is free software; you can redistribute it and/or
+  ~ modify it under the terms of the GNU Lesser General Public
+  ~ License as published by the Free Software Foundation; either
+  ~ version 3 of the License, or (at your option) any later version.
+  ~
+  ~ SonarQube is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public License
+  ~ along with this program; if not, write to the Free Software Foundation,
+  ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+  -->
+
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]"/>
+
+  <rules id="2" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
+         remediation_factor="[null]" default_remediation_factor="5d"
+         remediation_offset="[null]" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix"/>
+
+  <rules_parameters id="1" rule_id="2" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
+  <rules_parameters id="2" rule_id="2" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
+
+  <rule_tags id="1" tag="tag1"/>
+  <rule_tags id="2" tag="tag3"/>
+  <rule_tags id="3" tag="tag5"/>
+
+  <rules_rule_tags id="1" rule_id="2" rule_tag_id="1" tag_type="SYSTEM"/>
+  <rules_rule_tags id="2" rule_id="2" rule_tag_id="2" tag_type="SYSTEM"/>
+  <rules_rule_tags id="3" rule_id="2" rule_tag_id="3" tag_type="SYSTEM"/>
+
+  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_manual_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_manual_rules-result.xml
new file mode 100644 (file)
index 0000000..7aa9839
--- /dev/null
@@ -0,0 +1,15 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="PerformanceIssue" plugin_name="manual" plugin_config_key="[null]" name="Performance Issue" description="[null]"
+         status="READY" priority="[null]" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="2" plugin_rule_key="IllegalExceptionCheck" plugin_name="checkstyle" plugin_config_key="[null]" name="Illegal Exception" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
+
+  <rules id="3" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_manual_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_manual_rules.xml
new file mode 100644 (file)
index 0000000..f745b82
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="PerformanceIssue" plugin_name="manual" plugin_config_key="[null]" name="Performance Issue" description="[null]"
+         status="READY" priority="[null]" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules id="2" plugin_rule_key="IllegalExceptionCheck" plugin_name="checkstyle" plugin_config_key="[null]" name="Illegal Exception" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_template_rules_if_parent_is_enabled-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_template_rules_if_parent_is_enabled-result.xml
new file mode 100644 (file)
index 0000000..ddc9c94
--- /dev/null
@@ -0,0 +1,12 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+     status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+     status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
+
+  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+     status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_template_rules_if_parent_is_enabled.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_disable_template_rules_if_parent_is_enabled.xml
new file mode 100644 (file)
index 0000000..4260a86
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Rule one" description="[null]"
+         status="READY" priority="4" cardinality="MULTIPLE" parent_id="[null]"/>
+
+  <rules id="2" plugin_rule_key="user_rule" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="1"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_update_already_disabled_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_update_already_disabled_rules-result.xml
new file mode 100644 (file)
index 0000000..c8f9fa8
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="rule2" name="Two" description="Description of Two"
+                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_update_already_disabled_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/not_update_already_disabled_rules.xml
new file mode 100644 (file)
index 0000000..7a8a2fa
--- /dev/null
@@ -0,0 +1,6 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/reactivate_disabled_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/reactivate_disabled_rules-result.xml
new file mode 100644 (file)
index 0000000..18f0f55
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/reactivate_disabled_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/reactivate_disabled_rules.xml
new file mode 100644 (file)
index 0000000..146807e
--- /dev/null
@@ -0,0 +1,6 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Old name" description="Old description"
+         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]"/>
+
+</dataset>
index 68ec4b5e99b2e177de5ba0554d46f13380886ce9..84192cc4810a77f8738fc06d91eaa3c18aaaf1ff 100644 (file)
@@ -3,4 +3,4 @@
   <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
                    status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
 
-</dataset>
\ No newline at end of file
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shouldNotDisableManualRules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shouldNotDisableManualRules-result.xml
deleted file mode 100644 (file)
index 7aa9839..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="PerformanceIssue" plugin_name="manual" plugin_config_key="[null]" name="Performance Issue" description="[null]"
-         status="READY" priority="[null]" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="2" plugin_rule_key="IllegalExceptionCheck" plugin_name="checkstyle" plugin_config_key="[null]" name="Illegal Exception" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="3" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shouldNotDisableManualRules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/shouldNotDisableManualRules.xml
deleted file mode 100644 (file)
index cc9e9f7..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="PerformanceIssue" plugin_name="manual" plugin_config_key="[null]" name="Performance Issue" description="[null]"
-         status="READY" priority="[null]" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules id="2" plugin_rule_key="IllegalExceptionCheck" plugin_name="checkstyle" plugin_config_key="[null]" name="Illegal Exception" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rule_params-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rule_params-result.xml
deleted file mode 100644 (file)
index d802714..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
-  <rules_parameters id="2" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
-
-  <rules_profiles id="1" version="1" used_profile="true" name="profile name" language="java" />
-  <active_rules id="1" rule_id="1" profile_id="1" failure_level="4" inheritance="[null]" />
-  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="one" rules_parameter_key="[null]"/>
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" value="two" rules_parameter_key="[null]"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rule_params.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rule_params.xml
deleted file mode 100644 (file)
index 8b124e9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description"
-         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" />
-
-  <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/>
-  <rules_parameters id="2" rule_id="1" name="param2" description="[null]" param_type="STRING"/>
-
-  <!-- to be removed -->
-  <rules_parameters id="3" rule_id="1" name="param3" description="[null]" param_type="STRING"/>
-
-
-  <rules_profiles id="1" version="1" used_profile="true" name="profile name" language="java" />
-  <active_rules id="1" rule_id="1" profile_id="1" failure_level="4" />
-  <active_rule_parameters id="1" active_rule_id="1" rules_parameter_id="1" value="one" />
-  <active_rule_parameters id="2" active_rule_id="1" rules_parameter_id="2" value="two" />
-
-  <!-- to be removed -->
-  <active_rule_parameters id="3" active_rule_id="1" rules_parameter_id="3" value="three" />
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rules-result.xml
deleted file mode 100644 (file)
index 9d78242..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="3" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_active_rules.xml
deleted file mode 100644 (file)
index 1e4bfe7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/>
-
-  <rules_profiles id="1" version="1" used_profile="true" name="sonar way" language="java" />
-  <active_rules id="1" rule_id="1" profile_id="1" failure_level="4" />
-  <active_rules id="2" rule_id="2" profile_id="1" failure_level="0" />
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_repositories-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_repositories-result.xml
deleted file mode 100644 (file)
index c360f76..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-     status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="2" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-  <rules_parameters id="1" rule_id="2" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
-  <rules_parameters id="2" rule_id="2" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
-  <rule_tags id="1" rule_id="2" tag="tag1" tag_type="SYSTEM"/>
-  <rule_tags id="2" rule_id="2" tag="tag3" tag_type="SYSTEM"/>
-  <rule_tags id="3" rule_id="2" tag="tag5" tag_type="SYSTEM"/>
-
-  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="rule2" name="Two" description="Description of Two"
-                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-  
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_rules-result.xml
deleted file mode 100644 (file)
index 6fbbd45..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING" default_value="[null]"/>
-
-  <rules id="3" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules_parameters id="2" rule_id="3" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
-  <rules_parameters id="3" rule_id="3" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
-
-  <rules id="4" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rule_tags id="3" tag="tag1"/>
-  <rule_tags id="4" tag="tag3"/>
-  <rule_tags id="5" tag="tag5"/>
-
-  <rules_rule_tags id="3" rule_id="3" rule_tag_id="3" tag_type="SYSTEM"/>
-  <rules_rule_tags id="4" rule_id="3" rule_tag_id="4" tag_type="SYSTEM"/>
-  <rules_rule_tags id="5" rule_id="3" rule_tag_id="5" tag_type="SYSTEM"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_disable_deprecated_rules.xml
deleted file mode 100644 (file)
index 02da4a3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules id="2" plugin_rule_key="deprecated" plugin_name="fake" plugin_config_key="[null]" name="Deprecated fake" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules_parameters id="1" rule_id="1" name="deprecated-prop" description="[null]" param_type="STRING"/>
-
-  <rule_tags id="1" tag="formertag1"/>
-  <rule_tags id="2" tag="formertag2"/>
-
-  <rules_rule_tags id="1" rule_id="1" rule_tag_id="1" tag_type="SYSTEM"/>
-  <rules_rule_tags id="2" rule_id="1" rule_tag_id="2" tag_type="ADMIN"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_insert_extended_repositories-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_insert_extended_repositories-result.xml
deleted file mode 100644 (file)
index f8650b8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="findbugs" plugin_config_key="[null]" name="Rule One" description="Description of Rule One"
-     status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-    <rules id="2" plugin_rule_key="rule2" plugin_name="findbugs" plugin_config_key="[null]" name="Rule Two" description="Description of Rule Two"
-         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_insert_new_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_insert_new_rules-result.xml
deleted file mode 100644 (file)
index 3c7dff4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-     status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="[null]"/>
-
-  <rules id="2" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-  <rules_parameters id="1" rule_id="2" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
-  <rules_parameters id="2" rule_id="2" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
-
-  <rule_tags id="1" tag="tag1"/>
-  <rule_tags id="2" tag="tag3"/>
-  <rule_tags id="3" tag="tag5"/>
-
-  <rules_rule_tags id="1" rule_id="2" rule_tag_id="1" tag_type="SYSTEM"/>
-  <rules_rule_tags id="2" rule_id="2" rule_tag_id="2" tag_type="SYSTEM"/>
-  <rules_rule_tags id="3" rule_id="2" rule_tag_id="3" tag_type="SYSTEM"/>
-
-  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-  
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_not_update_already_disabled_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_not_update_already_disabled_rules-result.xml
deleted file mode 100644 (file)
index c8f9fa8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="rule2" name="Two" description="Description of Two"
-                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_not_update_already_disabled_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_not_update_already_disabled_rules.xml
deleted file mode 100644 (file)
index 7a8a2fa..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="deprecated-key" plugin_name="deprecated-repo" plugin_config_key="[null]" name="Deprecated" description="[null]"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_reactivate_disabled_rules-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_reactivate_disabled_rules-result.xml
deleted file mode 100644 (file)
index 18f0f55..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_reactivate_disabled_rules.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_reactivate_disabled_rules.xml
deleted file mode 100644 (file)
index 146807e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Old name" description="Old description"
-         status="REMOVED" priority="4" cardinality="SINGLE" parent_id="[null]"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_store_bundle_name_and_description_in_database-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_store_bundle_name_and_description_in_database-result.xml
deleted file mode 100644 (file)
index b7d93c5..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="The One" description="The Description of One"
-     status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="rule2" name="Two" description="Description of Two"
-     status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_rule_parameters-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_rule_parameters-result.xml
deleted file mode 100644 (file)
index 337a28e..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-  <rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
-  <rules_parameters id="3" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_rule_parameters.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_rule_parameters.xml
deleted file mode 100644 (file)
index 6e63e30..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description"
-         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
-         status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"/>
-
-  <rules_parameters id="1" rule_id="1" name="param1" description="old description" param_type="STRING"/>
-  <rules_parameters id="2" rule_id="1" name="deprecated_param" description="deprecated param to be removed" param_type="STRING"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_template_rule_language-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_template_rule_language-result.xml
deleted file mode 100644 (file)
index d59dce6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <!-- Instance of old rule 1 :/ -->
-  <rules id="2" plugin_rule_key="template_rule1" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="java"/>
-
-  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <!-- Template of old rule 3 :/ -->
-  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="DEPRECATED" priority="4" cardinality="SINGLE" parent_id="3" language="java"/>
-
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_template_rule_language.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/should_update_template_rule_language.xml
deleted file mode 100644 (file)
index c8e9ce4..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Rule one" description="[null]"
-         status="READY" priority="4" cardinality="MULTIPLE" parent_id="[null]" language="[null]"/>
-
-  <!-- Instance of rule 1 -->
-  <rules id="2" plugin_rule_key="template_rule1" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="[null]"/>
-
-  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
-         status="DEPRECATED" priority="1" cardinality="MULTIPLE" parent_id="[null]" />
-
-  <!-- Instance of rule 3 -->
-  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
-         status="READY" priority="4" cardinality="SINGLE" parent_id="3"/>
-
-</dataset>
\ No newline at end of file
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/store_bundle_name_and_description_in_database-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/store_bundle_name_and_description_in_database-result.xml
new file mode 100644 (file)
index 0000000..b7d93c5
--- /dev/null
@@ -0,0 +1,9 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="The One" description="The Description of One"
+     status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="rule2" name="Two" description="Description of Two"
+     status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/updadeRuleFields-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/updadeRuleFields-result.xml
deleted file mode 100644 (file)
index 6a94636..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
-                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-  <rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
-  <rules_parameters id="2" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
-
-  <rule_tags id="1" tag="tag1"/>
-  <rule_tags id="3" tag="tag3"/>
-  <rule_tags id="4" tag="tag4"/>
-  <rule_tags id="5" tag="tag5"/>
-
-  <rules_rule_tags id="1" rule_id="1" rule_tag_id="1" tag_type="SYSTEM"/>
-  <rules_rule_tags id="3" rule_id="1" rule_tag_id="3" tag_type="SYSTEM"/>
-  <rules_rule_tags id="4" rule_id="1" rule_tag_id="4" tag_type="ADMIN"/>
-  <rules_rule_tags id="5" rule_id="1" rule_tag_id="5" tag_type="SYSTEM"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
-     status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/updadeRuleFields.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/updadeRuleFields.xml
deleted file mode 100644 (file)
index 7221294..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<dataset>
-
-  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description"
-         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]" />
-
-  <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/>
-
-  <rule_tags id="1" tag="tag1"/>
-  <rule_tags id="2" tag="tag2"/>
-  <rule_tags id="3" tag="tag3"/>
-  <rule_tags id="4" tag="tag4"/>
-
-  <rules_rule_tags id="1" rule_id="1" rule_tag_id="1" tag_type="SYSTEM"/>
-  <rules_rule_tags id="2" rule_id="1" rule_tag_id="2" tag_type="SYSTEM"/>
-  <rules_rule_tags id="3" rule_id="1" rule_tag_id="3" tag_type="ADMIN"/>
-  <rules_rule_tags id="4" rule_id="1" rule_tag_id="4" tag_type="ADMIN"/>
-
-  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
-         status="READY" priority="1" cardinality="SINGLE" parent_id="[null]" />
-
-
-</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields-result.xml
new file mode 100644 (file)
index 0000000..f630e3a
--- /dev/null
@@ -0,0 +1,32 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"
+         characteristic_id="[null]" default_characteristic_id="200"
+         remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
+         remediation_factor="[null]" default_remediation_factor="5d"
+         remediation_offset="[null]" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix"/>
+
+  <rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
+  <rules_parameters id="2" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
+
+  <rule_tags id="1" tag="tag1"/>
+  <rule_tags id="3" tag="tag3"/>
+  <rule_tags id="4" tag="tag4"/>
+  <rule_tags id="5" tag="tag5"/>
+
+  <rules_rule_tags id="1" rule_id="1" rule_tag_id="1" tag_type="SYSTEM"/>
+  <rules_rule_tags id="3" rule_id="1" rule_tag_id="3" tag_type="SYSTEM"/>
+  <rules_rule_tags id="4" rule_id="1" rule_tag_id="4" tag_type="ADMIN"/>
+  <rules_rule_tags id="5" rule_id="1" rule_tag_id="5" tag_type="SYSTEM"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_fields.xml
new file mode 100644 (file)
index 0000000..416104e
--- /dev/null
@@ -0,0 +1,27 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description"
+         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]"
+         characteristic_id="[null]" default_characteristic_id="200"
+         remediation_function="[null]" default_remediation_function="LINEAR"
+         remediation_factor="[null]" default_remediation_factor="14min"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]"/>
+
+  <rules_parameters id="1" rule_id="1" name="param1" description="[null]" param_type="STRING"/>
+
+  <rule_tags id="1" tag="tag1"/>
+  <rule_tags id="2" tag="tag2"/>
+  <rule_tags id="3" tag="tag3"/>
+  <rule_tags id="4" tag="tag4"/>
+
+  <rules_rule_tags id="1" rule_id="1" rule_tag_id="1" tag_type="SYSTEM"/>
+  <rules_rule_tags id="2" rule_id="1" rule_tag_id="2" tag_type="SYSTEM"/>
+  <rules_rule_tags id="3" rule_id="1" rule_tag_id="3" tag_type="ADMIN"/>
+  <rules_rule_tags id="4" rule_id="1" rule_tag_id="4" tag_type="ADMIN"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
+         status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"/>
+
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_parameters-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_parameters-result.xml
new file mode 100644 (file)
index 0000000..337a28e
--- /dev/null
@@ -0,0 +1,11 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+                   status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"/>
+  <rules_parameters id="1" rule_id="1" default_value="default value one" description="parameter one" name="param1" param_type="STRING"/>
+  <rules_parameters id="3" rule_id="1" default_value="default value two" description="parameter two" name="param2" param_type="STRING"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+                   status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_parameters.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_rule_parameters.xml
new file mode 100644 (file)
index 0000000..6e63e30
--- /dev/null
@@ -0,0 +1,12 @@
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="old_config_key" name="old name" description="old description"
+         status="READY" priority="2" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules id="2" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
+         status="READY" priority="1" cardinality="SINGLE" parent_id="[null]"/>
+
+  <rules_parameters id="1" rule_id="1" name="param1" description="old description" param_type="STRING"/>
+  <rules_parameters id="2" rule_id="1" name="deprecated_param" description="deprecated param to be removed" param_type="STRING"/>
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language-result.xml
new file mode 100644 (file)
index 0000000..210511b
--- /dev/null
@@ -0,0 +1,57 @@
+<!--
+  ~ SonarQube, open source software quality management tool.
+  ~ Copyright (C) 2008-2013 SonarSource
+  ~ mailto:contact AT sonarsource DOT com
+  ~
+  ~ SonarQube is free software; you can redistribute it and/or
+  ~ modify it under the terms of the GNU Lesser General Public
+  ~ License as published by the Free Software Foundation; either
+  ~ version 3 of the License, or (at your option) any later version.
+  ~
+  ~ SonarQube is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public License
+  ~ along with this program; if not, write to the Free Software Foundation,
+  ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+  -->
+
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="config1" name="One" description="Description of One"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="[null]" language="java"
+         characteristic_id="[null]" default_characteristic_id="100"
+         remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
+         remediation_factor="[null]" default_remediation_factor="5d"
+         remediation_offset="[null]" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix" />
+
+  <!-- Instance of old rule 1 :/ -->
+  <rules id="2" plugin_rule_key="template_rule1" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="java"
+         characteristic_id="[null]" default_characteristic_id="100"
+         remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
+         remediation_factor="[null]" default_remediation_factor="5d"
+         remediation_offset="[null]" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix" />
+
+  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="[null]" name="Two" description="Description of Two"
+         status="DEPRECATED" priority="0" cardinality="SINGLE" parent_id="[null]" language="java"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]" />
+
+  <!-- Template of old rule 3 :/ -->
+  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="DEPRECATED" priority="4" cardinality="SINGLE" parent_id="3" language="java"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]" />
+
+</dataset>
diff --git a/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml b/sonar-server/src/test/resources/org/sonar/server/rule/RuleRegistrationTest/update_template_rule_language.xml
new file mode 100644 (file)
index 0000000..b5a6352
--- /dev/null
@@ -0,0 +1,57 @@
+<!--
+  ~ SonarQube, open source software quality management tool.
+  ~ Copyright (C) 2008-2013 SonarSource
+  ~ mailto:contact AT sonarsource DOT com
+  ~
+  ~ SonarQube is free software; you can redistribute it and/or
+  ~ modify it under the terms of the GNU Lesser General Public
+  ~ License as published by the Free Software Foundation; either
+  ~ version 3 of the License, or (at your option) any later version.
+  ~
+  ~ SonarQube is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  ~ Lesser General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU Lesser General Public License
+  ~ along with this program; if not, write to the Free Software Foundation,
+  ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+  -->
+
+<dataset>
+
+  <rules id="1" plugin_rule_key="rule1" plugin_name="fake" plugin_config_key="[null]" name="Rule one" description="[null]"
+         status="READY" priority="4" cardinality="MULTIPLE" parent_id="[null]" language="[null]"
+         characteristic_id="[null]" default_characteristic_id="100"
+         remediation_function="[null]" default_remediation_function="LINEAR_OFFSET"
+         remediation_factor="[null]" default_remediation_factor="5d"
+         remediation_offset="[null]" default_remediation_offset="10h"
+         effort_to_fix_l10n_key="squid.S115.effortToFix" />
+
+  <!-- Instance of rule 1 -->
+  <rules id="2" plugin_rule_key="template_rule1" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="1" language="[null]"
+         characteristic_id="[null]" default_characteristic_id="200"
+         remediation_function="[null]" default_remediation_function="LINEAR"
+         remediation_factor="[null]" default_remediation_factor="1h"
+         remediation_offset="[null]" default_remediation_offset="15min"
+         effort_to_fix_l10n_key="squid.S115.effortToFix2" />
+
+  <rules id="3" plugin_rule_key="rule2" plugin_name="fake" plugin_config_key="old_config_key2" name="old name2" description="old description2"
+         status="DEPRECATED" priority="1" cardinality="MULTIPLE" parent_id="[null]"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]" />
+
+  <!-- Instance of rule 3 -->
+  <rules id="4" plugin_rule_key="template_rule2" plugin_name="fake" plugin_config_key="[null]" name="User rule" description="[null]"
+         status="READY" priority="4" cardinality="SINGLE" parent_id="3"
+         characteristic_id="[null]" default_characteristic_id="[null]"
+         remediation_function="[null]" default_remediation_function="[null]"
+         remediation_factor="[null]" default_remediation_factor="[null]"
+         remediation_offset="[null]" default_remediation_offset="[null]"
+         effort_to_fix_l10n_key="[null]" />
+
+</dataset>