aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/test
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-03-01 10:41:59 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-03-02 14:19:36 +0100
commit325c7610b94af87a05860635831ecc4728478e29 (patch)
treea61f37a8a230617ab5f6fde80820e87d6cd14070 /sonar-db/src/test
parent284c6d1ee5deeeab127dc992c85731989c113a43 (diff)
downloadsonarqube-325c7610b94af87a05860635831ecc4728478e29.tar.gz
sonarqube-325c7610b94af87a05860635831ecc4728478e29.zip
SONAR-7329 Feed RULES.RULE_TYPE
Diffstat (limited to 'sonar-db/src/test')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DbTester.java24
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java50
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesTypesTest.java135
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/TagsToTypeTest.java45
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v55/FeedIssueTypesTest/schema.sql21
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate-result.xml87
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate.xml87
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/schema.sql9
9 files changed, 402 insertions, 58 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java
index 9936840875c..64c10150619 100644
--- a/sonar-db/src/test/java/org/sonar/db/DbTester.java
+++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java
@@ -19,6 +19,7 @@
*/
package org.sonar.db;
+import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import java.io.InputStream;
import java.math.BigDecimal;
@@ -62,9 +63,6 @@ import static org.junit.Assert.fail;
/**
* This class should be called using @Rule.
* Data is truncated between each tests. The schema is created between each test.
- * <p>
- * File using {@link DbTester} must be annotated with {@link org.sonar.test.DbTests} so
- * that they can be executed on all supported DBs (Oracle, MySQL, ...).
*/
public class DbTester extends ExternalResource {
@@ -135,8 +133,24 @@ public class DbTester extends ExternalResource {
try (Connection connection = db.getDatabase().getDataSource().getConnection()) {
new QueryRunner().update(connection, sql);
} catch (Exception e) {
- throw new IllegalStateException("Fail to execute sql: " + sql);
+ throw new IllegalStateException("Fail to execute sql: " + sql, e);
+ }
+ }
+
+ /**
+ * Very simple helper method to insert some data into a table.
+ * It's the responsibility of the caller to convert column values to string.
+ */
+ public void executeInsert(String table, Map<String, String> valuesByColumn){
+ if (valuesByColumn.isEmpty()) {
+ throw new IllegalArgumentException("Values cannot be empty");
}
+ String sql = "insert into " + table.toLowerCase() + " (" +
+ Joiner.on(", ").join(valuesByColumn.keySet()) +
+ ") values ('" +
+ Joiner.on("', '").join(valuesByColumn.values()) +
+ "')";
+ executeUpdateSql(sql);
}
/**
@@ -377,7 +391,7 @@ public class DbTester extends ExternalResource {
}
}
- private void closeQuietly(IDatabaseConnection connection) {
+ private void closeQuietly(@Nullable IDatabaseConnection connection) {
try {
if (connection != null) {
connection.close();
diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
index 8de7b00ca97..a4ed4bd9e31 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
public void verify_count_of_added_MigrationStep_types() {
ComponentContainer container = new ComponentContainer();
new MigrationStepModule().configure(container);
- assertThat(container.size()).isEqualTo(60);
+ assertThat(container.size()).isEqualTo(61);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java
index 42ac6cbee1a..0998ab7f6cb 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java
@@ -19,60 +19,48 @@
*/
package org.sonar.db.version.v55;
-import java.util.Arrays;
-import java.util.Collections;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.utils.System2;
import org.sonar.core.rule.RuleType;
-import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
-import org.sonar.db.issue.IssueDto;
import org.sonar.db.version.MigrationStep;
-import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-import static org.sonar.db.version.v55.FeedIssueTypes.tagsToType;
public class FeedIssueTypesTest {
+ static final Joiner TAGS_JOINER = Joiner.on(",");
+
@Rule
public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedIssueTypesTest.class, "schema.sql");
@Test
- public void test_tagsToType() {
- assertThat(tagsToType(asList("misra", "bug"))).isEqualTo(RuleType.BUG);
- assertThat(tagsToType(asList("misra", "security"))).isEqualTo(RuleType.VULNERABILITY);
+ public void test_migration() throws Exception {
+ insertIssue("code_smell", "clumsy", "spring");
+ insertIssue("without_tags");
+ insertIssue("bug", "clumsy", "bug");
- // "bug" has priority on "security"
- assertThat(tagsToType(asList("security", "bug"))).isEqualTo(RuleType.BUG);
+ MigrationStep underTest = new FeedIssueTypes(db.database(), mock(System2.class));
+ underTest.execute();
- // default is "code smell"
- assertThat(tagsToType(asList("clumsy", "spring"))).isEqualTo(RuleType.CODE_SMELL);
- assertThat(tagsToType(Collections.<String>emptyList())).isEqualTo(RuleType.CODE_SMELL);
+ assertType("code_smell", RuleType.CODE_SMELL);
+ assertType("without_tags", RuleType.CODE_SMELL);
+ assertType("bug", RuleType.BUG);
}
- @Test
- public void test_migration() throws Exception {
- try (DbSession dbSession = db.getSession()) {
- IssueDto codeSmell = new IssueDto().setKee("code_smell").setTags(Arrays.asList("clumsy", "spring"));
- IssueDto withoutTags = new IssueDto().setKee("without_tags");
- IssueDto bug = new IssueDto().setKee("bug").setTags(Arrays.asList("clumsy", "bug"));
- db.getDbClient().issueDao().insert(dbSession, codeSmell, withoutTags, bug);
- dbSession.commit();
-
- MigrationStep underTest = new FeedIssueTypes(db.database(), mock(System2.class));
- underTest.execute();
-
- assertType("code_smell", RuleType.CODE_SMELL);
- assertType("without_tags", RuleType.CODE_SMELL);
- assertType("bug", RuleType.BUG);
- }
+ private void insertIssue(String key, String... tags) {
+ db.executeInsert("issues", ImmutableMap.of(
+ "kee", key,
+ "tags", TAGS_JOINER.join(tags)
+ ));
}
private void assertType(String issueKey, RuleType expectedType) {
- Number type = (Number)db.selectFirst("select * from issues where kee='" + issueKey + "'").get("ISSUE_TYPE");
+ Number type = (Number) db.selectFirst("select * from issues where kee='" + issueKey + "'").get("ISSUE_TYPE");
assertThat(type.intValue()).isEqualTo(expectedType.getDbConstant());
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesTypesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesTypesTest.java
new file mode 100644
index 00000000000..d24721e97f4
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesTypesTest.java
@@ -0,0 +1,135 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.db.version.v55;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.core.rule.RuleType;
+import org.sonar.db.DbTester;
+import org.sonar.db.version.MigrationStep;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class FeedRulesTypesTest {
+
+ @Rule
+ public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedRulesTypesTest.class, "schema.sql");
+
+ static final Joiner TAGS_JOINER = Joiner.on(",");
+
+ System2 system2 = mock(System2.class);
+
+ static final long BEFORE = 1000L;
+ static final long NOW = 2000L;
+
+ MigrationStep underTest;
+
+ @Before
+ public void setUp() throws Exception {
+ when(system2.now()).thenReturn(NOW);
+ underTest = new FeedRulesTypes(db.database(), system2);
+ }
+
+ @Test
+ public void set_type_depending_on_system_tags() throws Exception {
+ insertRuleWithSystemTags("only_performance", "performance");
+ insertRuleWithSystemTags("no_tag");
+ insertRuleWithSystemTags("only_bug", "bug");
+ insertRuleWithSystemTags("security", "security", "test");
+ insertRuleWithSystemTags("bug_and_security", "security", "bug");
+ insertRuleWithType("type_already_exists", RuleType.BUG);
+
+ underTest.execute();
+
+ assertRule("only_performance", RuleType.CODE_SMELL, "performance", NOW);
+ assertRule("no_tag", RuleType.CODE_SMELL, "", NOW);
+ assertRule("only_bug", RuleType.BUG, "", NOW);
+ assertRule("security", RuleType.VULNERABILITY, "test", NOW);
+ assertRule("bug_and_security", RuleType.BUG, "", NOW);
+ assertRule("type_already_exists", RuleType.BUG, null, BEFORE);
+ }
+
+ @Test
+ public void remove_forbidden_user_tags() throws Exception {
+ insertRuleWithUserTags("only_performance", "performance");
+ insertRuleWithUserTags("no_tag");
+ insertRuleWithUserTags("only_bug", "bug");
+ insertRuleWithUserTags("security", "security", "test");
+ insertRuleWithUserTags("bug_and_security", "security", "bug");
+
+ underTest.execute();
+
+ assertRuleWithUserTags("only_performance", "performance", NOW);
+ assertRuleWithUserTags("no_tag", "", NOW);
+ assertRuleWithUserTags("only_bug", "", NOW);
+ assertRuleWithUserTags("security", "test", NOW);
+ assertRuleWithUserTags("bug_and_security", "", NOW);
+ }
+
+ private void assertRule(String ruleKey, RuleType expectedType, @Nullable String systemTags, long updatedAt) {
+ Map<String, Object> rule = db.selectFirst("select rule_type as \"ruleType\", system_tags as \"systemTags\", updated_at as \"updatedAt\" from rules where plugin_rule_key='"
+ + ruleKey + "'");
+ assertThat(((Number) rule.get("ruleType")).intValue()).isEqualTo(expectedType.getDbConstant());
+ assertThat(rule.get("systemTags")).isEqualTo(systemTags);
+ assertThat(rule.get("updatedAt")).isEqualTo(updatedAt);
+ }
+
+ private void assertRuleWithUserTags(String ruleKey, @Nullable String tags, long updatedAt) {
+ Map<String, Object> rule = db.selectFirst("select tags as \"tags\", updated_at as \"updatedAt\" from rules where plugin_rule_key='" + ruleKey + "'");
+ assertThat(rule.get("tags")).isEqualTo(tags);
+ assertThat(rule.get("updatedAt")).isEqualTo(updatedAt);
+ }
+
+ private void insertRuleWithSystemTags(String ruleKey, String... systemTags) {
+ db.executeInsert("rules", ImmutableMap.of(
+ "plugin_rule_key", ruleKey,
+ "system_tags", TAGS_JOINER.join(systemTags),
+ "created_at", Long.toString(BEFORE),
+ "updated_at", Long.toString(BEFORE)
+ ));
+ }
+
+ private void insertRuleWithUserTags(String ruleKey, String... userTags) {
+ db.executeInsert("rules", ImmutableMap.of(
+ "plugin_rule_key", ruleKey,
+ "tags", TAGS_JOINER.join(userTags),
+ "created_at", Long.toString(BEFORE),
+ "updated_at", Long.toString(BEFORE)
+ ));
+ }
+
+ private void insertRuleWithType(String ruleKey, RuleType type) {
+ db.executeInsert("rules", ImmutableMap.of(
+ "plugin_rule_key", ruleKey,
+ "rule_type", Integer.toString(type.getDbConstant()),
+ "created_at", Long.toString(BEFORE),
+ "updated_at", Long.toString(BEFORE)
+ ));
+ }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/TagsToTypeTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/TagsToTypeTest.java
new file mode 100644
index 00000000000..a140543a595
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/TagsToTypeTest.java
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.db.version.v55;
+
+import java.util.Collections;
+import org.junit.Test;
+import org.sonar.api.rules.RuleType;
+
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.db.version.v55.TagsToType.tagsToType;
+
+public class TagsToTypeTest {
+
+ @Test
+ public void test_tagsToType() {
+ assertThat(tagsToType(asList("misra", "bug"))).isEqualTo(RuleType.BUG);
+ assertThat(tagsToType(asList("misra", "security"))).isEqualTo(RuleType.VULNERABILITY);
+
+ // "bug" has priority on "security"
+ assertThat(tagsToType(asList("security", "bug"))).isEqualTo(RuleType.BUG);
+
+ // default is "code smell"
+ assertThat(tagsToType(asList("clumsy", "spring"))).isEqualTo(RuleType.CODE_SMELL);
+ assertThat(tagsToType(Collections.<String>emptyList())).isEqualTo(RuleType.CODE_SMELL);
+ }
+
+}
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedIssueTypesTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedIssueTypesTest/schema.sql
index b7526a5d2bb..9289b3abf57 100644
--- a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedIssueTypesTest/schema.sql
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedIssueTypesTest/schema.sql
@@ -1,29 +1,8 @@
CREATE TABLE "ISSUES" (
"ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"KEE" VARCHAR(50) UNIQUE NOT NULL,
- "COMPONENT_UUID" VARCHAR(50),
- "PROJECT_UUID" VARCHAR(50),
- "RULE_ID" INTEGER,
- "SEVERITY" VARCHAR(10),
- "MANUAL_SEVERITY" BOOLEAN NOT NULL,
- "MESSAGE" VARCHAR(4000),
- "LINE" INTEGER,
- "EFFORT_TO_FIX" DOUBLE,
- "TECHNICAL_DEBT" INTEGER,
- "STATUS" VARCHAR(20),
- "RESOLUTION" VARCHAR(20),
- "CHECKSUM" VARCHAR(1000),
- "REPORTER" VARCHAR(255),
- "ASSIGNEE" VARCHAR(255),
- "AUTHOR_LOGIN" VARCHAR(255),
- "ACTION_PLAN_KEY" VARCHAR(50) NULL,
- "ISSUE_ATTRIBUTES" VARCHAR(4000),
"TAGS" VARCHAR(4000),
- "ISSUE_CREATION_DATE" BIGINT,
- "ISSUE_CLOSE_DATE" BIGINT,
- "ISSUE_UPDATE_DATE" BIGINT,
"CREATED_AT" BIGINT,
"UPDATED_AT" BIGINT,
- "LOCATIONS" BLOB(167772150),
"ISSUE_TYPE" TINYINT
);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate-result.xml b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate-result.xml
new file mode 100644
index 00000000000..fd3675f51ca
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate-result.xml
@@ -0,0 +1,87 @@
+<dataset>
+
+ <!-- performance tag => type is CODE_SMELL (1) -->
+ <rules id="1" name="Null Pointer" plugin_rule_key="S001"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="performance" system_tags="cwe"
+ rule_type="1"
+ created_at="1000000000000" updated_at="2000000000000"
+ />
+
+ <!-- No tag => type is CODE_SMELL (1) -->
+ <rules id="2" name="Slow" plugin_rule_key="S002"
+ plugin_config_key="S2" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="BETA"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="[null]" system_tags="[null]"
+ rule_type="1"
+ created_at="1000000000000" updated_at="2000000000000"
+ />
+
+ <!-- bug tag => type is BUG (2) -->
+ <rules id="3" name="Rule3" plugin_rule_key="Rule3"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="" system_tags="cwe"
+ rule_type="[null]"
+ created_at="1000000000000" updated_at="2000000000000"
+ />
+
+ <!-- security tag => type is VULNERABILITY (3) -->
+ <rules id="4" name="Rule4" plugin_rule_key="Rule4"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="test" system_tags="cwe"
+ rule_type="3"
+ created_at="1000000000000" updated_at="2000000000000"
+ />
+
+ <!-- bug and security tags => type is CODE_SMELL (1) -->
+ <rules id="5" name="Rule5" plugin_rule_key="Rule5"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="bug" system_tags="cwe"
+ rule_type="1"
+ created_at="1000000000000" updated_at="2000000000000"
+ />
+
+ <!-- re-entrant migration - ignore the rules that are already fed with type -->
+ <rules id="10" name="Down" plugin_rule_key="S003"
+ plugin_config_key="S3" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="BETA"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="[null]" system_tags="[null]"
+ rule_type="1"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate.xml b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate.xml
new file mode 100644
index 00000000000..22c27deea0a
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/migrate.xml
@@ -0,0 +1,87 @@
+<dataset>
+
+ <!-- performance tag => type should be CODE_SMELL (1) -->
+ <rules id="1" name="Null Pointer" plugin_rule_key="S001"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="performance" system_tags="cwe"
+ rule_type="[null]"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+ <!-- No tag => type should be CODE_SMELL (1) -->
+ <rules id="2" name="Slow" plugin_rule_key="S002"
+ plugin_config_key="S2" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="BETA"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="[null]" system_tags="[null]"
+ rule_type="0"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+ <!-- bug tag => type should be BUG (2) -->
+ <rules id="3" name="Rule3" plugin_rule_key="Rule3"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="bug" system_tags="cwe"
+ rule_type="[null]"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+ <!-- security tag => type should be VULNERABILITY (3) -->
+ <rules id="4" name="Rule4" plugin_rule_key="Rule4"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="security,test" system_tags="cwe"
+ rule_type="[null]"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+ <!-- bug and security tags => type should be CODE_SMELL (1) -->
+ <rules id="5" name="Rule5" plugin_rule_key="Rule5"
+ plugin_config_key="S1" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="READY"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="security,bug" system_tags="cwe"
+ rule_type="[null]"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+ <!-- re-entrant migration - ignore the rules that are already fed with type -->
+ <rules id="10" name="Down" plugin_rule_key="S003"
+ plugin_config_key="S3" plugin_name="java" description="[null]" description_format="[null]" priority="4" status="BETA"
+ note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" language="java"
+ remediation_function="[null]" default_remediation_function="[null]"
+ remediation_coeff="[null]" default_remediation_coeff="[null]"
+ remediation_offset="[null]" default_remediation_offset="[null]"
+ effort_to_fix_description="[null]"
+ is_template="[false]" template_id="[null]"
+ tags="[null]" system_tags="[null]"
+ rule_type="1"
+ created_at="1000000000000" updated_at="1000000000000"
+ />
+
+</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/schema.sql
new file mode 100644
index 00000000000..838b2c25de4
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesTypesTest/schema.sql
@@ -0,0 +1,9 @@
+CREATE TABLE "RULES" (
+ "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL,
+ "TAGS" VARCHAR(4000),
+ "SYSTEM_TAGS" VARCHAR(4000),
+ "RULE_TYPE" TINYINT,
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT
+);