+ 25 // level 1
+ 46 // content of DaoModule
+ 2 // content of EsSearchModule
- + 64 // content of CorePropertyDefinitions
+ + 62 // content of CorePropertyDefinitions
+ 1 // content of CePropertyDefinitions
);
assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull();
import org.sonar.db.event.EventDao;
import org.sonar.db.issue.IssueChangeDao;
import org.sonar.db.issue.IssueDao;
-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.custom.CustomMeasureDao;
InternalPropertiesDao.class,
IssueDao.class,
IssueChangeDao.class,
- IssueFilterDao.class,
- IssueFilterFavouriteDao.class,
LoadedTemplateDao.class,
MeasureDao.class,
MetricDao.class,
import org.sonar.db.event.EventDao;
import org.sonar.db.issue.IssueChangeDao;
import org.sonar.db.issue.IssueDao;
-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.custom.CustomMeasureDao;
private final PermissionTemplateDao permissionTemplateDao;
private final PermissionTemplateCharacteristicDao permissionTemplateCharacteristicDao;
private final IssueDao issueDao;
- private final IssueFilterDao issueFilterDao;
- private final IssueFilterFavouriteDao issueFilterFavouriteDao;
private final IssueChangeDao issueChangeDao;
private final CeActivityDao ceActivityDao;
private final CeQueueDao ceQueueDao;
permissionTemplateDao = getDao(map, PermissionTemplateDao.class);
permissionTemplateCharacteristicDao = getDao(map, PermissionTemplateCharacteristicDao.class);
issueDao = getDao(map, IssueDao.class);
- issueFilterDao = getDao(map, IssueFilterDao.class);
- issueFilterFavouriteDao = getDao(map, IssueFilterFavouriteDao.class);
issueChangeDao = getDao(map, IssueChangeDao.class);
ceActivityDao = getDao(map, CeActivityDao.class);
ceQueueDao = getDao(map, CeQueueDao.class);
return issueDao;
}
- public IssueFilterDao issueFilterDao() {
- return issueFilterDao;
- }
-
- public IssueFilterFavouriteDao issueFilterFavouriteDao() {
- return issueFilterFavouriteDao;
- }
-
public IssueChangeDao issueChangeDao() {
return issueChangeDao;
}
import org.sonar.db.issue.IssueChangeDto;
import org.sonar.db.issue.IssueChangeMapper;
import org.sonar.db.issue.IssueDto;
-import org.sonar.db.issue.IssueFilterDto;
-import org.sonar.db.issue.IssueFilterFavouriteDto;
-import org.sonar.db.issue.IssueFilterFavouriteMapper;
-import org.sonar.db.issue.IssueFilterMapper;
import org.sonar.db.issue.IssueMapper;
import org.sonar.db.loadedtemplate.LoadedTemplateDto;
import org.sonar.db.loadedtemplate.LoadedTemplateMapper;
confBuilder.loadAlias("IdUuidPair", IdUuidPair.class);
confBuilder.loadAlias("InternalProperty", InternalPropertyDto.class);
confBuilder.loadAlias("IssueChange", IssueChangeDto.class);
- confBuilder.loadAlias("IssueFilterFavourite", IssueFilterFavouriteDto.class);
- confBuilder.loadAlias("IssueFilter", IssueFilterDto.class);
confBuilder.loadAlias("Issue", IssueDto.class);
confBuilder.loadAlias("LoadedTemplate", LoadedTemplateDto.class);
confBuilder.loadAlias("Measure", MeasureDto.class);
InternalPropertiesMapper.class,
IsAliveMapper.class,
IssueChangeMapper.class,
- IssueFilterFavouriteMapper.class,
- IssueFilterMapper.class,
IssueMapper.class,
LoadedTemplateMapper.class,
MeasureMapper.class,
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.apache.ibatis.session.SqlSession;
-import org.sonar.db.Dao;
-import org.sonar.db.DbSession;
-import org.sonar.db.MyBatis;
-
-public class IssueFilterDao implements Dao {
-
- private final MyBatis mybatis;
-
- public IssueFilterDao(MyBatis mybatis) {
- this.mybatis = mybatis;
- }
-
- @CheckForNull
- public IssueFilterDto selectById(DbSession session, long id) {
- return mapper(session).selectById(id);
- }
-
- @CheckForNull
- public IssueFilterDto selectById(long id) {
- DbSession session = mybatis.openSession(false);
- try {
- return selectById(session, id);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- /**
- * @deprecated since 5.2 use {@link #selectByUser(DbSession, String)}
- */
- @Deprecated
- public List<IssueFilterDto> selectByUser(String user) {
- DbSession session = mybatis.openSession(false);
- try {
- return selectByUser(session, user);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<IssueFilterDto> selectByUser(DbSession session, String user) {
- return mapper(session).selectByUser(user);
- }
-
- public List<IssueFilterDto> selectFavoriteFiltersByUser(String user) {
- SqlSession session = mybatis.openSession(false);
- try {
- return mapper(session).selectFavoriteFiltersByUser(user);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public IssueFilterDto selectProvidedFilterByName(String name) {
- SqlSession session = mybatis.openSession(false);
- try {
- return mapper(session).selectProvidedFilterByName(name);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- /**
- * @deprecated since 5.2 use {@link #selectSharedFilters(DbSession)}
- */
- @Deprecated
- public List<IssueFilterDto> selectSharedFilters() {
- DbSession session = mybatis.openSession(false);
- try {
- return selectSharedFilters(session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<IssueFilterDto> selectSharedFilters(DbSession session) {
- return mapper(session).selectSharedFilters();
- }
-
- /**
- * @deprecated since 5.2 use {@link #insert(DbSession, IssueFilterDto)}
- */
- @Deprecated
- public void insert(IssueFilterDto filter) {
- DbSession session = mybatis.openSession(false);
- try {
- insert(session, filter);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public IssueFilterDto insert(DbSession session, IssueFilterDto filter) {
- mapper(session).insert(filter);
- session.commit();
-
- return filter;
- }
-
- public void update(IssueFilterDto filter) {
- DbSession session = mybatis.openSession(false);
- try {
- mapper(session).update(filter);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public void delete(long id) {
- DbSession session = mybatis.openSession(false);
- try {
- mapper(session).delete(id);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- private static IssueFilterMapper mapper(SqlSession session) {
- return session.getMapper(IssueFilterMapper.class);
- }
-}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.Date;
-import javax.annotation.Nullable;
-
-/**
- * @since 3.7
- */
-public class IssueFilterDto {
-
- private Long id;
- private String name;
- private String userLogin;
- private boolean shared;
- private String description;
- private String data;
- private Date createdAt;
- private Date updatedAt;
-
- public IssueFilterDto() {
- Date now = new Date();
- createdAt = updatedAt = now;
- shared = false;
- }
-
- public Long getId() {
- return id;
- }
-
- public IssueFilterDto setId(Long id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public IssueFilterDto setName(String name) {
- this.name = name;
- return this;
- }
-
- public String getUserLogin() {
- return userLogin;
- }
-
- public IssueFilterDto setUserLogin(String userLogin) {
- this.userLogin = userLogin;
- return this;
- }
-
- public boolean isShared() {
- return shared;
- }
-
- public IssueFilterDto setShared(boolean shared) {
- this.shared = shared;
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public IssueFilterDto setDescription(@Nullable String description) {
- this.description = description;
- return this;
- }
-
- public String getData() {
- return data;
- }
-
- public IssueFilterDto setData(String data) {
- this.data = data;
- return this;
- }
-
- public Date getCreatedAt() {
- return createdAt;
- }
-
- public IssueFilterDto setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public Date getUpdatedAt() {
- return updatedAt;
- }
-
- public IssueFilterDto setUpdatedAt(Date updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.List;
-import org.apache.ibatis.session.SqlSession;
-import org.sonar.db.Dao;
-import org.sonar.db.DbSession;
-import org.sonar.db.MyBatis;
-
-public class IssueFilterFavouriteDao implements Dao {
-
- private final MyBatis mybatis;
-
- public IssueFilterFavouriteDao(MyBatis mybatis) {
- this.mybatis = mybatis;
- }
-
- public IssueFilterFavouriteDto selectById(DbSession session, long id) {
- return mapper(session).selectById(id);
- }
-
- public IssueFilterFavouriteDto selectById(long id) {
- DbSession session = mybatis.openSession(false);
- try {
- return selectById(session, id);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<IssueFilterFavouriteDto> selectByFilterId(long filterId) {
- SqlSession session = mybatis.openSession(false);
- try {
- return mapper(session).selectByFilterId(filterId);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- /**
- * @deprecated since 5.2 use {@link #insert(DbSession, IssueFilterFavouriteDto)}
- */
- @Deprecated
- public void insert(IssueFilterFavouriteDto filter) {
- DbSession session = mybatis.openSession(false);
- try {
- insert(session, filter);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public void insert(DbSession session, IssueFilterFavouriteDto filter) {
- mapper(session).insert(filter);
- session.commit();
- }
-
- public void delete(long id) {
- SqlSession session = mybatis.openSession(false);
- try {
- mapper(session).delete(id);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public void deleteByFilterId(long filterId) {
- SqlSession session = mybatis.openSession(false);
- try {
- mapper(session).deleteByFilterId(filterId);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- private static IssueFilterFavouriteMapper mapper(SqlSession session) {
- return session.getMapper(IssueFilterFavouriteMapper.class);
- }
-
- public List<IssueFilterFavouriteDto> selectByUser(DbSession dbSession, String login) {
- return mapper(dbSession).selectByUser(login);
- }
-}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.Date;
-
-/**
- * @since 3.7
- */
-public class IssueFilterFavouriteDto {
-
- private Long id;
- private String userLogin;
- private Long issueFilterId;
- private Date createdAt;
-
- public Long getId() {
- return id;
- }
-
- public IssueFilterFavouriteDto setId(Long id) {
- this.id = id;
- return this;
- }
-
- public String getUserLogin() {
- return userLogin;
- }
-
- public IssueFilterFavouriteDto setUserLogin(String userLogin) {
- this.userLogin = userLogin;
- return this;
- }
-
- public Long getIssueFilterId() {
- return issueFilterId;
- }
-
- public IssueFilterFavouriteDto setIssueFilterId(Long issueFilterId) {
- this.issueFilterId = issueFilterId;
- return this;
- }
-
- public Date getCreatedAt() {
- return createdAt;
- }
-
- public IssueFilterFavouriteDto setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
-}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * @since 3.7
- */
-public interface IssueFilterFavouriteMapper {
-
- @CheckForNull
- IssueFilterFavouriteDto selectById(long id);
-
- List<IssueFilterFavouriteDto> selectByFilterId(@Param("filterId") long filterId);
-
- List<IssueFilterFavouriteDto> selectByUser(String login);
-
- void insert(IssueFilterFavouriteDto filterFavourite);
-
- void delete(long id);
-
- void deleteByFilterId(long filterId);
-}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-
-/**
- * @since 3.7
- */
-public interface IssueFilterMapper {
-
- @CheckForNull
- IssueFilterDto selectById(long id);
-
- List<IssueFilterDto> selectByUser(String user);
-
- List<IssueFilterDto> selectFavoriteFiltersByUser(String user);
-
- List<IssueFilterDto> selectSharedFilters();
-
- IssueFilterDto selectProvidedFilterByName(String name);
-
- void insert(IssueFilterDto filter);
-
- void update(IssueFilterDto filter);
-
- void delete(long id);
-
-}
}
mapper.removeUserFromGroups(dto.getId());
- mapper.deleteUnsharedUserIssueFilters(dto.getLogin());
- mapper.deleteUserIssueFilterFavourites(dto.getLogin());
mapper.deleteUserProperties(dto.getId());
mapper.deleteUserRoles(dto.getId());
mapper.deletePropertiesMatchingLogin(asList(DEFAULT_ISSUE_ASSIGNEE), dto.getLogin());
void removeUserFromGroups(long userId);
- void deleteUnsharedUserIssueFilters(String login);
-
- void deleteUserIssueFilterFavourites(String login);
-
void deleteUserProperties(long userId);
void deleteUserRoles(long userId);
+++ /dev/null
-<?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.issue.IssueFilterFavouriteMapper">
-
- <sql id="issueFilterFavouriteColumns">
- filter_favourites.id as id,
- filter_favourites.user_login as userLogin,
- filter_favourites.issue_filter_id as issueFilterId,
- filter_favourites.created_at as createdAt
- </sql>
-
- <select id="selectById" parameterType="long" resultType="issueFilterFavourite">
- select
- <include refid="issueFilterFavouriteColumns"/>
- from issue_filter_favourites filter_favourites
- where filter_favourites.id=#{id}
- </select>
-
- <select id="selectByFilterId" parameterType="long" resultType="issueFilterFavourite">
- select
- <include refid="issueFilterFavouriteColumns"/>
- from issue_filter_favourites filter_favourites
- where filter_favourites.issue_filter_id=#{filterId}
- </select>
-
- <select id="selectByUser" parameterType="string" resultType="issueFilterFavourite">
- select
- <include refid="issueFilterFavouriteColumns"/>
- from issue_filter_favourites filter_favourites
- where filter_favourites.user_login=#{login}
- </select>
-
- <insert id="insert" parameterType="issueFilterFavourite" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO issue_filter_favourites (user_login, issue_filter_id, created_at)
- VALUES (#{userLogin}, #{issueFilterId}, current_timestamp)
- </insert>
-
- <delete id="delete" parameterType="long">
- delete from issue_filter_favourites where id=#{id}
- </delete>
-
- <delete id="deleteByFilterId" parameterType="long">
- delete from issue_filter_favourites where issue_filter_id=#{issueFilterId}
- </delete>
-
-</mapper>
+++ /dev/null
-<?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.issue.IssueFilterMapper">
-
- <sql id="issueFilterColumns">
- filters.id as id,
- filters.name as name,
- filters.user_login as userLogin,
- filters.shared as shared,
- filters.description as description,
- filters.data as data,
- filters.created_at as createdAt,
- filters.updated_at as updatedAt
- </sql>
-
- <select id="selectById" parameterType="long" resultType="IssueFilter">
- select
- <include refid="issueFilterColumns"/>
- from issue_filters filters
- where filters.id=#{id}
- </select>
-
- <select id="selectByUser" parameterType="String" resultType="IssueFilter">
- select
- <include refid="issueFilterColumns"/>
- from issue_filters filters
- where filters.user_login=#{user}
- </select>
-
- <select id="selectFavoriteFiltersByUser" parameterType="String" resultType="IssueFilter">
- select
- <include refid="issueFilterColumns"/>
- from issue_filters filters
- inner join issue_filter_favourites fav on fav.issue_filter_id = filters.id
- where fav.user_login=#{user}
- </select>
-
- <select id="selectSharedFilters" parameterType="String" resultType="IssueFilter">
- select
- <include refid="issueFilterColumns"/>
- from issue_filters filters
- where filters.shared=${_true}
- </select>
-
- <select id="selectProvidedFilterByName" parameterType="String" resultType="IssueFilter">
- select
- <include refid="issueFilterColumns"/>
- from issue_filters filters
- where filters.user_login is null
- and filters.shared=${_true}
- and filters.name=#{name}
- </select>
-
- <insert id="insert" parameterType="IssueFilter" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO issue_filters (name, user_login, shared, description, data, created_at, updated_at)
- VALUES (#{name}, #{userLogin}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt})
- </insert>
-
- <update id="update" parameterType="IssueFilter">
- update issue_filters set
- name=#{name},
- shared=#{shared},
- description=#{description},
- data=#{data},
- user_login=#{userLogin},
- updated_at=current_timestamp
- where id=#{id}
- </update>
-
- <delete id="delete" parameterType="long">
- delete from issue_filters where id=#{id}
- </delete>
-
-</mapper>
DELETE FROM properties WHERE user_id=#{id}
</delete>
- <delete id="deleteUnsharedUserIssueFilters" parameterType="String">
- DELETE FROM issue_filters WHERE user_login=#{id} and shared <> ${_true}
- </delete>
-
- <delete id="deleteUserIssueFilterFavourites" parameterType="String">
- DELETE FROM issue_filter_favourites WHERE user_login=#{id}
- </delete>
-
<delete id="deletePropertiesMatchingLogin" parameterType="String">
DELETE FROM properties
<where>
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new DaoModule().configure(container);
- assertThat(container.size()).isEqualTo(2 + 46);
+ assertThat(container.size()).isEqualTo(2 + 44);
}
}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-
-public class IssueFilterDaoTest {
-
- @Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
- IssueFilterDao dao = dbTester.getDbClient().issueFilterDao();
-
- @Test
- public void should_select_by_id() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- IssueFilterDto filter = dao.selectById(1L);
-
- assertThat(filter.getId()).isEqualTo(1L);
- assertThat(filter.getName()).isEqualTo("Sonar Issues");
- assertThat(filter.isShared()).isTrue();
-
- assertThat(dao.selectById(123L)).isNull();
- }
-
- @Test
- public void should_select_by_user() {
- dbTester.prepareDbUnit(getClass(), "should_select_by_user.xml");
-
- List<IssueFilterDto> results = dao.selectByUser("michael");
-
- assertThat(results).hasSize(2);
- }
-
- @Test
- public void should_select_by_user_with_only_favorite_filters() {
- dbTester.prepareDbUnit(getClass(), "should_select_by_user_with_only_favorite_filters.xml");
-
- List<IssueFilterDto> results = dao.selectFavoriteFiltersByUser("michael");
-
- assertThat(results).hasSize(1);
- IssueFilterDto issueFilterDto = results.get(0);
- assertThat(issueFilterDto.getId()).isEqualTo(2L);
- }
-
- @Test
- public void should_select_shared() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- assertThat(dao.selectSharedFilters()).hasSize(1);
- }
-
- @Test
- public void should_select_provided_by_name() {
- dbTester.prepareDbUnit(getClass(), "should_select_provided_by_name.xml");
-
- assertThat(dao.selectProvidedFilterByName("Unresolved Issues").getName()).isEqualTo("Unresolved Issues");
- assertThat(dao.selectProvidedFilterByName("My Unresolved Issues").getName()).isEqualTo("My Unresolved Issues");
- assertThat(dao.selectProvidedFilterByName("Unknown Filter")).isNull();
- }
-
- @Test
- public void should_insert() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- IssueFilterDto filterDto = new IssueFilterDto();
- filterDto.setName("Sonar Open issues");
- filterDto.setUserLogin("michael");
- filterDto.setShared(true);
- filterDto.setDescription("All open issues on Sonar");
- filterDto.setData("statuses=OPEN|componentRoots=org.codehaus.sonar");
-
- dao.insert(filterDto);
-
- dbTester.assertDbUnit(getClass(), "should_insert-result.xml", new String[]{"created_at", "updated_at"}, "issue_filters");
- }
-
- @Test
- public void should_update() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- IssueFilterDto filterDto = new IssueFilterDto();
- filterDto.setId(2L);
- filterDto.setName("Closed issues");
- filterDto.setShared(false);
- filterDto.setDescription("All closed issues");
- filterDto.setData("statuses=CLOSED");
- filterDto.setUserLogin("bernard");
-
- dao.update(filterDto);
-
- dbTester.assertDbUnit(getClass(), "should_update-result.xml", new String[]{"created_at", "updated_at"}, "issue_filters");
- }
-
- @Test
- public void should_delete() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- dao.delete(1l);
-
- dbTester.assertDbUnit(getClass(), "should_delete-result.xml", new String[] {"created_at", "updated_at"}, "issue_filters");
- }
-}
+++ /dev/null
-/*
- * 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.issue;
-
-import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-
-public class IssueFilterFavouriteDaoTest {
-
- @Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
- IssueFilterFavouriteDao dao = dbTester.getDbClient().issueFilterFavouriteDao();
-
- @Test
- public void should_select_by_id() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- IssueFilterFavouriteDto dto = dao.selectById(1L);
- assertThat(dto.getId()).isEqualTo(1L);
- assertThat(dto.getUserLogin()).isEqualTo("stephane");
- assertThat(dto.getIssueFilterId()).isEqualTo(10L);
- assertThat(dto.getCreatedAt()).isNotNull();
-
- assertThat(dao.selectById(999L)).isNull();
- }
-
- @Test
- public void should_select_by_filter_id() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- List<IssueFilterFavouriteDto> dtos = dao.selectByFilterId(11L);
- assertThat(dtos).hasSize(1);
- IssueFilterFavouriteDto dto = dtos.get(0);
- assertThat(dto.getId()).isEqualTo(2L);
- assertThat(dto.getUserLogin()).isEqualTo("stephane");
- assertThat(dto.getIssueFilterId()).isEqualTo(11L);
- assertThat(dto.getCreatedAt()).isNotNull();
-
- assertThat(dao.selectByFilterId(10L)).hasSize(2);
- assertThat(dao.selectByFilterId(999L)).isEmpty();
- }
-
- @Test
- public void should_insert() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- IssueFilterFavouriteDto dto = new IssueFilterFavouriteDto();
- dto.setUserLogin("arthur");
- dto.setIssueFilterId(11L);
-
- dao.insert(dto);
-
- dbTester.assertDbUnit(getClass(), "should_insert-result.xml", new String[]{"created_at"}, "issue_filter_favourites");
- }
-
- @Test
- public void should_delete() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- dao.delete(3l);
-
- dbTester.assertDbUnit(getClass(), "should_delete-result.xml", new String[]{"created_at"}, "issue_filter_favourites");
- }
-
- @Test
- public void should_delete_by_issue_filter_id() {
- dbTester.prepareDbUnit(getClass(), "shared.xml");
-
- dao.deleteByFilterId(10l);
-
- dbTester.assertDbUnit(getClass(), "should_delete_by_issue_filter_id-result.xml", new String[]{"created_at"}, "issue_filter_favourites");
- }
-
-}
import org.sonar.db.DbSession;
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.organization.OrganizationDto;
import org.sonar.db.property.PropertyDto;
import org.sonar.db.property.PropertyQuery;
@Test
public void deactivate_user() throws Exception {
UserDto user = newActiveUser();
- IssueFilterDto issueFilter = insertIssueFilter(user, false);
- IssueFilterFavouriteDto issueFilterFavourite = insertIssueFilterFavourite(issueFilter, user);
PropertyDto property = insertProperty(user);
db.users().insertPermissionOnUser(user, "perm");
insertUserGroup(user);
assertThat(underTest.selectUserById(session, otherUser.getId())).isNotNull();
- assertThat(dbClient.issueFilterDao().selectById(session, issueFilter.getId())).isNull();
- assertThat(dbClient.issueFilterFavouriteDao().selectById(session, issueFilterFavourite.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();
}
- @Test
- public void deactivate_user_does_not_remove_shared_issue_filter() throws Exception {
- UserDto user = newActiveUser();
- IssueFilterDto notSharedFilter = insertIssueFilter(user, false);
- IssueFilterDto sharedFilter = insertIssueFilter(user, true);
- session.commit();
-
- boolean deactivated = underTest.deactivateUserByLogin(session, user.getLogin());
- assertThat(deactivated).isTrue();
-
- assertThat(dbClient.issueFilterDao().selectById(session, notSharedFilter.getId())).isNull();
- IssueFilterDto sharedFilterReloaded = dbClient.issueFilterDao().selectById(session, sharedFilter.getId());
- assertThat(sharedFilterReloaded).isNotNull();
- assertThat(sharedFilterReloaded.getUserLogin()).isEqualTo(user.getLogin());
- }
-
@Test
public void deactivate_user_also_remove_default_assignee_login_properties() throws Exception {
UserDto user = newActiveUser();
return dto;
}
- private IssueFilterDto insertIssueFilter(UserDto user, boolean shared) {
- IssueFilterDto dto = new IssueFilterDto().setUserLogin(user.getLogin()).setName(randomAlphanumeric(100)).setShared(shared);
- dbClient.issueFilterDao().insert(session, dto);
- return dto;
- }
-
- private IssueFilterFavouriteDto insertIssueFilterFavourite(IssueFilterDto filter, UserDto user) {
- IssueFilterFavouriteDto dto = new IssueFilterFavouriteDto().setUserLogin(user.getLogin()).setIssueFilterId(filter.getId());
- dbClient.issueFilterFavouriteDao().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);
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="1"
- name="Sonar Issues"
- user_login="stephane"
- shared="[true]"
- description="All issues of Sonar"
- data="componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="2"
- name="Open issues"
- user_login="michael"
- shared="[false]"
- description="All open issues"
- data="statuses=OPEN"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="2"
- name="Open issues"
- user_login="michael"
- shared="[false]"
- description="All open issues"
- data="statuses=OPEN"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="1"
- name="Sonar Issues"
- user_login="stephane"
- shared="[true]"
- description="All issues of Sonar"
- data="componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="2"
- name="Open issues"
- user_login="michael"
- shared="[false]"
- description="All open issues"
- data="statuses=OPEN"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
-
- <issue_filters
- id="3"
- name="Sonar Open issues"
- user_login="michael"
- shared="[true]"
- description="All open issues on Sonar"
- data="statuses=OPEN|componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="1"
- name="Sonar Issues"
- user_login="stephane"
- shared="[true]"
- description="All issues of Sonar"
- data="componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="2"
- name="Open issues"
- user_login="michael"
- shared="[false]"
- description="All open issues"
- data="statuses=OPEN"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="3"
- name="Sonar Open issues"
- user_login="michael"
- shared="[true]"
- description="All open issues on Sonar"
- data="statuses=OPEN|componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="1"
- name="Sonar Issues"
- user_login="stephane"
- shared="[true]"
- description="All issues of Sonar"
- data="componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="2"
- name="Open issues"
- user_login="michael"
- shared="[false]"
- description="All open issues"
- data="statuses=OPEN"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="3"
- name="Sonar Open issues"
- user_login="michael"
- shared="[true]"
- description="All open issues on Sonar"
- data="statuses=OPEN|componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="10"
- user_login="michael"
- issue_filter_id="2"
- created_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <!-- This one must be found -->
- <issue_filters
- id="1"
- name="Unresolved Issues"
- user_login="[null]"
- shared="[true]"
- description="[null]"
- data="resolved=false"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00"/>
-
- <!-- This one must NOT be found: belongs to admin -->
- <issue_filters
- id="2"
- name="Unresolved Issues"
- user_login="admin"
- shared="[true]"
- description="[null]"
- data="resolved=false"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00"/>
-
- <!-- This one must NOT be found: not shared -->
- <issue_filters
- id="3"
- name="Unresolved Issues"
- user_login="[null]"
- shared="[false]"
- description="[null]"
- data="resolved=false"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00"/>
-
- <!-- This one must be found -->
- <issue_filters
- id="4"
- name="My Unresolved Issues"
- user_login="[null]"
- shared="[true]"
- description="[null]"
- data="resolved=false|assignees=__me__"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00"/>
-
- <!-- This one must NOT be found: not shared -->
- <issue_filters
- id="5"
- name="Unknown Filter"
- user_login="[null]"
- shared="[false]"
- description="[null]"
- data="resolved=false"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="1"
- name="Sonar Issues"
- user_login="stephane"
- shared="[true]"
- description="All issues of Sonar"
- data="componentRoots=org.codehaus.sonar"
- created_at="2013-06-10"
- updated_at="2013-06-10"/>
-
- <issue_filters
- id="2"
- name="Closed issues"
- user_login="bernard"
- shared="[false]"
- description="All closed issues"
- data="statuses=CLOSED"
- created_at="2013-06-10"
- updated_at="2013-06-11"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filter_favourites
- id="1"
- user_login="stephane"
- issue_filter_id="10"
- created_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="2"
- user_login="stephane"
- issue_filter_id="11"
- created_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="3"
- user_login="arthur"
- issue_filter_id="10"
- created_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filter_favourites
- id="1"
- user_login="stephane"
- issue_filter_id="10"
- created_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="2"
- user_login="stephane"
- issue_filter_id="11"
- created_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filter_favourites
- id="2"
- user_login="stephane"
- issue_filter_id="11"
- created_at="2013-06-10"/>
-
-</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filter_favourites
- id="1"
- user_login="stephane"
- issue_filter_id="10"
- created_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="2"
- user_login="stephane"
- issue_filter_id="11"
- created_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="3"
- user_login="arthur"
- issue_filter_id="10"
- created_at="2013-06-10"/>
-
- <issue_filter_favourites
- id="4"
- user_login="arthur"
- issue_filter_id="11"
- created_at="2013-06-18"/>
-
-</dataset>