aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-01-30 17:36:15 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-02-02 16:12:13 +0100
commit6793f543cc7b6d8a074dfa00d20c5706007d13a7 (patch)
tree14fede539aae99ff09d8bb2015c3e9e1020e9904 /sonar-db/src
parent7efab8ef44b618e27427be25df59df751e0bf814 (diff)
downloadsonarqube-6793f543cc7b6d8a074dfa00d20c5706007d13a7.tar.gz
sonarqube-6793f543cc7b6d8a074dfa00d20c5706007d13a7.zip
SONAR-8651 add and use OrganizationDbTester.setDefaultTemplates with dtos
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/organization/OrganizationDbTester.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/organization/OrganizationDbTester.java b/sonar-db/src/test/java/org/sonar/db/organization/OrganizationDbTester.java
index 15f8c312626..ee67f83555b 100644
--- a/sonar-db/src/test/java/org/sonar/db/organization/OrganizationDbTester.java
+++ b/sonar-db/src/test/java/org/sonar/db/organization/OrganizationDbTester.java
@@ -22,6 +22,9 @@ package org.sonar.db.organization;
import javax.annotation.Nullable;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
+import org.sonar.db.permission.template.PermissionTemplateDto;
+
+import static com.google.common.base.Preconditions.checkArgument;
public class OrganizationDbTester {
private final DbTester dbTester;
@@ -55,10 +58,24 @@ public class OrganizationDbTester {
return dto;
}
+ public void setDefaultTemplates(PermissionTemplateDto projectDefaultTemplate, @Nullable PermissionTemplateDto viewDefaultTemplate) {
+ checkArgument(viewDefaultTemplate == null
+ || viewDefaultTemplate.getOrganizationUuid().equals(projectDefaultTemplate.getOrganizationUuid()),
+ "default template for project and view must belong to the same organization");
+
+ DbSession dbSession = dbTester.getSession();
+ dbTester.getDbClient().organizationDao().setDefaultTemplates(dbSession, projectDefaultTemplate.getOrganizationUuid(),
+ new DefaultTemplates()
+ .setProjectUuid(projectDefaultTemplate.getUuid())
+ .setViewUuid(viewDefaultTemplate == null ? null : viewDefaultTemplate.getUuid()));
+ dbSession.commit();
+ }
+
public void setDefaultTemplates(OrganizationDto defaultOrganization,
String projectDefaultTemplateUuid, @Nullable String viewDefaultTemplateUuid) {
DbSession dbSession = dbTester.getSession();
- dbTester.getDbClient().organizationDao().setDefaultTemplates(dbSession, defaultOrganization.getUuid(), new DefaultTemplates().setProjectUuid(projectDefaultTemplateUuid).setViewUuid(viewDefaultTemplateUuid));
+ dbTester.getDbClient().organizationDao().setDefaultTemplates(dbSession, defaultOrganization.getUuid(),
+ new DefaultTemplates().setProjectUuid(projectDefaultTemplateUuid).setViewUuid(viewDefaultTemplateUuid));
dbSession.commit();
}