aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-08-26 10:08:25 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-08-27 09:50:00 +0200
commit534f06f13130dda4c572a4192ae6e8b0b9c48b30 (patch)
treefeeb74935bced02914f120f4601f6bafed3360b5 /sonar-db
parent61050e0245725fc9fdca23825d49ccf3cfa2bba2 (diff)
downloadsonarqube-534f06f13130dda4c572a4192ae6e8b0b9c48b30.tar.gz
sonarqube-534f06f13130dda4c572a4192ae6e8b0b9c48b30.zip
SONAR-6497 WS permissions/update/template update a permission template
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java12
-rw-r--r--sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java4
2 files changed, 9 insertions, 7 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java b/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java
index 23164c14160..535d98648fd 100644
--- a/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java
@@ -127,15 +127,15 @@ public class PermissionTemplateDao implements Dao {
}
@CheckForNull
- public PermissionTemplateDto selectTemplateByKey(DbSession session, String templateKey) {
+ public PermissionTemplateDto selectByKey(DbSession session, String templateKey) {
return mapper(session).selectByKey(templateKey);
}
@CheckForNull
- public PermissionTemplateDto selectTemplateByKey(String templateKey) {
+ public PermissionTemplateDto selectByKey(String templateKey) {
DbSession session = myBatis.openSession(false);
try {
- return selectTemplateByKey(session, templateKey);
+ return selectByKey(session, templateKey);
} finally {
MyBatis.closeQuietly(session);
}
@@ -243,9 +243,11 @@ public class PermissionTemplateDao implements Dao {
}
}
- public void update(DbSession session, PermissionTemplateDto permissionTemplate) {
+ public PermissionTemplateDto update(DbSession session, PermissionTemplateDto permissionTemplate) {
mapper(session).update(permissionTemplate);
session.commit();
+
+ return permissionTemplate;
}
/**
@@ -342,7 +344,7 @@ public class PermissionTemplateDao implements Dao {
*/
@VisibleForTesting
PermissionTemplateDto selectPermissionTemplateWithPermissions(DbSession session, String templateKey) {
- PermissionTemplateDto permissionTemplateDto = selectTemplateByKey(session, templateKey);
+ PermissionTemplateDto permissionTemplateDto = selectByKey(session, templateKey);
if (permissionTemplateDto == null) {
throw new IllegalArgumentException("Could not retrieve permission template with key " + templateKey);
}
diff --git a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java
index 0a301480170..3c672eb5082 100644
--- a/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/permission/PermissionTemplateDaoTest.java
@@ -124,7 +124,7 @@ public class PermissionTemplateDaoTest {
public void should_select_permission_template_by_key() {
dbTester.prepareDbUnit(getClass(), "selectPermissionTemplate.xml");
- PermissionTemplateDto permissionTemplate = underTest.selectTemplateByKey("my_template_20130102_030405");
+ PermissionTemplateDto permissionTemplate = underTest.selectByKey("my_template_20130102_030405");
assertThat(permissionTemplate).isNotNull();
assertThat(permissionTemplate.getId()).isEqualTo(1L);
@@ -235,7 +235,7 @@ public class PermissionTemplateDaoTest {
PermissionTemplateDto permissionTemplateDto = new PermissionTemplateDto().setName("Test template").setKee("test_template");
PermissionTemplateDto templateWithPermissions = new PermissionTemplateDto().setKee("test_template");
underTest = mock(PermissionTemplateDao.class);
- when(underTest.selectTemplateByKey(dbTester.getSession(), "test_template")).thenReturn(permissionTemplateDto);
+ when(underTest.selectByKey(dbTester.getSession(), "test_template")).thenReturn(permissionTemplateDto);
when(underTest.selectPermissionTemplate(dbTester.getSession(), "test_template")).thenReturn(templateWithPermissions);
when(underTest.selectPermissionTemplateWithPermissions(dbTester.getSession(), "test_template")).thenCallRealMethod();