aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-08 21:14:10 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-02-10 22:49:09 +0100
commitf4b595f075588f33a9b955758f36536104330663 (patch)
treea36ba3a8c1ca1ba7e3ab78782af2e769b11aad2b /sonar-db
parent9fe9e202fe21e5c62378e11992cc46c8122ddf56 (diff)
downloadsonarqube-f4b595f075588f33a9b955758f36536104330663.tar.gz
sonarqube-f4b595f075588f33a9b955758f36536104330663.zip
Add and complete DbTester#properties()
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DbTester.java7
-rw-r--r--sonar-db/src/test/java/org/sonar/db/property/PropertyDbTester.java18
2 files changed, 25 insertions, 0 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java
index 7f48f1242c3..17651fa8bd5 100644
--- a/sonar-db/src/test/java/org/sonar/db/DbTester.java
+++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java
@@ -72,6 +72,7 @@ import org.sonar.db.organization.OrganizationDbTester;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.organization.OrganizationTesting;
import org.sonar.db.permission.template.PermissionTemplateDbTester;
+import org.sonar.db.property.PropertyDbTester;
import org.sonar.db.qualitygate.QualityGateDbTester;
import org.sonar.db.qualityprofile.QualityProfileDbTester;
import org.sonar.db.rule.RuleDbTester;
@@ -111,6 +112,7 @@ public class DbTester extends ExternalResource {
private final EventDbTester eventTester;
private final OrganizationDbTester organizationTester;
private final PermissionTemplateDbTester permissionTemplateTester;
+ private final PropertyDbTester propertyTester;
private final QualityGateDbTester qualityGateDbTester;
private final IssueDbTester issueDbTester;
private final RuleDbTester ruleDbTester;
@@ -128,6 +130,7 @@ public class DbTester extends ExternalResource {
this.eventTester = new EventDbTester(this);
this.organizationTester = new OrganizationDbTester(this);
this.permissionTemplateTester = new PermissionTemplateDbTester(this);
+ this.propertyTester = new PropertyDbTester(this);
this.qualityGateDbTester = new QualityGateDbTester(this);
this.issueDbTester = new IssueDbTester(this);
this.ruleDbTester = new RuleDbTester(this);
@@ -223,6 +226,10 @@ public class DbTester extends ExternalResource {
return permissionTemplateTester;
}
+ public PropertyDbTester properties() {
+ return propertyTester;
+ }
+
public QualityGateDbTester qualityGates() {
return qualityGateDbTester;
}
diff --git a/sonar-db/src/test/java/org/sonar/db/property/PropertyDbTester.java b/sonar-db/src/test/java/org/sonar/db/property/PropertyDbTester.java
index 14473e6e6dd..b2bb7b7c5a4 100644
--- a/sonar-db/src/test/java/org/sonar/db/property/PropertyDbTester.java
+++ b/sonar-db/src/test/java/org/sonar/db/property/PropertyDbTester.java
@@ -23,6 +23,7 @@ import com.google.common.base.Joiner;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import javax.annotation.Nullable;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
@@ -30,6 +31,7 @@ import org.sonar.db.DbTester;
import org.sonar.db.component.ComponentDto;
import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.property.PropertyTesting.newComponentPropertyDto;
import static org.sonar.db.property.PropertyTesting.newGlobalPropertyDto;
@@ -86,4 +88,20 @@ public class PropertyDbTester {
}
insertProperties(propertyDtos);
}
+
+ public PropertyDbTester verifyInternal(String key, @Nullable String expectedValue) {
+ Optional<String> value = dbClient.internalPropertiesDao().selectByKey(dbSession, key);
+ if (expectedValue == null) {
+ assertThat(value).isEmpty();
+ } else {
+ assertThat(value).hasValue(expectedValue);
+ }
+ return this;
+ }
+
+ public PropertyDbTester insertInternal(String key, String value) {
+ dbClient.internalPropertiesDao().save(dbSession, key, value);
+ dbSession.commit();
+ return this;
+ }
}