]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4383 Replace userId by user in FilterDto
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 11 Jun 2013 14:44:54 +0000 (16:44 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 11 Jun 2013 14:45:11 +0000 (16:45 +0200)
17 files changed:
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueFilter.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDto.java
sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/test/java/org/sonar/core/issue/db/IssueFilterDaoTest.java
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueFilterDaoTest/shared.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueFilterDaoTest/should_delete-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueFilterDaoTest/should_insert-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueFilterDaoTest/should_select_by_user.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueFilterDaoTest/should_update-result.xml
sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
sonar-server/src/main/java/org/sonar/server/issue/IssueFilterService.java
sonar-server/src/main/webapp/WEB-INF/db/migrate/410_create_issue_filters.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/411_create_issue_filter_favourites.rb
sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java [new file with mode: 0644]

diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueFilter.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueFilter.java
new file mode 100644 (file)
index 0000000..639dafb
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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.core.issue;
+
+import javax.annotation.CheckForNull;
+
+import java.util.Date;
+
+public class DefaultIssueFilter {
+
+  public static String SEPARATOR = "|";
+  public static String KEY_VALUE_SEPARATOR = "=";
+  public static String LIST_SEPARATOR = ",";
+
+  private Long id;
+  private String name;
+  private String user;
+  private Boolean shared;
+  private String description;
+  private String data;
+  private Date createdAt;
+  private Date updatedAt;
+
+  public DefaultIssueFilter() {
+
+  }
+
+  public Long id() {
+    return id;
+  }
+
+  public DefaultIssueFilter setId(Long id) {
+    this.id = id;
+    return this;
+  }
+
+  public String name() {
+    return name;
+  }
+
+  public DefaultIssueFilter setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  @CheckForNull
+  public String user() {
+    return user;
+  }
+
+  public DefaultIssueFilter setUser(String user) {
+    this.user = user;
+    return this;
+  }
+
+  public Boolean shared() {
+    return shared;
+  }
+
+  public DefaultIssueFilter setShared(Boolean shared) {
+    this.shared = shared;
+    return this;
+  }
+
+  public String description() {
+    return description;
+  }
+
+  public DefaultIssueFilter setDescription(String description) {
+    this.description = description;
+    return this;
+  }
+
+  public String data() {
+    return data;
+  }
+
+  public DefaultIssueFilter setData(String data) {
+    this.data = data;
+    return this;
+  }
+
+  public Date createdAt() {
+    return createdAt;
+  }
+
+  public DefaultIssueFilter setCreatedAt(Date createdAt) {
+    this.createdAt = createdAt;
+    return this;
+  }
+
+  public Date updatedAt() {
+    return updatedAt;
+  }
+
+  public DefaultIssueFilter setUpdatedAt(Date updatedAt) {
+    this.updatedAt = updatedAt;
+    return this;
+  }
+
+}
index 37d9790a9e89d26f9deb64b3bd48407d411d9adb..2ac8a80265c709133af15be0dd8381f293df501b 100644 (file)
@@ -41,7 +41,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
   }
 
   @CheckForNull
