aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-08-20 16:49:52 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-08-24 10:09:52 +0200
commit9cf53a057f8d0cb669d26e51df9b16249d543f3d (patch)
tree97679c84abf83244c4aa9e254e3ce2c46e222ab6 /sonar-db/src
parent4aa1109a0c4d704c7f112669d91373b593097c38 (diff)
downloadsonarqube-9cf53a057f8d0cb669d26e51df9b16249d543f3d.tar.gz
sonarqube-9cf53a057f8d0cb669d26e51df9b16249d543f3d.zip
Remove selectGroupByName methods from UserDao
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/permission/PermissionRepository.java4
-rw-r--r--sonar-db/src/main/java/org/sonar/db/user/GroupDao.java6
-rw-r--r--sonar-db/src/main/java/org/sonar/db/user/UserDao.java26
-rw-r--r--sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/user/UserDaoTest.java22
5 files changed, 6 insertions, 54 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/permission/PermissionRepository.java b/sonar-db/src/main/java/org/sonar/db/permission/PermissionRepository.java
index f34ce6cc9f8..24d39bc3d41 100644
--- a/sonar-db/src/main/java/org/sonar/db/permission/PermissionRepository.java
+++ b/sonar-db/src/main/java/org/sonar/db/permission/PermissionRepository.java
@@ -98,7 +98,7 @@ public class PermissionRepository {
if (DefaultGroups.isAnyone(groupName)) {
insertGroupPermission(resourceId, (Long) null, permission, session);
} else {
- GroupDto group = dbClient.userDao().selectGroupByName(groupName, session);
+ GroupDto group = dbClient.groupDao().selectByName(session, groupName);
if (group != null) {
insertGroupPermission(resourceId, group.getId(), permission, session);
}
@@ -118,7 +118,7 @@ public class PermissionRepository {
if (DefaultGroups.isAnyone(groupName)) {
deleteGroupPermission(resourceId, (Long) null, permission, session);
} else {
- GroupDto group = dbClient.userDao().selectGroupByName(groupName, session);
+ GroupDto group = dbClient.groupDao().selectByName(session, groupName);
if (group != null) {
deleteGroupPermission(resourceId, group.getId(), permission, session);
}
diff --git a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java
index cf2f1d1e4d1..2b316fec8b0 100644
--- a/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/user/GroupDao.java
@@ -40,8 +40,8 @@ public class GroupDao implements Dao {
this.system = system;
}
- public GroupDto selectOrFailByKey(DbSession session, String key) {
- GroupDto group = selectByKey(session, key);
+ public GroupDto selectOrFailByName(DbSession session, String key) {
+ GroupDto group = selectByName(session, key);
if (group == null) {
throw new RowNotFoundException(String.format("Could not find a group with name '%s'", key));
}
@@ -49,7 +49,7 @@ public class GroupDao implements Dao {
}
@CheckForNull
- public GroupDto selectByKey(DbSession session, String key) {
+ public GroupDto selectByName(DbSession session, String key) {
return mapper(session).selectByKey(key);
}
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 5c1e52d5f8c..451554b2a49 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
@@ -158,32 +158,6 @@ public class UserDao implements Dao {
}
}
- /**
- * Search for group by name.
- *
- * @return the group, null if group not found
- *
- * TODO should be moved to GroupDao
- */
- @CheckForNull
- public GroupDto selectGroupByName(String name, DbSession session) {
- UserMapper mapper = session.getMapper(UserMapper.class);
- return mapper.selectGroupByName(name);
- }
-
- /**
- * TODO should be moved to GroupDao
- */
- @CheckForNull
- public GroupDto selectGroupByName(String name) {
- DbSession session = mybatis.openSession(false);
- try {
- return selectGroupByName(name, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
@CheckForNull
public UserDto selectByLogin(DbSession session, String login) {
return mapper(session).selectByLogin(login);
diff --git a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java
index 003f0a46ff0..c09cd3ff4af 100644
--- a/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/user/GroupDaoTest.java
@@ -62,7 +62,7 @@ public class GroupDaoTest {
public void select_by_key() {
dbTester.prepareDbUnit(getClass(), "select_by_key.xml");
- GroupDto group = new GroupDao(system2).selectOrFailByKey(session, "sonar-users");
+ GroupDto group = new GroupDao(system2).selectOrFailByName(session, "sonar-users");
assertThat(group).isNotNull();
assertThat(group.getId()).isEqualTo(1L);
assertThat(group.getName()).isEqualTo("sonar-users");
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 07fea9e3c47..d0fe4e7ee84 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
@@ -19,7 +19,6 @@
*/
package org.sonar.db.user;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -163,27 +162,6 @@ public class UserDaoTest {
}
@Test
- public void selectGroupByName() {
- db.prepareDbUnit(getClass(), "selectGroupByName.xml");
-
- GroupDto group = underTest.selectGroupByName("sonar-users");
- assertThat(group).isNotNull();
- assertThat(group.getId()).isEqualTo(1L);
- assertThat(group.getName()).isEqualTo("sonar-users");
- assertThat(group.getDescription()).isEqualTo("Sonar Users");
- assertThat(group.getCreatedAt()).isNotNull();
- assertThat(group.getUpdatedAt()).isNotNull();
- }
-
- @Test
- public void selectGroupByName_not_found() {
- db.prepareDbUnit(getClass(), "selectGroupByName.xml");
-
- GroupDto group = underTest.selectGroupByName("not-found");
- assertThat(group).isNull();
- }
-
- @Test
public void insert_user() {
Long date = DateUtils.parseDate("2014-06-20").getTime();