]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7333 DB migration to set ISSUES.ISSUE_TYPE
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 25 Feb 2016 22:31:28 +0000 (23:31 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 26 Feb 2016 15:27:24 +0000 (16:27 +0100)
20 files changed:
server/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java
server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexer.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/display_facets.json
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1107_feed_issues_types.rb [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/issue/IssueType.java
sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java [new file with mode: 0644]
sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
sonar-db/src/test/java/org/sonar/db/issue/IssueDaoTest.java
sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
sonar-db/src/test/java/org/sonar/db/version/v55/FeedIssueTypesTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java
sonar-db/src/test/resources/org/sonar/db/issue/IssueDaoTest/get_by_key.xml
sonar-db/src/test/resources/org/sonar/db/version/v55/FeedIssueTypesTest/schema.sql [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
sonar-ws/src/main/java/org/sonarqube/ws/client/issue/IssueFilterParameters.java

index 46109f8393614a67377e925f046c1c417ebe9065..a2f7742c812999e7a141196f0876da269120af00 100644 (file)
@@ -44,9 +44,6 @@ import org.sonar.api.web.UserRole;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.core.issue.DefaultIssueBuilder;
 import org.sonar.core.issue.IssueChangeContext;
-import org.sonar.core.issue.IssueType;
-import org.sonar.server.issue.workflow.IssueWorkflow;
-import org.sonar.server.issue.workflow.Transition;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDto;
@@ -59,6 +56,8 @@ import org.sonar.server.issue.actionplan.ActionPlanService;
 import org.sonar.server.issue.index.IssueDoc;
 import org.sonar.server.issue.index.IssueIndex;
 import org.sonar.server.issue.notification.IssueChangeNotification;
+import org.sonar.server.issue.workflow.IssueWorkflow;
+import org.sonar.server.issue.workflow.Transition;
 import org.sonar.server.notification.NotificationManager;
 import org.sonar.server.source.SourceService;
 import org.sonar.server.user.UserSession;
index f4fa7f5b4b07ae0a0716fb23064e492e3d46da71..f7cb3a9ed606add8beb981c1ed595a6032981e20 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue.ws;
 
 import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Lists;
 import com.google.common.io.Resources;
 import java.util.Collection;
@@ -38,7 +37,6 @@ import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.Paging;
 import org.sonar.core.issue.IssueType;
-import org.sonar.server.rule.RuleKeyFunctions;
 import org.sonar.server.es.Facets;
 import org.sonar.server.es.SearchOptions;
 import org.sonar.server.es.SearchResult;
@@ -47,6 +45,7 @@ import org.sonar.server.issue.IssueQueryService;
 import org.sonar.server.issue.IssueService;
 import org.sonar.server.issue.index.IssueDoc;
 import org.sonar.server.issue.index.IssueIndex;
+import org.sonar.server.rule.RuleKeyFunctions;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.Issues.SearchWsResponse;
 import org.sonarqube.ws.client.issue.IssueFilterParameters;
@@ -347,7 +346,7 @@ public class SearchAction implements IssuesWsAction {
     addMandatoryValuesToFacet(facets, IssueFilterParameters.RULES, request.getRules());
     addMandatoryValuesToFacet(facets, IssueFilterParameters.LANGUAGES, request.getLanguages());
     addMandatoryValuesToFacet(facets, IssueFilterParameters.TAGS, request.getTags());
-    addMandatoryValuesToFacet(facets, IssueFilterParameters.TYPES, request.getTypes());
+    addMandatoryValuesToFacet(facets, IssueFilterParameters.TYPES, IssueType.ALL_NAMES);
     List<String> actionPlans = Lists.newArrayList("");
     List<String> actionPlansFromRequest = request.getActionPlans();
     if (actionPlansFromRequest != null) {
index 6cb8f5fe74c1ef72635e3f5656567a60120886ed..cdb8a3b78eeb692857252597a777f56486735857 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.user.index;
 
 import java.util.Iterator;
 import org.elasticsearch.action.index.IndexRequest;
-import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.server.es.BaseIndexer;
index 69295b395da92b2e690218a5e879cc686abc27d2..f6f196f17fef949ac663c08491496b96093ec74b 100644 (file)
@@ -358,7 +358,7 @@ public class SearchActionMediumTest {
     userSessionRule.login("john");
     WsTester.Result result = wsTester.newGetRequest(IssuesWs.API_ENDPOINT, SearchAction.SEARCH_ACTION)
       .setParam("resolved", "false")
-      .setParam(WebService.Param.FACETS, "statuses,severities,resolutions,projectUuids,rules,fileUuids,assignees,languages,actionPlans")
+      .setParam(WebService.Param.FACETS, "statuses,severities,resolutions,projectUuids,rules,fileUuids,assignees,languages,actionPlans,types")
       .execute();
     result.assertJson(this.getClass(), "display_facets.json");
   }
index 439e6889cc0d943adab56d4cc4711852b556719b..4a9a5fb36de6e16826b318e730c7fc6bfa82dace 100644 (file)
           "count": 1
         }
       ]
+    },
+    {
+      "property": "types",
+      "values": [
+        {
+          "val": "CODE_SMELL",
+          "count": 1
+        },
+        {
+          "val": "BUG",
+          "count": 0
+        },
+        {
+          "val": "VULNERABILITY",
+          "count": 0
+        }
+      ]
     }
   ]}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1107_feed_issues_types.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1107_feed_issues_types.rb
