diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-11-08 14:46:07 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-11-09 16:47:34 +0100 |
commit | 003b0805e5869fa9430ba95a3ac408d30b6a13d8 (patch) | |
tree | 34434baa98849175e9bd9da19a3064e51611674b /sonar-db | |
parent | 72fa937e63b9ec047ef5b0cb5df6d192e6909cfb (diff) | |
download | sonarqube-003b0805e5869fa9430ba95a3ac408d30b6a13d8.tar.gz sonarqube-003b0805e5869fa9430ba95a3ac408d30b6a13d8.zip |
SONAR-8355 Remove measure filters Dao
Diffstat (limited to 'sonar-db')
20 files changed, 1 insertions, 675 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java index 17fb1ec6268..822aab89617 100644 --- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java +++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java @@ -40,8 +40,6 @@ import org.sonar.db.issue.IssueFilterDao; import org.sonar.db.issue.IssueFilterFavouriteDao; import org.sonar.db.loadedtemplate.LoadedTemplateDao; import org.sonar.db.measure.MeasureDao; -import org.sonar.db.measure.MeasureFilterDao; -import org.sonar.db.measure.MeasureFilterFavouriteDao; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.db.metric.MetricDao; import org.sonar.db.notification.NotificationQueueDao; @@ -93,8 +91,6 @@ public class DaoModule extends Module { IssueFilterFavouriteDao.class, LoadedTemplateDao.class, MeasureDao.class, - MeasureFilterDao.class, - MeasureFilterFavouriteDao.class, MetricDao.class, NotificationQueueDao.class, OrganizationDao.class, diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java index a4aebb92ea1..1c3b438ee2c 100644 --- a/sonar-db/src/main/java/org/sonar/db/DbClient.java +++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java @@ -40,8 +40,6 @@ import org.sonar.db.issue.IssueFilterDao; import org.sonar.db.issue.IssueFilterFavouriteDao; import org.sonar.db.loadedtemplate.LoadedTemplateDao; import org.sonar.db.measure.MeasureDao; -import org.sonar.db.measure.MeasureFilterDao; -import org.sonar.db.measure.MeasureFilterFavouriteDao; import org.sonar.db.measure.custom.CustomMeasureDao; import org.sonar.db.metric.MetricDao; import org.sonar.db.notification.NotificationQueueDao; @@ -86,8 +84,6 @@ public class DbClient { private final ResourceDao resourceDao; private final ComponentKeyUpdaterDao componentKeyUpdaterDao; private final MeasureDao measureDao; - private final MeasureFilterDao measureFilterDao; - private final MeasureFilterFavouriteDao measureFilterFavouriteDao; private final UserDao userDao; private final UserGroupDao userGroupDao; private final UserTokenDao userTokenDao; @@ -143,8 +139,6 @@ public class DbClient { resourceDao = getDao(map, ResourceDao.class); componentKeyUpdaterDao = getDao(map, ComponentKeyUpdaterDao.class); measureDao = getDao(map, MeasureDao.class); - measureFilterDao = getDao(map, MeasureFilterDao.class); - measureFilterFavouriteDao = getDao(map, MeasureFilterFavouriteDao.class); userDao = getDao(map, UserDao.class); userGroupDao = getDao(map, UserGroupDao.class); userTokenDao = getDao(map, UserTokenDao.class); @@ -254,14 +248,6 @@ public class DbClient { return measureDao; } - public MeasureFilterDao measureFilterDao() { - return measureFilterDao; - } - - public MeasureFilterFavouriteDao measureFilterFavouriteDao() { - return measureFilterFavouriteDao; - } - public UserDao userDao() { return userDao; } diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java index ba299882dda..349ee78df10 100644 --- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java +++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java @@ -64,10 +64,6 @@ import org.sonar.db.issue.IssueMapper; import org.sonar.db.loadedtemplate.LoadedTemplateDto; import org.sonar.db.loadedtemplate.LoadedTemplateMapper; import org.sonar.db.measure.MeasureDto; -import org.sonar.db.measure.MeasureFilterDto; -import org.sonar.db.measure.MeasureFilterFavouriteDto; -import org.sonar.db.measure.MeasureFilterFavouriteMapper; -import org.sonar.db.measure.MeasureFilterMapper; import org.sonar.db.measure.MeasureMapper; import org.sonar.db.measure.custom.CustomMeasureDto; import org.sonar.db.measure.custom.CustomMeasureMapper; @@ -178,8 +174,6 @@ public class MyBatis { confBuilder.loadAlias("IssueFilter", IssueFilterDto.class); confBuilder.loadAlias("Issue", IssueDto.class); confBuilder.loadAlias("LoadedTemplate", LoadedTemplateDto.class); - confBuilder.loadAlias("MeasureFilterFavourite", MeasureFilterFavouriteDto.class); - confBuilder.loadAlias("MeasureFilter", MeasureFilterDto.class); confBuilder.loadAlias("Measure", MeasureDto.class); confBuilder.loadAlias("NotificationQueue", NotificationQueueDto.class); confBuilder.loadAlias("Organization", OrganizationDto.class); @@ -237,8 +231,6 @@ public class MyBatis { IssueFilterMapper.class, IssueMapper.class, LoadedTemplateMapper.class, - MeasureFilterFavouriteMapper.class, - MeasureFilterMapper.class, MeasureMapper.class, MetricMapper.class, Migration45Mapper.class, diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java deleted file mode 100644 index 6dbaaf1a45b..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDao.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.measure; - -import org.apache.ibatis.session.SqlSession; -import org.sonar.db.Dao; -import org.sonar.db.DbSession; -import org.sonar.db.MyBatis; - -public class MeasureFilterDao implements Dao { - private MyBatis mybatis; - - public MeasureFilterDao(MyBatis mybatis) { - this.mybatis = mybatis; - } - - public MeasureFilterDto selectSystemFilterByName(String name) { - SqlSession session = mybatis.openSession(false); - try { - MeasureFilterMapper mapper = session.getMapper(MeasureFilterMapper.class); - return mapper.findSystemFilterByName(name); - } finally { - MyBatis.closeQuietly(session); - } - } - - public MeasureFilterDto selectById(DbSession session, long id){ - return session.getMapper(MeasureFilterMapper.class).selectById(id); - } - - public void insert(DbSession session, MeasureFilterDto filter) { - session.getMapper(MeasureFilterMapper.class).insert(filter); - } - - public void insert(MeasureFilterDto filter) { - DbSession session = mybatis.openSession(false); - try { - insert(session, filter); - session.commit(); - } finally { - MyBatis.closeQuietly(session); - } - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDto.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDto.java deleted file mode 100644 index 02688c2d16a..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterDto.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.measure; - -import java.util.Date; -import javax.annotation.Nullable; - -/** - * @since 3.4 - */ -public class MeasureFilterDto { - private Long id; - private String name; - private Long userId; - private Boolean shared; - private String description; - private String data; - private Date createdAt; - private Date updatedAt; - - public Long getId() { - return id; - } - - public MeasureFilterDto setId(Long id) { - this.id = id; - return this; - } - - public String getName() { - return name; - } - - public MeasureFilterDto setName(String name) { - this.name = name; - return this; - } - - public Long getUserId() { - return userId; - } - - public MeasureFilterDto setUserId(@Nullable Long userId) { - this.userId = userId; - return this; - } - - public Boolean isShared() { - return shared; - } - - public MeasureFilterDto setShared(@Nullable Boolean shared) { - this.shared = shared; - return this; - } - - public String getDescription() { - return description; - } - - public MeasureFilterDto setDescription(@Nullable String description) { - this.description = description; - return this; - } - - public String getData() { - return data; - } - - public MeasureFilterDto setData(String data) { - this.data = data; - return this; - } - - public Date getCreatedAt() { - return createdAt; - } - - public MeasureFilterDto setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public MeasureFilterDto setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteDao.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteDao.java deleted file mode 100644 index 50f15b91878..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteDao.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.measure; - -import org.sonar.db.Dao; -import org.sonar.db.DbSession; - -public class MeasureFilterFavouriteDao implements Dao { - - public MeasureFilterFavouriteDto selectById(DbSession session, long id) { - return session.getMapper(MeasureFilterFavouriteMapper.class).selectById(id); - } - - public void insert(DbSession session, MeasureFilterFavouriteDto filter) { - session.getMapper(MeasureFilterFavouriteMapper.class).insert(filter); - } - -} diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteDto.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteDto.java deleted file mode 100644 index d7f0f8671cd..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteDto.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.measure; - -import java.util.Date; - -public class MeasureFilterFavouriteDto { - private Long id; - private Long userId; - private Long measureFilterId; - private Date createdAt; - - public Long getId() { - return id; - } - - public MeasureFilterFavouriteDto setId(Long id) { - this.id = id; - return this; - } - - public Long getUserId() { - return userId; - } - - public MeasureFilterFavouriteDto setUserId(Long userId) { - this.userId = userId; - return this; - } - - public Long getMeasureFilterId() { - return measureFilterId; - } - - public MeasureFilterFavouriteDto setMeasureFilterId(Long measureFilterId) { - this.measureFilterId = measureFilterId; - return this; - } - - public Date getCreatedAt() { - return createdAt; - } - - public MeasureFilterFavouriteDto setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - return this; - } -} diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteMapper.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteMapper.java deleted file mode 100644 index 2e00f07d8ea..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterFavouriteMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.measure; - -public interface MeasureFilterFavouriteMapper { - - MeasureFilterFavouriteDto selectById(long id); - - void insert(MeasureFilterFavouriteDto filter); -} diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterMapper.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterMapper.java deleted file mode 100644 index ec5b5748c6d..00000000000 --- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureFilterMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.measure; - -/** - * @since 3.4 - */ -public interface MeasureFilterMapper { - MeasureFilterDto findSystemFilterByName(String name); - - MeasureFilterDto selectById(long id); - - void insert(MeasureFilterDto filter); -} diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java index 74bd4355b9f..8f92c394f2a 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/UserDao.java +++ b/sonar-db/src/main/java/org/sonar/db/user/UserDao.java @@ -159,8 +159,6 @@ public class UserDao implements Dao { mapper.removeUserFromGroups(dto.getId()); mapper.deleteUnsharedUserIssueFilters(dto.getLogin()); mapper.deleteUserIssueFilterFavourites(dto.getLogin()); - mapper.deleteUnsharedUserMeasureFilters(dto.getId()); - mapper.deleteUserMeasureFilterFavourites(dto.getId()); mapper.deleteUserProperties(dto.getId()); mapper.deleteUserRoles(dto.getId()); mapper.deletePropertiesMatchingLogin(asList(DEFAULT_ISSUE_ASSIGNEE), dto.getLogin()); diff --git a/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java b/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java index 8795c1e4c7e..a060c21e66b 100644 --- a/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/user/UserMapper.java @@ -70,10 +70,6 @@ public interface UserMapper { void deleteUserIssueFilterFavourites(String login); - void deleteUnsharedUserMeasureFilters(long userId); - - void deleteUserMeasureFilterFavourites(long userId); - void deleteUserProperties(long userId); void deleteUserRoles(long userId); diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureFilterFavouriteMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureFilterFavouriteMapper.xml deleted file mode 100644 index 8e9a4a5f86f..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureFilterFavouriteMapper.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - -<mapper namespace="org.sonar.db.measure.MeasureFilterFavouriteMapper"> - - <sql id="measureFilterFavouriteColumns"> - mff.id, - mff.user_id as "userId", - mff.measure_filter_id as "measureFilterId", - mff.created_at as "createdAt" - </sql> - - <select id="selectById" parameterType="long" resultType="MeasureFilterFavourite"> - SELECT <include refid="measureFilterFavouriteColumns"/> - FROM measure_filter_favourites mff - WHERE mff.id=#{id} - </select> - - <insert id="insert" parameterType="MeasureFilterFavourite" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> - INSERT INTO measure_filter_favourites (user_id, measure_filter_id, created_at) - VALUES (#{userId,jdbcType=BIGINT}, #{measureFilterId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}) - </insert> - -</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureFilterMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureFilterMapper.xml deleted file mode 100644 index 63c9be3a27a..00000000000 --- a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureFilterMapper.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - -<mapper namespace="org.sonar.db.measure.MeasureFilterMapper"> - - <sql id="measureFilterColumns"> - mf.id, - mf.name, - mf.user_id as "userId", - mf.shared, - mf.description, - mf.data, - mf.created_at as "createdAt", - mf.updated_at as "updatedAt" - </sql> - - <select id="findSystemFilterByName" parameterType="string" resultType="MeasureFilter"> - SELECT <include refid="measureFilterColumns"/> - FROM measure_filters mf - WHERE mf.user_id is null and mf.name=#{id} - </select> - - <select id="selectById" parameterType="long" resultType="MeasureFilter"> - SELECT <include refid="measureFilterColumns"/> - FROM measure_filters mf - WHERE mf.id=#{id} - </select> - - <insert id="insert" parameterType="MeasureFilter" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> - INSERT INTO measure_filters (name, user_id, shared, description, data, created_at, updated_at) - VALUES (#{name,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}, #{shared,jdbcType=BOOLEAN}, #{description,jdbcType=VARCHAR}, #{data,jdbcType=VARCHAR}, - #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}) - </insert> - -</mapper> diff --git a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml index 7087a0a4b2f..4a940a2ebe0 100644 --- a/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/user/UserMapper.xml @@ -127,14 +127,6 @@ DELETE FROM properties WHERE user_id=#{id} </delete> - <delete id="deleteUnsharedUserMeasureFilters" parameterType="long"> - DELETE FROM measure_filters WHERE user_id=#{id} and shared <> ${_true} - </delete> - - <delete id="deleteUserMeasureFilterFavourites" parameterType="long"> - DELETE FROM measure_filter_favourites WHERE user_id=#{id} - </delete> - <delete id="deleteUnsharedUserIssueFilters" parameterType="String"> DELETE FROM issue_filters WHERE user_login=#{id} and shared <> ${_true} </delete> diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java index f653c76bfce..c76d29e2dc1 100644 --- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java @@ -29,6 +29,6 @@ public class DaoModuleTest { public void verify_count_of_added_components() { ComponentContainer container = new ComponentContainer(); new DaoModule().configure(container); - assertThat(container.size()).isEqualTo(2 + 48); + assertThat(container.size()).isEqualTo(2 + 46); } } diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java deleted file mode 100644 index 369f2368065..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterDaoTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.measure; - -import java.util.Date; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MeasureFilterDaoTest { - - @Rule - public DbTester db = DbTester.create(System2.INSTANCE); - - final DbSession session = db.getSession(); - - MeasureFilterDao underTest = db.getDbClient().measureFilterDao(); - - @Test - public void should_find_filter() { - db.prepareDbUnit(getClass(), "shared.xml"); - - MeasureFilterDto filter = underTest.selectSystemFilterByName("Projects"); - - assertThat(filter.getId()).isEqualTo(1L); - assertThat(filter.getName()).isEqualTo("Projects"); - } - - @Test - public void should_not_find_filter() { - db.prepareDbUnit(getClass(), "shared.xml"); - - assertThat(underTest.selectSystemFilterByName("Unknown")).isNull(); - } - - @Test - public void select_by_id() throws Exception { - MeasureFilterDto dto = new MeasureFilterDto() - .setUserId(10L) - .setName("name") - .setDescription("description") - .setData("data") - .setShared(true) - .setCreatedAt(new Date(1000L)) - .setUpdatedAt(new Date(2000L)); - underTest.insert(session, dto); - session.commit(); - - MeasureFilterDto dtoReloded = underTest.selectById(session, dto.getId()); - assertThat(dtoReloded).isNotNull(); - assertThat(dtoReloded.getUserId()).isEqualTo(10L); - assertThat(dtoReloded.getName()).isEqualTo("name"); - assertThat(dtoReloded.getDescription()).isEqualTo("description"); - assertThat(dtoReloded.getData()).isEqualTo("data"); - assertThat(dtoReloded.isShared()).isTrue(); - assertThat(dtoReloded.getCreatedAt()).isEqualTo(new Date(1000L)); - assertThat(dtoReloded.getUpdatedAt()).isEqualTo(new Date(2000L)); - - assertThat(underTest.selectById(session, 123L)).isNull(); - } - - @Test - public void should_insert() { - db.prepareDbUnit(getClass(), "shared.xml"); - - MeasureFilterDto filterDto = new MeasureFilterDto(); - filterDto.setName("Project Treemap"); - filterDto.setUserId(123L); - filterDto.setShared(true); - filterDto.setDescription("Treemap of projects"); - filterDto.setData("qualifiers=TRK|display=treemap"); - - underTest.insert(filterDto); - - db.assertDbUnit(getClass(), "shouldInsert-result.xml", new String[]{"created_at", "updated_at"}, "measure_filters"); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java deleted file mode 100644 index d2c94c30768..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureFilterFavouriteDaoTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.measure; - -import java.util.Date; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbSession; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MeasureFilterFavouriteDaoTest { - - @Rule - public DbTester db = DbTester.create(System2.INSTANCE); - - final DbSession session = db.getSession(); - - MeasureFilterFavouriteDao underTest = db.getDbClient().measureFilterFavouriteDao(); - - @Test - public void insert_and_select_by_id() throws Exception { - MeasureFilterFavouriteDto dto = new MeasureFilterFavouriteDto() - .setMeasureFilterId(5L) - .setUserId(10L) - .setCreatedAt(new Date(1000L)); - underTest.insert(session, dto); - session.commit(); - - MeasureFilterFavouriteDto dtoReloaded = underTest.selectById(session, dto.getId()); - assertThat(dtoReloaded).isNotNull(); - assertThat(dtoReloaded.getMeasureFilterId()).isEqualTo(5L); - assertThat(dtoReloaded.getUserId()).isEqualTo(10L); - assertThat(dtoReloaded.getCreatedAt()).isEqualTo(new Date(1000L)); - - assertThat(underTest.selectById(session, 123L)).isNull(); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java index 39a771d08e2..0d94157377d 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -35,8 +35,6 @@ import org.sonar.db.DbTester; import org.sonar.db.RowNotFoundException; import org.sonar.db.issue.IssueFilterDto; import org.sonar.db.issue.IssueFilterFavouriteDto; -import org.sonar.db.measure.MeasureFilterDto; -import org.sonar.db.measure.MeasureFilterFavouriteDto; import org.sonar.db.organization.OrganizationDto; import org.sonar.db.property.PropertyDto; import org.sonar.db.property.PropertyQuery; @@ -399,8 +397,6 @@ public class UserDaoTest { UserDto user = newActiveUser(); IssueFilterDto issueFilter = insertIssueFilter(user, false); IssueFilterFavouriteDto issueFilterFavourite = insertIssueFilterFavourite(issueFilter, user); - MeasureFilterDto measureFilter = insertMeasureFilter(user, false); - MeasureFilterFavouriteDto measureFilterFavourite = insertMeasureFilterFavourite(measureFilter, user); PropertyDto property = insertProperty(user); db.users().insertPermissionOnUser(user, "perm"); insertUserGroup(user); @@ -427,8 +423,6 @@ public class UserDaoTest { assertThat(dbClient.issueFilterDao().selectById(session, issueFilter.getId())).isNull(); assertThat(dbClient.issueFilterFavouriteDao().selectById(session, issueFilterFavourite.getId())).isNull(); - assertThat(dbClient.measureFilterDao().selectById(session, measureFilter.getId())).isNull(); - assertThat(dbClient.measureFilterFavouriteDao().selectById(session, measureFilterFavourite.getId())).isNull(); assertThat(dbClient.propertiesDao().selectByQuery(PropertyQuery.builder().setKey(property.getKey()).build(), session)).isEmpty(); assertThat(dbClient.userPermissionDao().selectGlobalPermissionsOfUser(session, user.getId(), db.getDefaultOrganization().getUuid())).isEmpty(); assertThat(dbClient.groupMembershipDao().countGroups(session, builder().login(user.getLogin()).membership(IN).build(), user.getId())).isZero(); @@ -451,22 +445,6 @@ public class UserDaoTest { } @Test - public void deactivate_user_does_not_remove_shared_measure_filter() throws Exception { - UserDto user = newActiveUser(); - MeasureFilterDto notSharedFilter = insertMeasureFilter(user, false); - MeasureFilterDto sharedFilter = insertMeasureFilter(user, true); - session.commit(); - - boolean deactivated = underTest.deactivateUserByLogin(session, user.getLogin()); - assertThat(deactivated).isTrue(); - - assertThat(dbClient.measureFilterDao().selectById(session, notSharedFilter.getId())).isNull(); - MeasureFilterDto sharedFilterReloaded = dbClient.measureFilterDao().selectById(session, sharedFilter.getId()); - assertThat(sharedFilterReloaded).isNotNull(); - assertThat(sharedFilterReloaded.getUserId()).isEqualTo(user.getId()); - } - - @Test public void deactivate_user_also_remove_default_assignee_login_properties() throws Exception { UserDto user = newActiveUser(); insertProperty("sonar.issues.defaultAssigneeLogin", user.getLogin(), 10L); @@ -777,18 +755,6 @@ public class UserDaoTest { return dto; } - private MeasureFilterDto insertMeasureFilter(UserDto user, boolean shared) { - MeasureFilterDto dto = new MeasureFilterDto().setUserId(user.getId()).setName(randomAlphanumeric(100)).setShared(shared); - dbClient.measureFilterDao().insert(session, dto); - return dto; - } - - private MeasureFilterFavouriteDto insertMeasureFilterFavourite(MeasureFilterDto measureFilter, UserDto user) { - MeasureFilterFavouriteDto dto = new MeasureFilterFavouriteDto().setUserId(user.getId()).setMeasureFilterId(measureFilter.getId()); - dbClient.measureFilterFavouriteDao().insert(session, dto); - return dto; - } - private PropertyDto insertProperty(UserDto user) { PropertyDto dto = new PropertyDto().setKey(randomAlphanumeric(100)).setUserId(user.getId()); dbClient.propertiesDao().saveProperty(session, dto); diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureFilterDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureFilterDaoTest/shared.xml deleted file mode 100644 index 8814a1c894d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureFilterDaoTest/shared.xml +++ /dev/null @@ -1,23 +0,0 @@ -<dataset> - - <measure_filters - id="1" - name="Projects" - user_id="[null]" - shared="[true]" - description="All projects" - data="qualifiers=TRK" - created_at="2012-12-25" - updated_at="2012-12-25"/> - - <measure_filters - id="2" - name="Files" - user_id="[null]" - shared="[true]" - description="All files" - data="qualifiers=FIL" - created_at="2012-01-25" - updated_at="2012-01-25"/> - -</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureFilterDaoTest/shouldInsert-result.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureFilterDaoTest/shouldInsert-result.xml deleted file mode 100644 index 1100b166b82..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureFilterDaoTest/shouldInsert-result.xml +++ /dev/null @@ -1,34 +0,0 @@ -<dataset> - - <measure_filters - id="1" - name="Projects" - user_id="[null]" - shared="[true]" - description="All projects" - data="qualifiers=TRK" - created_at="2012-12-25" - updated_at="2012-12-25"/> - - <measure_filters - id="2" - name="Files" - user_id="[null]" - shared="[true]" - description="All files" - data="qualifiers=FIL" - created_at="2012-01-25" - updated_at="2012-01-25"/> - - - <measure_filters - id="3" - name="Project Treemap" - user_id="123" - shared="[true]" - description="Treemap of projects" - data="qualifiers=TRK|display=treemap" - created_at="2012-12-25" - updated_at="2012-12-25"/> - -</dataset> |