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;
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;
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);
return permissionTemplateTester;
}
+ public PropertyDbTester properties() {
+ return propertyTester;
+ }
+
public QualityGateDbTester qualityGates() {
return qualityGateDbTester;
}
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;
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;
}
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;
+ }
}