new file mode 100644 (file)
index 0000000..213f84e
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 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.
+#
+
+#
+# SonarQube 5.5
+# MMF-141
+#
+class FeedIssuesTypes < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v55.FeedIssueTypes')
+  end
+
+end
index 2ce73537adb42c26967101e5af3eff1796c01ab0..32a20a80891b341c4774ed351b666a31b2a00e4d 100644 (file)
  */
 package org.sonar.core.issue;
 
+import com.google.common.base.Enums;
+import com.google.common.collect.Lists;
+import java.util.List;
+
 import static java.lang.String.format;
 
 public enum IssueType {
@@ -46,4 +50,6 @@ public enum IssueType {
     }
     throw new IllegalArgumentException(format("Unsupported value for db column ISSUES.ISSUE_TYPE: %d", dbConstant));
   }
+
+  public static List<String> ALL_NAMES = Lists.transform(Lists.newArrayList(values()), Enums.stringConverter(IssueType.class).reverse());
 }
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java b/sonar-core/src/test/java/org/sonar/core/issue/IssueTypeTest.java
new file mode 100644 (file)
index 0000000..57bd074
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.core.issue;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class IssueTypeTest {
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  @Test
+  public void test_valueOf_db_constant() {
+    assertThat(IssueType.valueOf(1)).isEqualTo(IssueType.CODE_SMELL);
+    assertThat(IssueType.valueOf(2)).isEqualTo(IssueType.BUG);
+  }
+
+  @Test
+  public void valueOf_throws_ISE_if_unsupported_db_constant() {
+    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expectMessage("Unsupported value for db column ISSUES.ISSUE_TYPE: 4");
+    IssueType.valueOf(4);
+  }
+
+  @Test
+  public void test_ALL_NAMES() {
+    assertThat(IssueType.ALL_NAMES).containsOnly("BUG", "VULNERABILITY", "CODE_SMELL");
+  }
+}
index 113ee4f5fdded16ab2d3d59eaba59d5efe092348..744620671a65cf31915e6ffe0789de11ae8e0372 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.MyBatis;
 
 public class DatabaseVersion {
 
-  public static final int LAST_VERSION = 1106;
+  public static final int LAST_VERSION = 1107;
 
   /**
    * The minimum supported version which can be upgraded. Lower
index 7df3779ced9a288a7a6dc690571ed55a18e4d9b3..ac74da47d4991f30e52761cd77b1b50a364305d2 100644 (file)
@@ -72,6 +72,7 @@ import org.sonar.db.version.v54.RemovePreviewPermission;
 import org.sonar.db.version.v55.AddIssuesType;
 import org.sonar.db.version.v55.AddRulesLongDateColumns;
 import org.sonar.db.version.v55.DeleteMeasuresWithCharacteristicId;
+import org.sonar.db.version.v55.FeedIssueTypes;
 import org.sonar.db.version.v55.FeedRulesLongDateColumns;
 
 public class MigrationStepModule extends Module {
@@ -143,7 +144,8 @@ public class MigrationStepModule extends Module {
       AddRulesLongDateColumns.class,
       FeedRulesLongDateColumns.class,
       DeleteMeasuresWithCharacteristicId.class,
-      AddIssuesType.class
+      AddIssuesType.class,
+      FeedIssueTypes.class
       );
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java b/sonar-db/src/main/java/org/sonar/db/version/v55/FeedIssueTypes.java
new file mode 100644 (file)
index 0000000..233e2e6
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.base.Splitter;
+import java.sql.SQLException;
+import java.util.List;
+import org.sonar.api.utils.System2;
+import org.sonar.core.issue.IssueType;
+import org.sonar.db.Database;
+import org.sonar.db.version.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+import org.sonar.db.version.MassUpdate.Handler;
+import org.sonar.db.version.Select.Row;
+import org.sonar.db.version.SqlStatement;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.apache.commons.lang.StringUtils.defaultString;
+
+/**
+ * Duplicates RuleTagsToTypeConverter from API on purpose. Db migration must be isolated and must not
+ * depend on external code that may evolve over time.
+ *
+ * https://jira.sonarsource.com/browse/MMF-141
+ */
+public class FeedIssueTypes extends BaseDataChange {
+
+  private final long now;
+
+  public FeedIssueTypes(Database db, System2 system) {
+    super(db);
+    this.now = system.now();
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    final Splitter tagSplitter = Splitter.on(',');
+    final Joiner tagJoiner = Joiner.on(',').skipNulls();
+
+    MassUpdate update = context.prepareMassUpdate().rowPluralName("issues");
+    update.select("SELECT id, tags FROM issues WHERE issue_type IS NULL OR issue_type=0");
+    update.update("UPDATE issues SET issue_type=?, tags=?, updated_at=? WHERE id=?");
+    update.execute(new Handler() {
+      @Override
+      public boolean handle(Row row, SqlStatement update) throws SQLException {
+        long id = row.getLong(1);
+
+        // See algorithm to deduce type from tags in RuleTagsToTypeConverter
+        List<String> tags = newArrayList(tagSplitter.split(defaultString(row.getNullableString(2))));
+        IssueType type = tagsToType(tags);
+        tags.remove("bug");
+        tags.remove("security");
+
+        update.setInt(1, type.getDbConstant());
+        update.setString(2, tagJoiner.join(tags));
+        update.setLong(3, now);
+        update.setLong(4, id);
+        return true;
+      }
+    });
+  }
+
+  static IssueType tagsToType(List<String> tags) {
+    IssueType type = IssueType.CODE_SMELL;
+    if (tags.contains("bug")) {
+      type = IssueType.BUG;
+    } else if (tags.contains("security")) {
+      type = IssueType.VULNERABILITY;
+    }
+    return type;
+  }
+
+}
index 2016f764ae9ad181a372c8a8f9b71c0ed629ccf6..3c87dc8ed22adacb167257e9b875a7e7e9af39a0 100644 (file)
@@ -381,7 +381,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1100');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1101');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1102');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1103');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1106');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1107');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index ddd3920af680aa5d5a81778350e076f9b0fb8065..cbda4d662bc90a830f9e9f8a64afc9f32a14a613 100644 (file)
@@ -106,6 +106,7 @@ public class IssueDaoTest {
     assertThat(issue.getRuleId()).isEqualTo(500);
     assertThat(issue.getLanguage()).isEqualTo("java");
     assertThat(issue.getSeverity()).isEqualTo("BLOCKER");
+    assertThat(issue.getType()).isEqualTo(2);
     assertThat(issue.isManualSeverity()).isFalse();
     assertThat(issue.getMessage()).isNull();
     assertThat(issue.getLine()).isEqualTo(200);
index 033448a921e38add2bb42441e2c37aa7ec73e4ce..e81f60853626832ae5297cc075e4378d9d4fab61 100644 (file)
@@ -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(55);
+    assertThat(container.size()).isEqualTo(56);
   }
 }
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
new file mode 100644 (file)
index 0000000..0299c30
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.Arrays;
+import java.util.Collections;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.core.issue.IssueType;
+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 {
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedIssueTypesTest.class, "schema.sql");
+
+  @Test
+  public void test_tagsToType() {
+    assertThat(tagsToType(asList("misra", "bug"))).isEqualTo(IssueType.BUG);
+    assertThat(tagsToType(asList("misra", "security"))).isEqualTo(IssueType.VULNERABILITY);
+
+    // "bug" has priority on "security"
+    assertThat(tagsToType(asList("security", "bug"))).isEqualTo(IssueType.BUG);
+
+    // default is "code smell"
+    assertThat(tagsToType(asList("clumsy", "spring"))).isEqualTo(IssueType.CODE_SMELL);
+    assertThat(tagsToType(Collections.<String>emptyList())).isEqualTo(IssueType.CODE_SMELL);
+  }
+
+  @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", IssueType.CODE_SMELL);
+      assertType("without_tags", IssueType.CODE_SMELL);
+      assertType("bug", IssueType.BUG);
+    }
+  }
+
+  private void assertType(String issueKey, IssueType expectedType) {
+    Number type = (Number)db.selectFirst("select * from issues where kee='" + issueKey + "'").get("ISSUE_TYPE");
+    assertThat(type.intValue()).isEqualTo(expectedType.getDbConstant());
+  }
+
+}
index 84da34783be26f75aef5c3f6acd7f82a9c1b6e0d..240c0e7934592731c8d75af009dc040400e70b16 100644 (file)
@@ -39,7 +39,7 @@ public class FeedRulesLongDateColumnsTest {
 
   System2 system = mock(System2.class);
 
-  MigrationStep migration = new FeedRulesLongDateColumns(db.database(), system);
+  MigrationStep underTest = new FeedRulesLongDateColumns(db.database(), system);
 
   @Before
   public void setUp() throws Exception {
@@ -50,7 +50,7 @@ public class FeedRulesLongDateColumnsTest {
   public void execute() throws Exception {
     db.prepareDbUnit(getClass(), "execute.xml");
 
-    migration.execute();
+    underTest.execute();
 
     assertThat(db.countSql("select count(*) from rules where created_at_ms is not null and updated_at_ms is not null")).isEqualTo(3);
     // Only 1 rules not updated
index 0b261a3252df1fbb2f997dc01dfece6e3bcb51ba..07ddc4b1729b86cd81b5ef50dbedb92cc560353f 100644 (file)
@@ -24,6 +24,7 @@
       created_at="1400000000000"
       updated_at="1450000000000"
       locations="[null]"
+      issue_type="2"
     />
 
     <issues
@@ -50,6 +51,7 @@
       created_at="1400000000000"
       updated_at="1450000000000"
       locations="[null]"
+      issue_type="2"
       />
 
 </dataset>
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
new file mode 100644 (file)
index 0000000..b7526a5
--- /dev/null
@@ -0,0 +1,29 @@
+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
+);
index cc5efce850b258afb670daec72e1ce7d3188c04c..d55538662e02b28264659e198547c46931218069 100644 (file)
@@ -929,7 +929,7 @@ public interface RulesDefinition {
       this.status = newRule.status;
       this.debtRemediationFunction = newRule.debtRemediationFunction;
       this.effortToFixDescription = newRule.effortToFixDescription;
-      this.type = (newRule.type == null ? RuleTagsToTypeConverter.convert(newRule.tags) : newRule.type);
+      this.type = newRule.type == null ? RuleTagsToTypeConverter.convert(newRule.tags) : newRule.type;
       this.tags = ImmutableSortedSet.copyOf(Sets.difference(newRule.tags, RuleTagsToTypeConverter.RESERVED_TAGS));
       ImmutableMap.Builder<String, Param> paramsBuilder = ImmutableMap.builder();
       for (NewParam newParam : newRule.paramsByKey.values()) {
index 96e71ee495c10b042aa0be22cab8cd2621a10b14..5dd58351754a960ad6b7909fdfd65f733f0cac81 100644 (file)
@@ -75,9 +75,12 @@ public class IssueFilterParameters {
 
   public static final String FACET_ASSIGNED_TO_ME = "assigned_to_me";
 
-  public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED, COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS, TAGS, TYPES,
-    ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, CREATED_IN_LAST, COMPONENT_UUIDS, COMPONENT_ROOT_UUIDS, FACET_MODE,
-    PROJECTS, PROJECT_UUIDS, PROJECT_KEYS, COMPONENT_KEYS, MODULE_UUIDS, DIRECTORIES, FILE_UUIDS, AUTHORS, HIDE_COMMENTS, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
+  public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED,
+    COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS, TAGS, TYPES,
+    ASSIGNEES, LANGUAGES, ASSIGNED, PLANNED, HIDE_RULES, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, CREATED_IN_LAST,
+    COMPONENT_UUIDS, COMPONENT_ROOT_UUIDS, FACET_MODE,
+    PROJECTS, PROJECT_UUIDS, PROJECT_KEYS, COMPONENT_KEYS, MODULE_UUIDS, DIRECTORIES, FILE_UUIDS, AUTHORS,
+    HIDE_COMMENTS, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
 
   public static final List<String> ALL_WITHOUT_PAGINATION = ImmutableList.copyOf(Iterables.filter(ALL, new Predicate<String>() {
     @Override