-  public IssueFilterDto selectById(Integer id) {
+  public IssueFilterDto selectById(Long id) {
     SqlSession session = mybatis.openSession();
     try {
       session.getMapper(IssueFilterMapper.class);
@@ -51,11 +51,11 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
     }
   }
 
-  public List<IssueFilterDto> selectByUser(Integer userId) {
+  public List<IssueFilterDto> selectByUser(String user) {
     SqlSession session = mybatis.openSession();
     try {
       session.getMapper(IssueFilterMapper.class);
-      return getMapper(session).selectByUser(userId);
+      return getMapper(session).selectByUser(user);
     } finally {
       MyBatis.closeQuietly(session);
     }
@@ -81,7 +81,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
     }
   }
 
-  public void delete(Integer id) {
+  public void delete(Long id) {
     SqlSession session = mybatis.openSession();
     try {
       getMapper(session).delete(id);
index 1e4c59c48573e97b6e9ef406fcdf8232b8c349bf..29093953dc9add909cb4d3a30fc7a4f5cef33546 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.core.issue.db;
 
+import org.sonar.core.issue.DefaultIssueFilter;
+
 import javax.annotation.Nullable;
 
 import java.util.Date;
@@ -30,7 +32,7 @@ public class IssueFilterDto {
 
   private Long id;
   private String name;
-  private Long userId;
+  private String user;
   private Boolean shared;
   private String description;
   private String data;
@@ -55,12 +57,12 @@ public class IssueFilterDto {
     return this;
   }
 
-  public Long getUserId() {
-    return userId;
+  public String getUser() {
+    return user;
   }
 
-  public IssueFilterDto setUserId(@Nullable Long userId) {
-    this.userId = userId;
+  public IssueFilterDto setUser(@Nullable String user) {
+    this.user = user;
     return this;
   }
 
@@ -108,4 +110,28 @@ public class IssueFilterDto {
     this.updatedAt = updatedAt;
     return this;
   }
+
+  public DefaultIssueFilter toIssueFilter() {
+    return new DefaultIssueFilter()
+      .setId(id)
+      .setName(name)
+      .setUser(user)
+      .setDescription(description)
+      .setShared(shared)
+      .setData(data)
+      .setCreatedAt(createdAt)
+      .setUpdatedAt(updatedAt);
+  }
+
+  public static IssueFilterDto toIssueFilter(DefaultIssueFilter issueFilter) {
+    return new IssueFilterDto()
+      .setId(issueFilter.id())
+      .setName(issueFilter.name())
+      .setUser(issueFilter.user())
+      .setDescription(issueFilter.description())
+      .setShared(issueFilter.shared())
+      .setData(issueFilter.data())
+      .setCreatedAt(issueFilter.createdAt())
+      .setUpdatedAt(issueFilter.updatedAt());
+  }
 }
index 9bf819d11cd46de9e5d0e267ca375402aa3bf351..c4e8520febb42af5a15ed1069bbb7eb0e70fe89f 100644 (file)
@@ -29,13 +29,13 @@ import java.util.List;
 public interface IssueFilterMapper {
 
   @CheckForNull
-  IssueFilterDto selectById(Integer id);
+  IssueFilterDto selectById(Long id);
 
-  List<IssueFilterDto> selectByUser(Integer userId);
+  List<IssueFilterDto> selectByUser(String user);
 
   void insert(IssueFilterDto filter);
 
   void update(IssueFilterDto filter);
 
-  void delete(Integer id);
+  void delete(Long id);
 }
index d14bec6f23c3ff47bc96c3785d55177a9f311961..c1a1090343a1bf946d2256d1e001efb9ff0aeea1 100644 (file)
@@ -7,7 +7,7 @@
   <sql id="issueFilterColumns">
     if.id,
     if.name as name,
-    if.user_id as userId,
+    if.user as user,
     if.shared as shared,
     if.description as description,
     if.data as data,
     from issue_filters if WHERE id=#{id}
   </select>
 
-  <select id="selectByUser" parameterType="int" resultType="IssueFilter">
+  <select id="selectByUser" parameterType="String" resultType="IssueFilter">
     select <include refid="issueFilterColumns"/>
-    from issue_filters if WHERE user_id=#{userId}
+    from issue_filters if WHERE user=#{user}
   </select>
 
   <insert id="insert" parameterType="IssueFilter" useGeneratedKeys="true" keyProperty="id">
-    INSERT INTO issue_filters (name, user_id, shared, description, data, created_at, updated_at)
-    VALUES (#{name}, #{userId}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
+    INSERT INTO issue_filters (name, user, shared, description, data, created_at, updated_at)
+    VALUES (#{name}, #{user}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
   </insert>
 
   <!-- Oracle -->
     <selectKey order="BEFORE" resultType="Long" keyProperty="id">
       select issue_filters_seq.NEXTVAL from DUAL
     </selectKey>
-    INSERT INTO issue_filters (id, name, user_id, shared, description, data, created_at, updated_at)
-    VALUES (#{id}, #{name}, #{userId}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
+    INSERT INTO issue_filters (id, name, user, shared, description, data, created_at, updated_at)
+    VALUES (#{id}, #{name}, #{user}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
   </insert>
 
   <update id="update" parameterType="IssueFilter">
     update issue_filters set
     name=#{name},
-    user_id=#{userId},
+    user=#{user},
     shared=#{shared},
     description=#{description},
     data=#{data},
index 2e65ee3b2d55be54de1ec72b4bade019a91871a0..2a7f15231002b2a94e9cdef8d466dfd9b32cba40 100644 (file)
@@ -508,7 +508,7 @@ CREATE TABLE "ISSUE_FILTERS" (
   "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
   "NAME" VARCHAR(100) NOT NULL,
   "SHARED" BOOLEAN NOT NULL DEFAULT FALSE,
-  "USER_ID" INTEGER,
+  "USER" VARCHAR(40),
   "DESCRIPTION" VARCHAR(4000),
   "DATA" CLOB(2147483647),
   "CREATED_AT" TIMESTAMP,
@@ -517,7 +517,7 @@ CREATE TABLE "ISSUE_FILTERS" (
 
 CREATE TABLE "ISSUE_FILTER_FAVOURITES" (
   "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "USER_ID" INTEGER NOT NULL,
+  "USER" VARCHAR(40)  NOT NULL,
   "ISSUE_FILTER_ID" INTEGER NOT NULL,
   "CREATED_AT" TIMESTAMP
 );
@@ -658,6 +658,6 @@ CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES" ("ISSUE_KEY");
 
 CREATE INDEX "ISSUE_FILTERS_NAME" ON "ISSUE_FILTERS" ("NAME");
 
-CREATE INDEX "ISSUE_FILTER_FAVS_USERID" ON "ISSUE_FILTER_FAVOURITES" ("USER_ID");
+CREATE INDEX "ISSUE_FILTER_FAVS_USER" ON "ISSUE_FILTER_FAVOURITES" ("USER");
 
 CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN");
index 8cc8ec085586aaaef6f028b75c43d3dec144a6e4..5d5f905716a41ba209b3f14a898a09673ea1c92f 100644 (file)
@@ -41,20 +41,20 @@ public class IssueFilterDaoTest extends AbstractDaoTestCase {
   public void should_select_by_id() {
     setupData("shared");
 
-    IssueFilterDto filter = dao.selectById(1);
+    IssueFilterDto filter = dao.selectById(1L);
 
     assertThat(filter.getId()).isEqualTo(1L);
     assertThat(filter.getName()).isEqualTo("Sonar Issues");
     assertThat(filter.isShared()).isTrue();
 
-    assertThat(dao.selectById(123)).isNull();
+    assertThat(dao.selectById(123L)).isNull();
   }
 
   @Test
   public void should_select_by_user() {
     setupData("should_select_by_user");
 
-    List<IssueFilterDto> results = dao.selectByUser(2);
+    List<IssueFilterDto> results = dao.selectByUser("michael");
 
     assertThat(results).hasSize(2);
   }
@@ -65,7 +65,7 @@ public class IssueFilterDaoTest extends AbstractDaoTestCase {
 
     IssueFilterDto filterDto = new IssueFilterDto();
     filterDto.setName("Sonar Open issues");
-    filterDto.setUserId(2L);
+    filterDto.setUser("michael");
     filterDto.setShared(true);
     filterDto.setDescription("All open issues on Sonar");
     filterDto.setData("statuses=OPEN|componentRoots=org.codehaus.sonar");
@@ -82,7 +82,7 @@ public class IssueFilterDaoTest extends AbstractDaoTestCase {
     IssueFilterDto filterDto = new IssueFilterDto();
     filterDto.setId(2L);
     filterDto.setName("Closed issues");
-    filterDto.setUserId(3L);
+    filterDto.setUser("henry");
     filterDto.setShared(false);
     filterDto.setDescription("All closed issues");
     filterDto.setData("statuses=CLOSED");
@@ -96,7 +96,7 @@ public class IssueFilterDaoTest extends AbstractDaoTestCase {
   public void should_delete() {
     setupData("shared");
 
-    dao.delete(1);
+    dao.delete(1l);
 
     checkTables("should_delete", new String[]{"created_at", "updated_at"}, "issue_filters");
   }
index 3dd5ac09a05ef52f83e15ca8f896c606c2612e88..9cc2014c4353f9638b649bbde78a1a2f48294908 100644 (file)
@@ -3,7 +3,7 @@
   <issue_filters
       id="1"
       name="Sonar Issues"
-      user_id="1"
+      user="stephane"
       shared="[true]"
       description="All issues of Sonar"
       data="componentRoots=org.codehaus.sonar"
@@ -13,7 +13,7 @@
   <issue_filters
       id="2"
       name="Open issues"
-      user_id="2"
+      user="michael"
       shared="[false]"
       description="All open issues"
       data="statuses=OPEN"
index b218f0457b2b83ba32ecb2c00e44d593888b1730..d751cf7d2b707fe7236cbb392e9840b12a6f6fb9 100644 (file)
@@ -3,7 +3,7 @@
   <issue_filters
       id="2"
       name="Open issues"
-      user_id="2"
+      user="michael"
       shared="[false]"
       description="All open issues"
       data="statuses=OPEN"
index dc7196eafa8535dcd34d500248cd7b916ebac4df..ad5a2a52fa0352df4854eae5596c2aab226fdae1 100644 (file)
@@ -3,7 +3,7 @@
   <issue_filters
       id="1"
       name="Sonar Issues"
-      user_id="1"
+      user="stephane"
       shared="[true]"
       description="All issues of Sonar"
       data="componentRoots=org.codehaus.sonar"
@@ -13,7 +13,7 @@
   <issue_filters
       id="2"
       name="Open issues"
-      user_id="2"
+      user="michael"
       shared="[false]"
       description="All open issues"
       data="statuses=OPEN"
@@ -24,7 +24,7 @@
   <issue_filters
       id="3"
       name="Sonar Open issues"
-      user_id="2"
+      user="michael"
       shared="[true]"
       description="All open issues on Sonar"
       data="statuses=OPEN|componentRoots=org.codehaus.sonar"
index fda801cd549ef5c941251d7c3fb8aea2f69cfe17..e79b57c103bc4dd3c889cf943ed0ed9f5a65dce9 100644 (file)
@@ -3,7 +3,7 @@
   <issue_filters
       id="1"
       name="Sonar Issues"
-      user_id="1"
+      user="stephane"
       shared="[true]"
       description="All issues of Sonar"
       data="componentRoots=org.codehaus.sonar"
@@ -13,7 +13,7 @@
   <issue_filters
       id="2"
       name="Open issues"
-      user_id="2"
+      user="michael"
       shared="[false]"
       description="All open issues"
       data="statuses=OPEN"
@@ -23,7 +23,7 @@
   <issue_filters
       id="3"
       name="Sonar Open issues"
-      user_id="2"
+      user="michael"
       shared="[true]"
       description="All open issues on Sonar"
       data="statuses=OPEN|componentRoots=org.codehaus.sonar"
index 4b35add7346e8d10610ebcc415c6291bf339c5b0..9a233882bc7b5a13e058d58aacbb1ee94ae1c3f2 100644 (file)
@@ -3,7 +3,7 @@
   <issue_filters
       id="1"
       name="Sonar Issues"
-      user_id="1"
+      user="stephane"
       shared="[true]"
       description="All issues of Sonar"
       data="componentRoots=org.codehaus.sonar"
@@ -13,7 +13,7 @@
   <issue_filters
       id="2"
       name="Closed issues"
-      user_id="3"
+      user="henry"
       shared="[false]"
       description="All closed issues"
       data="statuses=CLOSED"
index 419b2f5b4008769e6eda9021cc6cbe9e71f2e027..09a52b681f05acf7336f5ce43c1419abdbc4f68f 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.api.ServerComponent;
 import org.sonar.api.issue.ActionPlan;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.issue.IssueComment;
+import org.sonar.api.issue.IssueQuery;
 import org.sonar.api.issue.action.Action;
 import org.sonar.api.issue.internal.DefaultIssue;
 import org.sonar.api.rule.RuleKey;
@@ -365,4 +366,8 @@ public class InternalRubyIssueService implements ServerComponent {
     return actionService.listAvailableActions(issue);
   }
 
+  public IssueQuery toQuery(Map<String, Object> props) {
+    return PublicRubyIssueService.toQuery(props);
+  }
+
 }
\ No newline at end of file
index d4364d26946d48e3612392e4a323cc90e9d17782..4dabe48119c686c4172c1f88f32965d70218ddec 100644 (file)
 
 package org.sonar.server.issue;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.StringUtils;
 import org.sonar.api.ServerComponent;
+import org.sonar.api.issue.IssueFinder;
+import org.sonar.api.issue.IssueQuery;
+import org.sonar.api.issue.IssueQueryResult;
+import org.sonar.core.issue.DefaultIssueFilter;
 import org.sonar.core.issue.db.IssueFilterDao;
+import org.sonar.core.issue.db.IssueFilterDto;
+import org.sonar.server.user.UserSession;
+
+import java.util.List;
+import java.util.Map;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Maps.newHashMap;
 
 public class IssueFilterService implements ServerComponent {
 
   private IssueFilterDao issueFilterDao;
+  private final IssueFinder issueFinder;
 
-  public IssueFilterService(IssueFilterDao issueFilterDao) {
+  public IssueFilterService(IssueFilterDao issueFilterDao, IssueFinder issueFinder) {
     this.issueFilterDao = issueFilterDao;
+    this.issueFinder = issueFinder;
+  }
+
+  public DefaultIssueFilter create(DefaultIssueFilter issueFilter, IssueQuery issueQuery, UserSession userSession) {
+    // TODO
+//    checkAuthorization(userSession, project, UserRole.ADMIN);
+    issueFilterDao.insert(IssueFilterDto.toIssueFilter(issueFilter));
+    return issueFilter;
+  }
+
+  public DefaultIssueFilter update(DefaultIssueFilter issueFilter, UserSession userSession) {
+    // TODO
+//    checkAuthorization(userSession, project, UserRole.ADMIN);
+    issueFilterDao.update(IssueFilterDto.toIssueFilter(issueFilter));
+    return issueFilter;
+  }
+
+  public void delete(Long issueFilterId, UserSession userSession) {
+    // TODO
+    //checkAuthorization(userSession, findActionPlanDto(actionPlanKey).getProjectKey(), UserRole.ADMIN);
+    issueFilterDao.delete(issueFilterId);
+  }
+
+  public IssueQueryResult execute(IssueQuery issueQuery) {
+    return issueFinder.find(issueQuery);
+  }
+
+  public IssueQueryResult execute(Long issueFilterId) {
+    IssueFilterDto issueFilterDto = issueFilterDao.selectById(issueFilterId);
+    if (issueFilterDto == null) {
+      // TODO throw 404
+      throw new IllegalArgumentException("Issue filter " + issueFilterId + " has not been found.");
+    }
+
+    DefaultIssueFilter issueFilter = issueFilterDto.toIssueFilter();
+    // convert data to issue query
+    issueFilter.data();
+
+//    return issueFinder.find(issueQuery);
+    return null;
+  }
+
+  @VisibleForTesting
+  Map<String, Object> dataAsMap(String data) {
+    Map<String, Object> props = newHashMap();
+
+    Iterable<String> keyValues = Splitter.on(DefaultIssueFilter.SEPARATOR).split(data);
+    for (String keyValue : keyValues) {
+      String[] keyValueSplit = StringUtils.split(keyValue, DefaultIssueFilter.KEY_VALUE_SEPARATOR);
+      if (keyValueSplit.length != 2) {
+        throw new IllegalArgumentException("Key value should be separate by a '"+ DefaultIssueFilter.KEY_VALUE_SEPARATOR + "'");
+      }
+      String key = keyValueSplit[0];
+      String value = keyValueSplit[1];
+      String[] listValues = StringUtils.split(value, DefaultIssueFilter.LIST_SEPARATOR);
+      if (listValues.length > 1) {
+        props.put(key, newArrayList(listValues));
+      } else {
+        props.put(key, value);
+      }
+    }
+    return props;
+  }
+
+  @VisibleForTesting
+  String mapAsdata(Map<String, Object> props) {
+    StringBuilder stringBuilder = new StringBuilder();
+
+    for (Map.Entry<String, Object> entries : props.entrySet()){
+      String key = entries.getKey();
+      Object value = entries.getValue();
+
+      stringBuilder.append(key);
+      stringBuilder.append(DefaultIssueFilter.KEY_VALUE_SEPARATOR);
+
+      List valuesList = newArrayList();
+      if (value instanceof List) {
+        // assume that it contains only strings
+        valuesList = (List) value;
+      } else if (value instanceof CharSequence) {
+        valuesList = Lists.newArrayList(Splitter.on(',').omitEmptyStrings().split((CharSequence) value));
+      } else {
+        stringBuilder.append(value);
+      }
+      for (Object valueList : valuesList) {
+        stringBuilder.append(valueList);
+        stringBuilder.append(DefaultIssueFilter.LIST_SEPARATOR);
+      }
+
+      stringBuilder.append(DefaultIssueFilter.SEPARATOR);
+    }
+    return stringBuilder.toString();
   }
+
 }
index ff63ed785b40b4e3eedf5ab0a035111e46eef303..575d71fc90ba31a25880b0c83a4470488aa3aece 100644 (file)
@@ -25,11 +25,11 @@ class CreateIssueFilters < ActiveRecord::Migration
 
   def self.up
     create_table 'issue_filters' do |t|
-      t.column 'name', :string, :null => false, :limit => 100
-      t.column 'user_id', :integer, :null => true
-      t.column 'shared', :boolean, :default => false, :null => false
-      t.column 'description', :string, :null => true, :limit => 4000
-      t.column 'data', :text, :null => true
+      t.column 'name',        :string,  :null => false,   :limit => 100
+      t.column 'user',        :string,  :null => true,   :limit => 40
+      t.column 'shared',      :boolean, :null => false,   :default => false
+      t.column 'description', :string,  :null => true,    :limit => 4000
+      t.column 'data',        :text,    :null => true
       t.timestamps
     end
     add_index 'issue_filters', 'name', :name => 'issue_filters_name'
index 322c19aaa53692e0f5a16a7aa613cef9182f696c..a45f1005f5747fb8f6eeb5fb219d6c37d2ce2bc6 100644 (file)
@@ -26,11 +26,11 @@ class CreateIssueFilterFavourites < ActiveRecord::Migration
 
   def self.up
     create_table 'issue_filter_favourites' do |t|
-      t.column 'user_id', :integer, :null => false
-      t.column 'issue_filter_id', :integer, :null => false
-      t.column 'created_at', :datetime
+      t.column 'user',            :string,    :null => false,   :limit => 40
+      t.column 'issue_filter_id', :integer,   :null => false
+      t.column 'created_at',      :datetime
     end
-    add_index 'issue_filter_favourites', 'user_id', :name => 'issue_filter_favs_userid'
+    add_index 'issue_filter_favourites', 'user', :name => 'issue_filter_favs_user'
   end
 
 end
diff --git a/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java b/sonar-server/src/test/java/org/sonar/server/issue/IssueFilterServiceTest.java
new file mode 100644 (file)
index 0000000..df99c3d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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.server.issue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.issue.IssueFinder;
+import org.sonar.core.issue.db.IssueFilterDao;
+
+import static org.mockito.Mockito.mock;
+
+public class IssueFilterServiceTest {
+
+  IssueFilterService service;
+
+  IssueFilterDao issueFilterDao;
+  IssueFinder issueFinder;
+
+  @Before
+  public void before() {
+    issueFinder = mock(IssueFinder.class);
+    issueFilterDao = mock(IssueFilterDao.class);
+    service = new IssueFilterService(issueFilterDao, issueFinder);
+  }
+
+  @Test
+  public void should_convert_map_to_data() {
+
+  }
+}