aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-09-20 11:59:16 -0500
committersonartech <sonartech@sonarsource.com>2022-10-12 20:03:43 +0000
commit566094fc629ab1e92afb0cdf191a0e2c685b5c35 (patch)
treece172266109cf1c4e81a041e460c6cc7bcd5d50e /server/sonar-db-dao
parentbcfb1cac55137b838da7a93385b20e0e5ed47abb (diff)
downloadsonarqube-566094fc629ab1e92afb0cdf191a0e2c685b5c35.tar.gz
sonarqube-566094fc629ab1e92afb0cdf191a0e2c685b5c35.zip
SONAR-17352 Refactor component keys to not include branch suffix
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java113
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java31
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java20
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithBranchUuidDto.java (renamed from server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithProjectUuidDto.java)14
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java8
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml3
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml79
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml16
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml12
-rw-r--r--server/sonar-db-dao/src/schema/schema-sq.ddl5
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java247
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java26
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java57
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java14
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java36
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java14
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/report/RegulatoryReportDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoWithPersisterTest.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java10
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java45
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/SnapshotTesting.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java4
44 files changed, 380 insertions, 466 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
index 14da008f50e..515fd70c61a 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java
@@ -62,7 +62,7 @@ import org.sonar.db.component.ResourceDto;
import org.sonar.db.component.ScrapAnalysisPropertyDto;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.component.SnapshotMapper;
-import org.sonar.db.component.UuidWithProjectUuidDto;
+import org.sonar.db.component.UuidWithBranchUuidDto;
import org.sonar.db.component.ViewsSnapshotDto;
import org.sonar.db.duplication.DuplicationMapper;
import org.sonar.db.duplication.DuplicationUnitDto;
@@ -243,7 +243,7 @@ public class MyBatis {
confBuilder.loadAlias("UserTelemetry", UserTelemetryDto.class);
confBuilder.loadAlias("UserToken", UserTokenDto.class);
confBuilder.loadAlias("UserTokenCount", UserTokenCount.class);
- confBuilder.loadAlias("UuidWithProjectUuid", UuidWithProjectUuidDto.class);
+ confBuilder.loadAlias("UuidWithBranchUuid", UuidWithBranchUuidDto.class);
confBuilder.loadAlias("ViewsSnapshot", ViewsSnapshotDto.class);
confExtensions.forEach(ext -> ext.loadAliases(confBuilder::loadAlias));
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
index 38cca4e8201..f655c175cfd 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
@@ -92,7 +92,7 @@ public class BranchDao implements Dao {
public Collection<BranchDto> selectByComponent(DbSession dbSession, ComponentDto component) {
String projectUuid = component.getMainBranchProjectUuid();
if (projectUuid == null) {
- projectUuid = component.projectUuid();
+ projectUuid = component.branchUuid();
}
return mapper(dbSession).selectByProjectUuid(projectUuid);
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
index b11d2801afd..d843733d1ff 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDao.java
@@ -23,6 +23,7 @@ import com.google.common.collect.Ordering;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -32,6 +33,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.sonar.api.resources.Qualifiers;
@@ -44,14 +46,10 @@ import org.sonar.db.audit.model.ComponentNewValue;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Collections.emptyList;
-import static org.sonar.core.util.stream.MoreCollectors.toList;
-import static org.sonar.core.util.stream.MoreCollectors.toSet;
import static org.sonar.db.DatabaseUtils.checkThatNotTooManyConditions;
import static org.sonar.db.DatabaseUtils.executeLargeInputs;
import static org.sonar.db.DatabaseUtils.executeLargeInputsIntoSet;
import static org.sonar.db.DatabaseUtils.executeLargeUpdates;
-import static org.sonar.db.component.ComponentDto.generateBranchKey;
-import static org.sonar.db.component.ComponentDto.generatePullRequestKey;
public class ComponentDao implements Dao {
private final AuditPersister auditPersister;
@@ -85,11 +83,7 @@ public class ComponentDao implements Dao {
}
public ComponentDto selectOrFailByUuid(DbSession session, String uuid) {
- Optional<ComponentDto> componentDto = selectByUuid(session, uuid);
- if (!componentDto.isPresent()) {
- throw new RowNotFoundException(String.format("Component with uuid '%s' not found", uuid));
- }
- return componentDto.get();
+ return selectByUuid(session, uuid).orElseThrow(() -> new RowNotFoundException(String.format("Component with uuid '%s' not found", uuid)));
}
/**
@@ -156,8 +150,8 @@ public class ComponentDao implements Dao {
return mapper(session).selectComponentsFromProjectKeyAndScope(projectKey, Scopes.PROJECT, excludeDisabled);
}
- public int countEnabledModulesByProjectUuid(DbSession session, String projectUuid) {
- return mapper(session).countEnabledModulesByProjectUuid(projectUuid);
+ public int countEnabledModulesByBranchUuid(DbSession session, String branchUuid) {
+ return mapper(session).countEnabledModulesByBranchUuid(branchUuid);
}
public List<ComponentDto> selectEnabledModulesFromProjectKey(DbSession session, String projectKey) {
@@ -169,30 +163,45 @@ public class ComponentDao implements Dao {
}
public List<ComponentDto> selectByKeysAndBranch(DbSession session, Collection<String> keys, String branch) {
- List<String> dbKeys = keys.stream().map(k -> generateBranchKey(k, branch)).collect(toList());
- List<String> allKeys = Stream.of(keys, dbKeys).flatMap(Collection::stream).collect(toList());
- return executeLargeInputs(allKeys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, branch));
- }
-
- /**
- * Return list of components that will will mix main and branch components.
- * Please note that a project can only appear once in the list, it's not possible to ask for many branches on same project with this method.
- */
- public List<ComponentDto> selectByKeysAndBranches(DbSession session, Map<String, String> branchesByKey) {
- Set<String> dbKeys = branchesByKey.entrySet().stream()
- .map(entry -> generateBranchKey(entry.getKey(), entry.getValue()))
- .collect(toSet());
- return selectByDbKeys(session, dbKeys);
- }
-
- public List<ComponentDto> selectByDbKeys(DbSession session, Set<String> dbKeys) {
- return executeLargeInputs(dbKeys, subKeys -> mapper(session).selectByDbKeys(subKeys));
+ return executeLargeInputs(keys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, branch));
}
public List<ComponentDto> selectByKeysAndPullRequest(DbSession session, Collection<String> keys, String pullRequestId) {
- List<String> dbKeys = keys.stream().map(k -> generatePullRequestKey(k, pullRequestId)).collect(toList());
- List<String> allKeys = Stream.of(keys, dbKeys).flatMap(Collection::stream).collect(toList());
- return executeLargeInputs(allKeys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, pullRequestId));
+ return executeLargeInputs(keys, subKeys -> mapper(session).selectByKeysAndBranch(subKeys, pullRequestId));
+ }
+
+ public List<ComponentDto> selectByDbKeys(DbSession session, Collection<String> dbKeys) {
+ Map<String, List<String>> keyByBranchKey = new HashMap<>();
+ Map<String, List<String>> keyByPrKey = new HashMap<>();
+ List<String> mainBranchKeys = new LinkedList<>();
+
+ for (String dbKey : dbKeys) {
+ String branchKey = StringUtils.substringAfterLast(dbKey, ComponentDto.BRANCH_KEY_SEPARATOR);
+ if (!StringUtils.isEmpty(branchKey)) {
+ keyByBranchKey.computeIfAbsent(branchKey, b -> new LinkedList<>())
+ .add(StringUtils.substringBeforeLast(dbKey, ComponentDto.BRANCH_KEY_SEPARATOR));
+ continue;
+ }
+
+ String prKey = StringUtils.substringAfterLast(dbKey, ComponentDto.PULL_REQUEST_SEPARATOR);
+ if (!StringUtils.isEmpty(prKey)) {
+ keyByPrKey.computeIfAbsent(prKey, b -> new LinkedList<>())
+ .add(StringUtils.substringBeforeLast(dbKey, ComponentDto.PULL_REQUEST_SEPARATOR));
+ continue;
+ }
+
+ mainBranchKeys.add(dbKey);
+ }
+
+ List<ComponentDto> components = new LinkedList<>();
+ for (Map.Entry<String, List<String>> e : keyByBranchKey.entrySet()) {
+ components.addAll(selectByKeysAndBranch(session, e.getValue(), e.getKey()));
+ }
+ for (Map.Entry<String, List<String>> e : keyByPrKey.entrySet()) {
+ components.addAll(selectByKeysAndPullRequest(session, e.getValue(), e.getKey()));
+ }
+ components.addAll(selectByKeys(session, mainBranchKeys));
+ return components;
}
/**
@@ -230,11 +239,7 @@ public class ComponentDao implements Dao {
}
public ComponentDto selectOrFailByKey(DbSession session, String key) {
- Optional<ComponentDto> component = selectByKey(session, key);
- if (!component.isPresent()) {
- throw new RowNotFoundException(String.format("Component key '%s' not found", key));
- }
- return component.get();
+ return selectByKey(session, key).orElseThrow(() -> new RowNotFoundException(String.format("Component key '%s' not found", key)));
}
public Optional<ComponentDto> selectByKey(DbSession session, String key) {
@@ -246,14 +251,14 @@ public class ComponentDao implements Dao {
}
public Optional<ComponentDto> selectByKeyAndBranch(DbSession session, String key, String branch) {
- return Optional.ofNullable(mapper(session).selectBranchByKeyAndBranchKey(key, generateBranchKey(key, branch), branch));
+ return Optional.ofNullable(mapper(session).selectByKeyAndBranchKey(key, branch));
}
public Optional<ComponentDto> selectByKeyAndPullRequest(DbSession session, String key, String pullRequestId) {
- return Optional.ofNullable(mapper(session).selectPrByKeyAndBranchKey(key, generatePullRequestKey(key, pullRequestId), pullRequestId));
+ return Optional.ofNullable(mapper(session).selectByKeyAndPrKey(key, pullRequestId));
}
- public List<UuidWithProjectUuidDto> selectAllViewsAndSubViews(DbSession session) {
+ public List<UuidWithBranchUuidDto> selectAllViewsAndSubViews(DbSession session) {
return mapper(session).selectUuidsForQualifiers(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW);
}
@@ -295,12 +300,12 @@ public class ComponentDao implements Dao {
}
/**
- * Retrieves all components with a specific root project Uuid, no other filtering is done by this method.
+ * Retrieves all components with a specific branch UUID, no other filtering is done by this method.
* <p>
* Used by Views plugin
*/
- public List<ComponentDto> selectByProjectUuid(String projectUuid, DbSession dbSession) {
- return mapper(dbSession).selectByProjectUuid(projectUuid);
+ public List<ComponentDto> selectByBranchUuid(String branchUuid, DbSession dbSession) {
+ return mapper(dbSession).selectByBranchUuid(branchUuid);
}
/**
@@ -340,8 +345,8 @@ public class ComponentDao implements Dao {
* Scroll all <strong>enabled</strong> files of the specified project (same project_uuid) in no specific order with
* 'SOURCE' source and a non null path.
*/
- public void scrollAllFilesForFileMove(DbSession session, String projectUuid, ResultHandler<FileMoveRowDto> handler) {
- mapper(session).scrollAllFilesForFileMove(projectUuid, handler);
+ public void scrollAllFilesForFileMove(DbSession session, String branchUuid, ResultHandler<FileMoveRowDto> handler) {
+ mapper(session).scrollAllFilesForFileMove(branchUuid, handler);
}
public void insert(DbSession session, ComponentDto item) {
@@ -373,23 +378,23 @@ public class ComponentDao implements Dao {
executeLargeUpdates(uuids, mapper(session)::updateBEnabledToFalse);
}
- public void applyBChangesForRootComponentUuid(DbSession session, String projectUuid) {
- mapper(session).applyBChangesForRootComponentUuid(projectUuid);
+ public void applyBChangesForRootComponentUuid(DbSession session, String branchUuid) {
+ mapper(session).applyBChangesForRootComponentUuid(branchUuid);
}
- public void resetBChangedForRootComponentUuid(DbSession session, String projectUuid) {
- mapper(session).resetBChangedForRootComponentUuid(projectUuid);
+ public void resetBChangedForRootComponentUuid(DbSession session, String branchUuid) {
+ mapper(session).resetBChangedForRootComponentUuid(branchUuid);
}
- public void setPrivateForRootComponentUuidWithoutAudit(DbSession session, String projectUuid, boolean isPrivate) {
- mapper(session).setPrivateForRootComponentUuid(projectUuid, isPrivate);
+ public void setPrivateForRootComponentUuidWithoutAudit(DbSession session, String branchUuid, boolean isPrivate) {
+ mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
}
- public void setPrivateForRootComponentUuid(DbSession session, String projectUuid, boolean isPrivate,
+ public void setPrivateForRootComponentUuid(DbSession session, String branchUuid, boolean isPrivate,
@Nullable String qualifier, String componentKey, String componentName) {
- ComponentNewValue componentNewValue = new ComponentNewValue(projectUuid, componentName, componentKey, isPrivate, qualifier);
+ ComponentNewValue componentNewValue = new ComponentNewValue(branchUuid, componentName, componentKey, isPrivate, qualifier);
auditPersister.updateComponentVisibility(session, componentNewValue);
- mapper(session).setPrivateForRootComponentUuid(projectUuid, isPrivate);
+ mapper(session).setPrivateForRootComponentUuid(branchUuid, isPrivate);
}
private static void checkThatNotTooManyComponents(ComponentQuery query) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
index a3818109278..cb17c2a859e 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentDto.java
@@ -24,7 +24,6 @@ import com.google.common.base.Strings;
import java.util.Date;
import java.util.List;
import java.util.Objects;
-import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -47,7 +46,6 @@ public class ComponentDto {
public static final String BRANCH_KEY_SEPARATOR = ":BRANCH:";
public static final String PULL_REQUEST_SEPARATOR = ":PULL_REQUEST:";
- private static final Splitter BRANCH_OR_PULL_REQUEST_SPLITTER = Splitter.on(Pattern.compile(BRANCH_KEY_SEPARATOR + "|" + PULL_REQUEST_SEPARATOR));
private static final Splitter BRANCH_KEY_SPLITTER = Splitter.on(BRANCH_KEY_SEPARATOR);
private static final Splitter PULL_REQUEST_SPLITTER = Splitter.on(PULL_REQUEST_SEPARATOR);
@@ -93,7 +91,7 @@ public class ComponentDto {
* - on view: UUID="5" PROJECT_UUID="5"
* - on sub-view: UUID="6" PROJECT_UUID="5"
*/
- private String projectUuid;
+ private String branchUuid;
/**
* Badly named, it is not the root !
@@ -177,24 +175,16 @@ public class ComponentDto {
return UUID_PATH_SPLITTER.splitToList(uuidPath);
}
- public String getDbKey() {
+ public String getKey() {
return kee;
}
- public ComponentDto setDbKey(String key) {
+ public ComponentDto setKey(String key) {
this.kee = checkComponentKey(key);
return this;
}
/**
- * The key to be displayed to user, doesn't contain information on branches
- */
- public String getKey() {
- List<String> split = BRANCH_OR_PULL_REQUEST_SPLITTER.splitToList(kee);
- return split.size() == 2 ? split.get(0) : kee;
- }
-
- /**
* @return the key of the branch. It will be null on the main branch and when the component is not on a branch
*/
@CheckForNull
@@ -233,12 +223,12 @@ public class ComponentDto {
/**
* Return the root project uuid. On a root project, return itself
*/
- public String projectUuid() {
- return projectUuid;
+ public String branchUuid() {
+ return branchUuid;
}
- public ComponentDto setProjectUuid(String projectUuid) {
- this.projectUuid = projectUuid;
+ public ComponentDto setBranchUuid(String branchUuid) {
+ this.branchUuid = branchUuid;
return this;
}
@@ -320,7 +310,7 @@ public class ComponentDto {
}
/**
- * Use {@link #projectUuid()}, {@link #moduleUuid()} or {@link #moduleUuidPath()}
+ * Use {@link #branchUuid()}, {@link #moduleUuid()} or {@link #moduleUuidPath()}
*/
@Deprecated
public String getRootUuid() {
@@ -409,7 +399,7 @@ public class ComponentDto {
.append("kee", kee)
.append("scope", scope)
.append("qualifier", qualifier)
- .append("projectUuid", projectUuid)
+ .append("branchUuid", branchUuid)
.append("moduleUuid", moduleUuid)
.append("moduleUuidPath", moduleUuidPath)
.append("rootUuid", rootUuid)
@@ -426,11 +416,10 @@ public class ComponentDto {
public ComponentDto copy() {
ComponentDto copy = new ComponentDto();
- copy.projectUuid = projectUuid;
copy.kee = kee;
copy.uuid = uuid;
copy.uuidPath = uuidPath;
- copy.projectUuid = projectUuid;
+ copy.branchUuid = branchUuid;
copy.rootUuid = rootUuid;
copy.mainBranchProjectUuid = mainBranchProjectUuid;
copy.moduleUuid = moduleUuid;
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
index e62a69a23b7..98297278093 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentMapper.java
@@ -37,10 +37,10 @@ public interface ComponentMapper {
ComponentDto selectByKeyCaseInsensitive(@Param("key") String key);
@CheckForNull
- ComponentDto selectBranchByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
+ ComponentDto selectByKeyAndBranchKey(@Param("key") String key, @Param("branch") String branch);
@CheckForNull
- ComponentDto selectPrByKeyAndBranchKey(@Param("key") String key, @Param("dbKey") String dbKey, @Param("branch") String branch);
+ ComponentDto selectByKeyAndPrKey(@Param("key") String key, @Param("pr") String pr);
@CheckForNull
ComponentDto selectByUuid(@Param("uuid") String uuid);
@@ -52,19 +52,17 @@ public interface ComponentMapper {
List<ComponentDto> selectByKeys(@Param("keys") Collection<String> keys);
- List<ComponentDto> selectByDbKeys(@Param("dbKeys") Collection<String> dbKeys);
-
List<ComponentDto> selectByKeysAndBranch(@Param("keys") Collection<String> keys, @Param("branch") String branch);
List<ComponentDto> selectByUuids(@Param("uuids") Collection<String> uuids);
- List<ComponentDto> selectByProjectUuid(@Param("projectUuid") String projectUuid);
+ List<ComponentDto> selectByBranchUuid(@Param("branchUuid") String branchUuid);
List<String> selectExistingUuids(@Param("uuids") Collection<String> uuids);
List<ComponentDto> selectComponentsByQualifiers(@Param("qualifiers") Collection<String> qualifiers);
- int countEnabledModulesByProjectUuid(@Param("projectUuid") String projectUuid);
+ int countEnabledModulesByBranchUuid(@Param("branchUuid") String branchUuid);
List<ComponentDto> selectByQuery(@Param("query") ComponentQuery query, RowBounds rowBounds);
@@ -103,7 +101,7 @@ public interface ComponentMapper {
* <p/>
* It's using a join on snapshots in order to use he indexed columns snapshots.qualifier
*/
- List<UuidWithProjectUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
+ List<UuidWithBranchUuidDto> selectUuidsForQualifiers(@Param("qualifiers") String... qualifiers);
/**
* Return components of a given scope of a project
@@ -127,7 +125,7 @@ public interface ComponentMapper {
void scrollForIndexing(@Param("projectUuid") @Nullable String projectUuid, ResultHandler<ComponentDto> handler);
- void scrollAllFilesForFileMove(@Param("projectUuid") String projectUuid, ResultHandler<FileMoveRowDto> handler);
+ void scrollAllFilesForFileMove(@Param("branchUuid") String branchUuid, ResultHandler<FileMoveRowDto> handler);
void insert(ComponentDto componentDto);
@@ -135,11 +133,11 @@ public interface ComponentMapper {
void updateBEnabledToFalse(@Param("uuids") List<String> uuids);
- void applyBChangesForRootComponentUuid(@Param("projectUuid") String projectUuid);
+ void applyBChangesForRootComponentUuid(@Param("branchUuid") String branchUuid);
- void resetBChangedForRootComponentUuid(@Param("projectUuid") String projectUuid);
+ void resetBChangedForRootComponentUuid(@Param("branchUuid") String branchUuid);
- void setPrivateForRootComponentUuid(@Param("projectUuid") String projectUuid, @Param("isPrivate") boolean isPrivate);
+ void setPrivateForRootComponentUuid(@Param("branchUuid") String branchUuid, @Param("isPrivate") boolean isPrivate);
void delete(String componentUuid);
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
index 90569194c85..7268d4b8aad 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
@@ -188,7 +188,7 @@ public class ComponentUpdateDto {
return new ComponentUpdateDto()
.setUuid(from.uuid())
.setBChanged(false)
- .setBKey(from.getDbKey())
+ .setBKey(from.getKey())
.setBCopyComponentUuid(from.getCopyComponentUuid())
.setBDescription(from.description())
.setBEnabled(from.isEnabled())
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithProjectUuidDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithBranchUuidDto.java
index 96c5c1913c7..0794cfc99b4 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithProjectUuidDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/UuidWithBranchUuidDto.java
@@ -19,17 +19,17 @@
*/
package org.sonar.db.component;
-public class UuidWithProjectUuidDto {
+public class UuidWithBranchUuidDto {
private String uuid;
- private String projectUuid;
+ private String branchUuid;
- public String getProjectUuid() {
- return projectUuid;
+ public String getBranchUuid() {
+ return branchUuid;
}
- public UuidWithProjectUuidDto setProjectUuid(String projectUuid) {
- this.projectUuid = projectUuid;
+ public UuidWithBranchUuidDto setBranchUuid(String branchUuid) {
+ this.branchUuid = branchUuid;
return this;
}
@@ -37,7 +37,7 @@ public class UuidWithProjectUuidDto {
return uuid;
}
- public UuidWithProjectUuidDto setUuid(String uuid) {
+ public UuidWithBranchUuidDto setUuid(String uuid) {
this.uuid = uuid;
return this;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java
index 00a47fe64ee..80ccda2b0d7 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDao.java
@@ -101,7 +101,7 @@ public class IssueDao implements Dao {
public List<IssueDto> selectNonClosedByModuleOrProjectExcludingExternalsAndSecurityHotspots(DbSession dbSession, ComponentDto module) {
String likeModuleUuidPath = buildLikeValue(module.moduleUuidPath(), WildcardPosition.AFTER);
- return mapper(dbSession).selectNonClosedByModuleOrProject(module.projectUuid(), likeModuleUuidPath);
+ return mapper(dbSession).selectNonClosedByModuleOrProject(module.branchUuid(), likeModuleUuidPath);
}
public List<PrIssueDto> selectOpenByComponentUuids(DbSession dbSession, Collection<String> componentUuids) {
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
index 7611cff2f3c..2e9fa59db67 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
@@ -206,7 +206,7 @@ public final class IssueDto implements Serializable {
}
public IssueDto setComponent(ComponentDto component) {
- this.componentKey = component.getDbKey();
+ this.componentKey = component.getKey();
this.componentUuid = component.uuid();
this.moduleUuidPath = component.moduleUuidPath();
this.filePath = component.path();
@@ -214,7 +214,7 @@ public final class IssueDto implements Serializable {
}
public IssueDto setProject(ComponentDto project) {
- this.projectKey = project.getDbKey();
+ this.projectKey = project.getKey();
this.projectUuid = project.uuid();
return this;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
index 056a1651b2d..6addf4b8359 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueTesting.java
@@ -47,7 +47,7 @@ public class IssueTesting {
public static IssueDto newIssue(RuleDto rule, ComponentDto project, ComponentDto file) {
checkArgument(project.qualifier().equals(Qualifiers.PROJECT), "Second parameter should be a project");
- return newIssue(rule, project.uuid(), project.getDbKey(), file);
+ return newIssue(rule, project.uuid(), project.getKey(), file);
}
public static IssueDto newIssue(RuleDto rule, ProjectDto project, ComponentDto file) {
@@ -55,7 +55,7 @@ public class IssueTesting {
}
public static IssueDto newIssue(RuleDto rule, String projectUuid, String projectKey, ComponentDto file) {
- checkArgument(file.projectUuid().equals(projectUuid), "The file doesn't belong to the project");
+ checkArgument(file.branchUuid().equals(projectUuid), "The file doesn't belong to the project");
return new IssueDto()
.setKee("uuid_" + randomAlphabetic(5))
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
index cd3f294fcc6..1e8687178d4 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
@@ -34,11 +34,11 @@ public interface PurgeMapper {
*/
List<String> selectRootAndModulesOrSubviewsByProjectUuid(@Param("rootUuid") String rootUuid);
- Set<String> selectDisabledComponentsWithFileSource(@Param("projectUuid") String projectUuid);
+ Set<String> selectDisabledComponentsWithFileSource(@Param("branchUuid") String branchUuid);
- Set<String> selectDisabledComponentsWithUnresolvedIssues(@Param("projectUuid") String projectUuid);
+ Set<String> selectDisabledComponentsWithUnresolvedIssues(@Param("branchUuid") String branchUuid);
- Set<String> selectDisabledComponentsWithLiveMeasures(@Param("projectUuid") String projectUuid);
+ Set<String> selectDisabledComponentsWithLiveMeasures(@Param("branchUuid") String branchUuid);
void deleteAnalyses(@Param("analysisUuids") List<String> analysisUuids);
@@ -97,7 +97,7 @@ public interface PurgeMapper {
@CheckForNull
String selectSpecificAnalysisNewCodePeriod(@Param("projectUuid") String projectUuid);
- List<String> selectDisabledComponentsWithoutIssues(@Param("projectUuid") String projectUuid);
+ List<String> selectDisabledComponentsWithoutIssues(@Param("branchUuid") String branchUuid);
void deleteIssuesFromKeys(@Param("keys") List<String> keys);
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml
index 0cdef645451..246dc8bbf43 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml
@@ -225,8 +225,7 @@
select
case when exists
(
- select pb.project_uuid, pb.need_issue_sync from project_branches pb join components c on pb.project_uuid =
- c.project_uuid
+ select pb.project_uuid, pb.need_issue_sync from project_branches pb join components c on pb.project_uuid = c.branch_uuid
where c.kee in
<foreach collection="componentKeys" open="(" close=")" item="componentKey" separator=",">
#{componentKey,jdbcType=VARCHAR}
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index aed19c345e9..c25cc05c20b 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -5,7 +5,7 @@
<sql id="componentColumns">
p.uuid as uuid,
p.uuid_path as uuidPath,
- p.project_uuid as projectUuid,
+ p.branch_uuid as branchUuid,
p.module_uuid as moduleUuid,
p.module_uuid_path as moduleUuidPath,
p.main_branch_project_uuid as mainBranchProjectUuid,
@@ -30,6 +30,7 @@
FROM components p
where
p.kee=#{key,jdbcType=VARCHAR}
+ and p.main_branch_project_uuid is null
</select>
<select id="selectByKeyCaseInsensitive" parameterType="String" resultType="Component">
@@ -40,25 +41,25 @@
lower(p.kee)=lower(#{key,jdbcType=VARCHAR})
</select>
- <select id="selectBranchByKeyAndBranchKey" parameterType="String" resultType="Component">
+ <select id="selectByKeyAndBranchKey" parameterType="String" resultType="Component">
select
<include refid="componentColumns"/>
from components p
- inner join project_branches pb on pb.uuid = p.project_uuid
+ inner join project_branches pb on pb.uuid = p.branch_uuid
where
- (p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
+ p.kee=#{key,jdbcType=VARCHAR}
and pb.kee=#{branch,jdbcType=VARCHAR}
- and (pb.branch_type='BRANCH')
+ and pb.branch_type='BRANCH'
</select>
- <select id="selectPrByKeyAndBranchKey" parameterType="String" resultType="Component">
+ <select id="selectByKeyAndPrKey" parameterType="String" resultType="Component">
select
<include refid="componentColumns"/>
from components p
- inner join project_branches pb on pb.uuid = p.project_uuid
+ inner join project_branches pb on pb.uuid = p.branch_uuid
where
- (p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
- and pb.kee=#{branch,jdbcType=VARCHAR}
+ p.kee=#{key,jdbcType=VARCHAR}
+ and pb.kee=#{pr,jdbcType=VARCHAR}
and pb.branch_type='PULL_REQUEST'
</select>
@@ -70,13 +71,13 @@
p.uuid=#{uuid,jdbcType=VARCHAR}
</select>
- <select id="selectByProjectUuid" parameterType="string" resultType="Component">
+ <select id="selectByBranchUuid" parameterType="string" resultType="Component">
select
<include refid="componentColumns"/>
from components root
- inner join components p on p.project_uuid=root.uuid
+ inner join components p on p.branch_uuid=root.uuid
where
- root.uuid=#{projectUuid,jdbcType=VARCHAR}
+ root.uuid=#{branchUuid,jdbcType=VARCHAR}
</select>
<select id="selectByKeys" parameterType="String" resultType="Component">
@@ -92,23 +93,11 @@
</foreach>
</select>
- <select id="selectByDbKeys" parameterType="String" resultType="Component">
- select
- <include refid="componentColumns"/>
- from components p
- where
- p.enabled=${_true}
- and p.kee in
- <foreach collection="dbKeys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </select>
-
<select id="selectByKeysAndBranch" parameterType="String" resultType="Component">
SELECT
<include refid="componentColumns"/>
FROM components p
- INNER JOIN project_branches pb on pb.uuid = p.project_uuid
+ INNER JOIN project_branches pb on pb.uuid = p.branch_uuid
<where>
p.enabled=${_true}
AND p.kee IN
@@ -165,7 +154,7 @@
<sql id="modulesTreeQuery">
INNER JOIN components module ON
- module.project_uuid = p.project_uuid
+ module.branch_uuid = p.branch_uuid
and module.uuid = #{moduleUuid}
and module.scope='PRJ' AND module.enabled = ${_true}
where
@@ -193,7 +182,7 @@
fs.revision
FROM components root
INNER JOIN components p on
- p.project_uuid=root.uuid
+ p.branch_uuid=root.uuid
and p.enabled=${_true}
and p.scope='FIL'
INNER JOIN file_sources fs ON
@@ -236,13 +225,13 @@
</foreach>
</select>
- <select id="countEnabledModulesByProjectUuid" resultType="int">
+ <select id="countEnabledModulesByBranchUuid" resultType="int">
select
count(1)
from components p
where
p.enabled=${_true}
- and p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
+ and p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
and p.qualifier = 'BRC'
</select>
@@ -388,7 +377,7 @@
<include refid="componentColumns"/>
from components p
where
- p.project_uuid = #{branchUuid,jdbcType=VARCHAR}
+ p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
and p.uuid_path in
<foreach collection="uuidPaths" item="uuidPath" open="(" close=")" separator=",">
#{uuidPath,jdbcType=VARCHAR}
@@ -407,7 +396,7 @@
</select>
<sql id="selectDescendantsJoins">
- inner join components base on base.project_uuid = p.project_uuid and base.uuid = #{baseUuid}
+ inner join components base on base.branch_uuid = p.branch_uuid and base.uuid = #{baseUuid}
<choose>
<when test="query.getStrategy().name() == 'CHILDREN'">
and p.uuid_path = #{baseUuidPath,jdbcType=VARCHAR}
@@ -441,8 +430,8 @@
</if>
</sql>
- <select id="selectUuidsForQualifiers" resultType="UuidWithProjectUuid">
- SELECT p.uuid as "uuid", p.project_uuid as "projectUuid" FROM components p
+ <select id="selectUuidsForQualifiers" resultType="UuidWithBranchUuid">
+ SELECT p.uuid as "uuid", p.branch_uuid as "branchUuid" FROM components p
where
<foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
p.qualifier=#{qualifier,jdbcType=VARCHAR}
@@ -461,7 +450,7 @@
<foreach collection="projectUuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
where
p.enabled = ${_true}
- and p.uuid = leaf.project_uuid
+ and p.uuid = leaf.branch_uuid
and p.scope = 'PRJ'
and p.qualifier in ('VW', 'APP')
</select>
@@ -470,7 +459,7 @@
from components p
where
p.enabled = ${_true}
- and p.project_uuid = #{projectViewUuid,jdbcType=VARCHAR}
+ and p.branch_uuid = #{projectViewUuid,jdbcType=VARCHAR}
<choose>
<when test="_databaseId == 'mssql'">
and p.module_uuid_path like #{viewUuidLikeQuery,jdbcType=VARCHAR} {escape '\'}
@@ -487,7 +476,7 @@
SELECT
<include refid="componentColumns"/>
FROM components p
- INNER JOIN components root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
+ INNER JOIN components root ON root.uuid=p.branch_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
<where>
<if test="excludeDisabled">
p.enabled = ${_true}
@@ -504,7 +493,7 @@
FROM
components p
INNER JOIN
- components root ON root.uuid=p.project_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
+ components root ON root.uuid=p.branch_uuid AND p.enabled = ${_true} AND root.kee=#{projectKey,jdbcType=VARCHAR}
</select>
<select id="selectUuidsByKeyFromProjectKey" parameterType="string" resultType="KeyWithUuid">
@@ -513,7 +502,7 @@
FROM
components p
INNER JOIN
- components root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
+ components root ON root.uuid=p.branch_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
</select>
<select id="scrollForIndexing" parameterType="map" resultType="Component" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
@@ -527,7 +516,7 @@
and p.scope = 'PRJ'
and p.qualifier in ('TRK','VW','SVW','APP')
<if test="projectUuid != null">
- and p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
+ and p.branch_uuid = #{projectUuid,jdbcType=VARCHAR}
</if>
</select>
@@ -541,7 +530,7 @@
inner join file_sources fs on
fs.file_uuid = p.uuid
where
- p.project_uuid = #{projectUuid,jdbcType=VARCHAR}
+ p.branch_uuid = #{branchUuid,jdbcType=VARCHAR}
and p.enabled = ${_true}
and p.scope = 'FIL'
and p.qualifier in ('FIL', 'UTS')
@@ -553,7 +542,7 @@
kee,
uuid,
uuid_path,
- project_uuid,
+ branch_uuid,
module_uuid,
module_uuid_path,
main_branch_project_uuid,
@@ -586,7 +575,7 @@
#{kee,jdbcType=VARCHAR},
#{uuid,jdbcType=VARCHAR},
#{uuidPath,jdbcType=VARCHAR},
- #{projectUuid,jdbcType=VARCHAR},
+ #{branchUuid,jdbcType=VARCHAR},
#{moduleUuid,jdbcType=VARCHAR},
#{moduleUuidPath,jdbcType=VARCHAR},
#{mainBranchProjectUuid, jdbcType=VARCHAR},
@@ -699,7 +688,7 @@
b_path = null,
b_qualifier = null
where
- project_uuid = #{projectUuid,jdbcType=VARCHAR} and
+ branch_uuid = #{branchUuid,jdbcType=VARCHAR} and
b_changed = ${_true}
</update>
@@ -709,7 +698,7 @@
<!-- Component key is normally immutable, but since 7.6 deprecated_kee is used as a b_kee to migrate component keys after the drop of modules -->
deprecated_kee = kee
where
- project_uuid = #{projectUuid,jdbcType=VARCHAR} and
+ branch_uuid = #{branchUuid,jdbcType=VARCHAR} and
b_changed = ${_true}
</update>
@@ -717,7 +706,7 @@
update components set
private = #{isPrivate,jdbcType=BOOLEAN}
where
- project_uuid = #{projectUuid,jdbcType=VARCHAR}
+ branch_uuid = #{branchUuid,jdbcType=VARCHAR}
and private &lt;&gt; #{isPrivate,jdbcType=BOOLEAN}
</update>
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
index 513386f1322..575645a72c6 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
@@ -38,7 +38,7 @@
<select id="selectLastSnapshotByComponentUuid" resultType="Snapshot">
select <include refid="snapshotColumns" />
from snapshots s
- inner join components p on s.component_uuid = p.project_uuid
+ inner join components p on s.component_uuid = p.branch_uuid
where
s.islast=${_true}
and p.uuid = #{componentUuid,jdbcType=VARCHAR}
@@ -47,10 +47,10 @@
<select id="selectLastAnalysisDateByProject" resultType="long">
select max(s.created_at)
from snapshots s
- inner join components p on s.component_uuid = p.project_uuid
+ inner join components p on s.component_uuid = p.branch_uuid
where
s.islast=${_true}
- and coalesce(p.main_branch_project_uuid, p.project_uuid) = #{projectUuid,jdbcType=VARCHAR}
+ and coalesce(p.main_branch_project_uuid, p.branch_uuid) = #{projectUuid,jdbcType=VARCHAR}
</select>
<select id="selectLastAnalysisDateByProjects" resultType="org.sonar.db.component.ProjectLastAnalysisDateDto">
@@ -65,7 +65,7 @@
from
snapshots s
inner join components c on
- s.component_uuid = c.project_uuid
+ s.component_uuid = c.branch_uuid
where
s.islast = ${_true}
and c.main_branch_project_uuid in
@@ -76,21 +76,21 @@
c.main_branch_project_uuid
union
select
- c.project_uuid as project_uuid,
+ c.branch_uuid as project_uuid,
max(s.created_at) as last_analysis_date
from
snapshots s
inner join components c on
- s.component_uuid = c.project_uuid
+ s.component_uuid = c.branch_uuid
where
s.islast = ${_true}
and c.main_branch_project_uuid is null
- and c.project_uuid in
+ and c.branch_uuid in
<foreach collection="projectUuids" item="projectUuid" separator="," open="(" close=")">
#{projectUuid,jdbcType=VARCHAR}
</foreach>
group by
- c.project_uuid
+ c.branch_uuid
) result_with_duplicates
group by
result_with_duplicates.project_uuid
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
index 20df7611c2b..db14d3c6646 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
@@ -69,7 +69,7 @@
components p
where
(
- p.project_uuid=#{rootUuid,jdbcType=VARCHAR}
+ p.branch_uuid=#{rootUuid,jdbcType=VARCHAR}
and p.scope = 'PRJ' and p.qualifier in ('SVW','BRC')
)
or (
@@ -85,7 +85,7 @@
inner join components p on
p.uuid = fs.file_uuid
and p.enabled = ${_false}
- and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+ and p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
</select>
<select id="selectDisabledComponentsWithUnresolvedIssues" parameterType="map" resultType="String">
@@ -95,7 +95,7 @@
inner join components p on
p.uuid = i.component_uuid
and p.enabled = ${_false}
- and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+ and p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
where
resolution is null
</select>
@@ -107,7 +107,7 @@
inner join components p on
p.uuid = lm.component_uuid
and p.enabled = ${_false}
- and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+ and p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
</select>
<delete id="deleteAnalysisMeasures" parameterType="map">
@@ -220,7 +220,7 @@
<delete id="deleteComponentsByProjectUuid" parameterType="map">
delete from components
where
- project_uuid = #{rootUuid,jdbcType=VARCHAR}
+ branch_uuid = #{rootUuid,jdbcType=VARCHAR}
</delete>
<delete id="deleteComponentsByMainBranchProjectUuid" parameterType="map">
@@ -322,7 +322,7 @@
components p
WHERE
p.enabled = ${_false}
- AND p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
+ AND p.branch_uuid=#{branchUuid,jdbcType=VARCHAR}
AND NOT EXISTS (SELECT 1 FROM issues i WHERE i.component_uuid = p.uuid)
</select>
diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl
index f161a202ff6..fae462a9976 100644
--- a/server/sonar-db-dao/src/schema/schema-sq.ddl
+++ b/server/sonar-db-dao/src/schema/schema-sq.ddl
@@ -215,7 +215,7 @@ CREATE TABLE "COMPONENTS"(
"COPY_COMPONENT_UUID" CHARACTER VARYING(50),
"PATH" CHARACTER VARYING(2000),
"UUID_PATH" CHARACTER VARYING(1500) NOT NULL,
- "PROJECT_UUID" CHARACTER VARYING(50) NOT NULL,
+ "BRANCH_UUID" CHARACTER VARYING(50) NOT NULL,
"MODULE_UUID" CHARACTER VARYING(50),
"MODULE_UUID_PATH" CHARACTER VARYING(1500),
"MAIN_BRANCH_PROJECT_UUID" CHARACTER VARYING(50),
@@ -233,13 +233,12 @@ CREATE TABLE "COMPONENTS"(
"B_MODULE_UUID_PATH" CHARACTER VARYING(1500),
"CREATED_AT" TIMESTAMP
);
-CREATE UNIQUE INDEX "PROJECTS_KEE" ON "COMPONENTS"("KEE" NULLS FIRST);
CREATE INDEX "PROJECTS_MODULE_UUID" ON "COMPONENTS"("MODULE_UUID" NULLS FIRST);
-CREATE INDEX "PROJECTS_PROJECT_UUID" ON "COMPONENTS"("PROJECT_UUID" NULLS FIRST);
CREATE INDEX "PROJECTS_QUALIFIER" ON "COMPONENTS"("QUALIFIER" NULLS FIRST);
CREATE INDEX "PROJECTS_ROOT_UUID" ON "COMPONENTS"("ROOT_UUID" NULLS FIRST);
CREATE INDEX "IDX_MAIN_BRANCH_PRJ_UUID" ON "COMPONENTS"("MAIN_BRANCH_PROJECT_UUID" NULLS FIRST);
CREATE UNIQUE INDEX "COMPONENTS_UUID" ON "COMPONENTS"("UUID" NULLS FIRST);
+CREATE INDEX "COMPONENTS_BRANCH_UUID" ON "COMPONENTS"("BRANCH_UUID" NULLS FIRST);
CREATE TABLE "DEFAULT_QPROFILES"(
"LANGUAGE" CHARACTER VARYING(20) NOT NULL,
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
index d760751fac2..2eb980d3913 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java
@@ -702,12 +702,12 @@ public class CeQueueDaoTest {
private void insertView(String view_uuid) {
ComponentDto view = new ComponentDto();
view.setQualifier("VW");
- view.setDbKey(view_uuid + "_key");
+ view.setKey(view_uuid + "_key");
view.setUuid(view_uuid);
view.setPrivate(false);
view.setRootUuid(view_uuid);
view.setUuidPath("uuid_path");
- view.setProjectUuid(view_uuid);
+ view.setBranchUuid(view_uuid);
db.components().insertPortfolioAndSnapshot(view);
db.commit();
}
@@ -715,12 +715,12 @@ public class CeQueueDaoTest {
private void insertBranch(String uuid) {
ComponentDto branch = new ComponentDto();
branch.setQualifier("TRK");
- branch.setDbKey(uuid + "_key");
+ branch.setKey(uuid + "_key");
branch.setUuid(uuid);
branch.setPrivate(false);
branch.setRootUuid(uuid);
branch.setUuidPath("uuid_path");
- branch.setProjectUuid(uuid);
+ branch.setBranchUuid(uuid);
db.components().insertComponent(branch);
db.commit();
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
index 7e016ddfe3a..7c8d24a49cc 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ApplicationProjectsDaoTest.java
@@ -79,9 +79,9 @@ public class ApplicationProjectsDaoTest {
@Test
public void select_project_branches_from_application_branch() {
- var project = db.components().insertPublicProjectDto(p -> p.setDbKey("project"));
+ var project = db.components().insertPublicProjectDto(p -> p.setKey("project"));
var projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("project-branch"));
- var app = db.components().insertPrivateApplicationDto(a -> a.setDbKey("app1"));
+ var app = db.components().insertPrivateApplicationDto(a -> a.setKey("app1"));
var appBranch = db.components().insertProjectBranch(app, b -> b.setKey("app-branch"));
db.components().addApplicationProject(app, project);
underTest.addProjectBranchToAppBranch(dbSession, app.getUuid(), appBranch.getUuid(), project.getUuid(), projectBranch.getUuid());
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
index e58113a3212..5de47d10d24 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
@@ -425,7 +425,7 @@ public class BranchDaoTest {
featureBranch.setMergeBranchUuid("U3");
underTest.insert(dbSession, featureBranch);
- ComponentDto component = new ComponentDto().setProjectUuid(mainBranch.getUuid());
+ ComponentDto component = new ComponentDto().setBranchUuid(mainBranch.getUuid());
// select the component
Collection<BranchDto> branches = underTest.selectByComponent(dbSession, component);
@@ -736,7 +736,7 @@ public class BranchDaoTest {
@Test
public void doAnyOfComponentsNeedIssueSync_test_more_than_1000() {
List<String> componentKeys = IntStream.range(0, 1100).mapToObj(value -> db.components().insertPrivateProject())
- .map(ComponentDto::getDbKey)
+ .map(ComponentDto::getKey)
.collect(Collectors.toList());
assertThat(underTest.doAnyOfComponentsNeedIssueSync(dbSession, componentKeys)).isFalse();
@@ -745,7 +745,7 @@ public class BranchDaoTest {
ProjectDto projectDto = db.components().getProjectDto(project);
db.components().insertProjectBranch(projectDto, b -> b.setBranchType(BranchType.BRANCH).setNeedIssueSync(true));
- componentKeys.add(project.getDbKey());
+ componentKeys.add(project.getKey());
assertThat(underTest.doAnyOfComponentsNeedIssueSync(dbSession, componentKeys)).isTrue();
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index 0996f6a56ff..8104002008b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -19,7 +19,6 @@
*/
package org.sonar.db.component;
-import com.google.common.collect.ImmutableMap;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
@@ -130,7 +129,7 @@ public class ComponentDaoTest {
@Test
public void get_by_uuid() {
ComponentDto project = db.components().insertPrivateProject(p -> p
- .setDbKey("org.struts:struts")
+ .setKey("org.struts:struts")
.setName("Struts")
.setLongName("Apache Struts"));
ComponentDto anotherProject = db.components().insertPrivateProject();
@@ -141,8 +140,8 @@ public class ComponentDaoTest {
assertThat(result.getUuidPath()).isEqualTo(".");
assertThat(result.moduleUuid()).isNull();
assertThat(result.moduleUuidPath()).isEqualTo("." + project.uuid() + ".");
- assertThat(result.projectUuid()).isEqualTo(project.uuid());
- assertThat(result.getDbKey()).isEqualTo("org.struts:struts");
+ assertThat(result.branchUuid()).isEqualTo(project.uuid());
+ assertThat(result.getKey()).isEqualTo("org.struts:struts");
assertThat(result.path()).isNull();
assertThat(result.name()).isEqualTo("Struts");
assertThat(result.longName()).isEqualTo("Apache Struts");
@@ -159,7 +158,7 @@ public class ComponentDaoTest {
public void get_by_uuid_on_technical_project_copy() {
ComponentDto view = db.components().insertPublicPortfolio();
ComponentDto project = db.components().insertPublicProject(p -> p
- .setDbKey("org.struts:struts")
+ .setKey("org.struts:struts")
.setName("Struts")
.setLongName("Apache Struts"));
ComponentDto projectCopy = db.components().insertComponent(newProjectCopy(project, view));
@@ -170,8 +169,8 @@ public class ComponentDaoTest {
assertThat(result.uuid()).isEqualTo(projectCopy.uuid());
assertThat(result.moduleUuid()).isEqualTo(view.uuid());
assertThat(result.moduleUuidPath()).isEqualTo("." + view.uuid() + ".");
- assertThat(result.projectUuid()).isEqualTo(view.uuid());
- assertThat(result.getDbKey()).isEqualTo(view.getDbKey() + project.getDbKey());
+ assertThat(result.branchUuid()).isEqualTo(view.uuid());
+ assertThat(result.getKey()).isEqualTo(view.getKey() + project.getKey());
assertThat(result.path()).isNull();
assertThat(result.name()).isEqualTo("Struts");
assertThat(result.longName()).isEqualTo("Apache Struts");
@@ -205,24 +204,24 @@ public class ComponentDaoTest {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto directory = db.components().insertComponent(newDirectory(project, "src"));
ComponentDto file = db.components().insertComponent(newFileDto(project, directory)
- .setDbKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+ .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
.setName("RequestContext.java")
.setLongName("org.struts.RequestContext")
.setLanguage("java")
.setPath("src/RequestContext.java"));
- Optional<ComponentDto> optional = underTest.selectByKey(dbSession, file.getDbKey());
+ Optional<ComponentDto> optional = underTest.selectByKey(dbSession, file.getKey());
ComponentDto result = optional.get();
assertThat(result.uuid()).isEqualTo(file.uuid());
- assertThat(result.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(result.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(result.path()).isEqualTo("src/RequestContext.java");
assertThat(result.name()).isEqualTo("RequestContext.java");
assertThat(result.longName()).isEqualTo("org.struts.RequestContext");
assertThat(result.qualifier()).isEqualTo("FIL");
assertThat(result.scope()).isEqualTo("FIL");
assertThat(result.language()).isEqualTo("java");
- assertThat(result.projectUuid()).isEqualTo(project.uuid());
+ assertThat(result.branchUuid()).isEqualTo(project.uuid());
assertThat(underTest.selectByKey(dbSession, "unknown")).isEmpty();
}
@@ -250,9 +249,7 @@ public class ComponentDaoTest {
ComponentDto file = db.components().insertComponent(newFileDto(pullRequest));
assertThat(underTest.selectByKeyAndPullRequest(dbSession, project.getKey(), "my_PR").get().uuid()).isEqualTo(pullRequest.uuid());
- assertThat(underTest.selectByKeyAndBranch(dbSession, project.getKey(), "master").get().uuid()).isEqualTo(project.uuid());
assertThat(underTest.selectByKeyAndPullRequest(dbSession, project.getKey(), "master").get().uuid()).isEqualTo(pullRequestNamedAsMainBranch.uuid());
- assertThat(underTest.selectByKeyAndBranch(dbSession, branch.getKey(), "my_branch").get().uuid()).isEqualTo(branch.uuid());
assertThat(underTest.selectByKeyAndPullRequest(dbSession, branch.getKey(), "my_branch").get().uuid()).isEqualTo(pullRequestNamedAsBranch.uuid());
assertThat(underTest.selectByKeyAndPullRequest(dbSession, file.getKey(), "my_PR").get().uuid()).isEqualTo(file.uuid());
assertThat(underTest.selectByKeyAndPullRequest(dbSession, "unknown", "my_branch")).isNotPresent();
@@ -271,7 +268,7 @@ public class ComponentDaoTest {
public void get_by_key_on_disabled_component() {
ComponentDto project = db.components().insertPrivateProject(p -> p.setEnabled(false));
- ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getDbKey());
+ ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getKey());
assertThat(result.isEnabled()).isFalse();
}
@@ -280,13 +277,13 @@ public class ComponentDaoTest {
public void get_by_key_on_a_root_project() {
ComponentDto project = db.components().insertPrivateProject();
- ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getDbKey());
+ ComponentDto result = underTest.selectOrFailByKey(dbSession, project.getKey());
- assertThat(result.getDbKey()).isEqualTo(project.getDbKey());
+ assertThat(result.getKey()).isEqualTo(project.getKey());
assertThat(result.uuid()).isEqualTo(project.uuid());
assertThat(result.getUuidPath()).isEqualTo(project.getUuidPath());
assertThat(result.getRootUuid()).isEqualTo(project.uuid());
- assertThat(result.projectUuid()).isEqualTo(project.uuid());
+ assertThat(result.branchUuid()).isEqualTo(project.uuid());
}
@Test
@@ -294,13 +291,13 @@ public class ComponentDaoTest {
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
- List<ComponentDto> results = underTest.selectByKeys(dbSession, asList(project1.getDbKey(), project2.getDbKey()));
+ List<ComponentDto> results = underTest.selectByKeys(dbSession, asList(project1.getKey(), project2.getKey()));
assertThat(results)
- .extracting(ComponentDto::uuid, ComponentDto::getDbKey)
+ .extracting(ComponentDto::uuid, ComponentDto::getKey)
.containsExactlyInAnyOrder(
- tuple(project1.uuid(), project1.getDbKey()),
- tuple(project2.uuid(), project2.getDbKey()));
+ tuple(project1.uuid(), project1.getKey()),
+ tuple(project2.uuid(), project2.getKey()));
assertThat(underTest.selectByKeys(dbSession, singletonList("unknown"))).isEmpty();
}
@@ -321,29 +318,7 @@ public class ComponentDaoTest {
assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(fileOnAnotherBranch.getKey()), "my_branch")).isEmpty();
assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(file1.getKey()), "unknown")).isEmpty();
assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList("unknown"), "my_branch")).isEmpty();
- assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(branch.getKey()), "master")).extracting(ComponentDto::uuid).containsExactlyInAnyOrder(project.uuid());
- }
-
- @Test
- public void select_by_keys_and_branches() {
- ComponentDto project = db.components().insertPublicProject();
- ComponentDto projectBranch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
- ComponentDto application = db.components().insertPublicProject(a -> a.setQualifier(APP));
- ComponentDto applicationBranch = db.components().insertProjectBranch(application, b -> b.setKey("my_branch"));
-
- assertThat(underTest.selectByKeysAndBranches(db.getSession(), ImmutableMap.of(
- projectBranch.getKey(), projectBranch.getBranch(),
- applicationBranch.getKey(), applicationBranch.getBranch())))
- .extracting(ComponentDto::getKey, ComponentDto::getBranch)
- .containsExactlyInAnyOrder(
- tuple(projectBranch.getKey(), "my_branch"),
- tuple(applicationBranch.getKey(), "my_branch"));
- assertThat(underTest.selectByKeysAndBranches(db.getSession(), ImmutableMap.of(
- projectBranch.getKey(), "unknown",
- "unknown", projectBranch.getBranch())))
- .extracting(ComponentDto::getDbKey)
- .isEmpty();
- assertThat(underTest.selectByKeysAndBranches(db.getSession(), Collections.emptyMap())).isEmpty();
+ assertThat(underTest.selectByKeysAndBranch(dbSession, singletonList(branch.getKey()), "my_branch")).extracting(ComponentDto::uuid).containsExactlyInAnyOrder(branch.uuid());
}
@Test
@@ -354,10 +329,10 @@ public class ComponentDaoTest {
List<ComponentDto> results = underTest.selectByUuids(dbSession, asList(project1.uuid(), project2.uuid()));
assertThat(results)
- .extracting(ComponentDto::uuid, ComponentDto::getDbKey)
+ .extracting(ComponentDto::uuid, ComponentDto::getKey)
.containsExactlyInAnyOrder(
- tuple(project1.uuid(), project1.getDbKey()),
- tuple(project2.uuid(), project2.getDbKey()));
+ tuple(project1.uuid(), project1.getKey()),
+ tuple(project2.uuid(), project2.getKey()));
assertThat(underTest.selectByUuids(dbSession, singletonList("unknown"))).isEmpty();
}
@@ -370,10 +345,10 @@ public class ComponentDaoTest {
List<ComponentDto> results = underTest.selectByUuids(dbSession, asList(project1.uuid(), project2.uuid()));
assertThat(results)
- .extracting(ComponentDto::getDbKey, ComponentDto::isEnabled)
+ .extracting(ComponentDto::getKey, ComponentDto::isEnabled)
.containsExactlyInAnyOrder(
- tuple(project1.getDbKey(), true),
- tuple(project2.getDbKey(), false));
+ tuple(project1.getKey(), true),
+ tuple(project2.getKey(), false));
}
@Test
@@ -393,10 +368,10 @@ public class ComponentDaoTest {
ComponentDto directory = db.components().insertComponent(newDirectory(module, "src"));
ComponentDto file = db.components().insertComponent(newFileDto(directory));
- assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("TRK"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(project.getDbKey());
- assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("BRC"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(module.getDbKey());
- assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("DIR"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(directory.getDbKey());
- assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("FIL"))).extracting(ComponentDto::getDbKey).containsExactlyInAnyOrder(file.getDbKey());
+ assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("TRK"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(project.getKey());
+ assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("BRC"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(module.getKey());
+ assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("DIR"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(directory.getKey());
+ assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("FIL"))).extracting(ComponentDto::getKey).containsExactlyInAnyOrder(file.getKey());
assertThat(underTest.selectComponentsByQualifiers(dbSession, newHashSet("unknown"))).isEmpty();
}
@@ -417,7 +392,7 @@ public class ComponentDaoTest {
subModule2.setEnabled(false);
db.components().insertComponent(subModule2);
- int result = underTest.countEnabledModulesByProjectUuid(dbSession, project.uuid());
+ int result = underTest.countEnabledModulesByBranchUuid(dbSession, project.uuid());
assertThat(result).isEqualTo(2);
}
@@ -437,8 +412,8 @@ public class ComponentDaoTest {
// Sub project of a file
assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(file.uuid())))
- .extracting(ComponentDto::getDbKey)
- .containsExactlyInAnyOrder(subModule.getDbKey());
+ .extracting(ComponentDto::getKey)
+ .containsExactlyInAnyOrder(subModule.getKey());
// Sub project of a directory
assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, singletonList(directory.uuid())))
@@ -518,7 +493,7 @@ public class ComponentDaoTest {
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
// From root project
- assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getDbKey()))
+ assertThat(underTest.selectEnabledComponentsWithModuleUuidFromProjectKey(dbSession, project.getKey()))
.extracting(ComponentWithModuleUuidDto::uuid)
.containsExactlyInAnyOrder(
project.uuid(),
@@ -636,10 +611,10 @@ public class ComponentDaoTest {
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
// Removed components are included
- assertThat(underTest.selectAllComponentsFromProjectKey(dbSession, project.getDbKey()))
- .extracting(ComponentDto::getDbKey)
- .containsExactlyInAnyOrder(project.getDbKey(), module.getDbKey(), removedModule.getDbKey(), subModule.getDbKey(), removedSubModule.getDbKey(),
- directory.getDbKey(), removedDirectory.getDbKey(), file.getDbKey(), removedFile.getDbKey());
+ assertThat(underTest.selectAllComponentsFromProjectKey(dbSession, project.getKey()))
+ .extracting(ComponentDto::getKey)
+ .containsExactlyInAnyOrder(project.getKey(), module.getKey(), removedModule.getKey(), subModule.getKey(), removedSubModule.getKey(),
+ directory.getKey(), removedDirectory.getKey(), file.getKey(), removedFile.getKey());
assertThat(underTest.selectAllComponentsFromProjectKey(dbSession, "UNKNOWN")).isEmpty();
}
@@ -657,19 +632,19 @@ public class ComponentDaoTest {
ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
- Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKey(dbSession, project.getDbKey())
+ Map<String, String> uuidsByKey = underTest.selectUuidsByKeyFromProjectKey(dbSession, project.getKey())
.stream().collect(Collectors.toMap(KeyWithUuidDto::key, KeyWithUuidDto::uuid));
assertThat(uuidsByKey).containsOnly(
- entry(project.getDbKey(), project.uuid()),
- entry(module.getDbKey(), module.uuid()),
- entry(removedModule.getDbKey(), removedModule.uuid()),
- entry(subModule.getDbKey(), subModule.uuid()),
- entry(removedSubModule.getDbKey(), removedSubModule.uuid()),
- entry(directory.getDbKey(), directory.uuid()),
- entry(removedDirectory.getDbKey(), removedDirectory.uuid()),
- entry(file.getDbKey(), file.uuid()),
- entry(removedFile.getDbKey(), removedFile.uuid()));
+ entry(project.getKey(), project.uuid()),
+ entry(module.getKey(), module.uuid()),
+ entry(removedModule.getKey(), removedModule.uuid()),
+ entry(subModule.getKey(), subModule.uuid()),
+ entry(removedSubModule.getKey(), removedSubModule.uuid()),
+ entry(directory.getKey(), directory.uuid()),
+ entry(removedDirectory.getKey(), removedDirectory.uuid()),
+ entry(file.getKey(), file.uuid()),
+ entry(removedFile.getKey(), removedFile.uuid()));
}
@Test
@@ -686,9 +661,9 @@ public class ComponentDaoTest {
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
// Removed modules are not included
- assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getDbKey()))
- .extracting(ComponentDto::getDbKey)
- .containsExactlyInAnyOrder(project.getDbKey(), module.getDbKey(), subModule.getDbKey());
+ assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, project.getKey()))
+ .extracting(ComponentDto::getKey)
+ .containsExactlyInAnyOrder(project.getKey(), module.getKey(), subModule.getKey());
assertThat(underTest.selectEnabledModulesFromProjectKey(dbSession, "UNKNOWN")).isEmpty();
}
@@ -704,10 +679,10 @@ public class ComponentDaoTest {
db.components().insertSubView(view, dto -> dto.setUuid("FGHI"));
ComponentDto application = db.components().insertPublicApplication();
- assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithProjectUuidDto::getUuid)
+ assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithBranchUuidDto::getUuid)
.containsExactlyInAnyOrder("ABCD", "EFGH", "FGHI", "IJKL", application.uuid());
- assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithProjectUuidDto::getProjectUuid)
- .containsExactlyInAnyOrder("ABCD", "EFGH", "EFGH", "IJKL", application.projectUuid());
+ assertThat(underTest.selectAllViewsAndSubViews(dbSession)).extracting(UuidWithBranchUuidDto::getBranchUuid)
+ .containsExactlyInAnyOrder("ABCD", "EFGH", "EFGH", "IJKL", application.branchUuid());
}
@Test
@@ -743,7 +718,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
- assertThat(keys).containsOnly(view.getDbKey());
+ assertThat(keys).containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
.isEqualTo(keys);
@@ -762,25 +737,25 @@ public class ComponentDaoTest {
insertProjectCopy(view2, project3);
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project1.uuid())))
- .containsOnly(view.getDbKey());
+ .containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid())))
- .containsOnly(view.getDbKey());
+ .containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid())))
- .containsOnly(view.getDbKey());
+ .containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
- .containsOnly(view.getDbKey());
+ .containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project3.uuid())))
- .containsOnly(view2.getDbKey());
+ .containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project3.uuid())))
- .containsOnly(view2.getDbKey());
+ .containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project2.uuid(), project1.uuid())))
- .containsOnly(view.getDbKey());
+ .containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid(), project1.uuid())))
- .containsOnly(view.getDbKey());
+ .containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project1.uuid(), project3.uuid())))
- .containsOnly(view.getDbKey(), view2.getDbKey());
+ .containsOnly(view.getKey(), view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid(), project3.uuid())))
- .containsOnly(view.getDbKey(), view2.getDbKey());
+ .containsOnly(view.getKey(), view2.getKey());
}
@Test
@@ -795,7 +770,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid()));
- assertThat(keys).containsOnly(view2.getDbKey());
+ assertThat(keys).containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
.isEqualTo(keys);
@@ -812,7 +787,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
- assertThat(keys).containsOnly(view1.getDbKey());
+ assertThat(keys).containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
.isEqualTo(keys);
@@ -829,7 +804,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
- assertThat(keys).containsOnly(view2.getDbKey());
+ assertThat(keys).containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
.isEqualTo(keys);
@@ -845,7 +820,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
- assertThat(keys).containsOnly(view.getDbKey());
+ assertThat(keys).containsOnly(view.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
.isEqualTo(keys);
@@ -866,25 +841,25 @@ public class ComponentDaoTest {
insertProjectCopy(lowestSubview2, project3);
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project1.uuid())))
- .containsOnly(view1.getDbKey());
+ .containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid())))
- .containsOnly(view1.getDbKey());
+ .containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid())))
- .containsOnly(view1.getDbKey());
+ .containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
- .containsOnly(view1.getDbKey());
+ .containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project3.uuid())))
- .containsOnly(view2.getDbKey());
+ .containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project3.uuid())))
- .containsOnly(view2.getDbKey());
+ .containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project2.uuid(), project1.uuid())))
- .containsOnly(view1.getDbKey());
+ .containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid(), project1.uuid())))
- .containsOnly(view1.getDbKey());
+ .containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, of(project1.uuid(), project3.uuid())))
- .containsOnly(view1.getDbKey(), view2.getDbKey());
+ .containsOnly(view1.getKey(), view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project1.uuid(), project3.uuid())))
- .containsOnly(view1.getDbKey(), view2.getDbKey());
+ .containsOnly(view1.getKey(), view2.getKey());
}
@Test
@@ -901,7 +876,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project2.uuid()));
- assertThat(keys).containsOnly(view2.getDbKey());
+ assertThat(keys).containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project2.uuid())))
.isEqualTo(keys);
@@ -920,7 +895,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
- assertThat(keys).containsOnly(view1.getDbKey());
+ assertThat(keys).containsOnly(view1.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
.isEqualTo(keys);
@@ -939,7 +914,7 @@ public class ComponentDaoTest {
Set<String> keys = underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, singleton(project.uuid()));
- assertThat(keys).containsOnly(view2.getDbKey());
+ assertThat(keys).containsOnly(view2.getKey());
assertThat(underTest.selectViewKeysWithEnabledCopyOfProject(dbSession, shuffleWithNonExistentUuids(project.uuid())))
.isEqualTo(keys);
@@ -1050,7 +1025,7 @@ public class ComponentDaoTest {
@Test
public void selectByQuery_provisioned() {
ComponentDto provisionedProject = db.components()
- .insertPrivateProject(p -> p.setDbKey("provisioned.project").setName("Provisioned Project"));
+ .insertPrivateProject(p -> p.setKey("provisioned.project").setName("Provisioned Project"));
ComponentDto provisionedPortfolio = db.components().insertPrivatePortfolio();
SnapshotDto analyzedProject = db.components().insertProjectAndSnapshot(newPrivateProjectDto());
@@ -1076,7 +1051,7 @@ public class ComponentDaoTest {
.containsOnly(provisionedProject.uuid(), provisionedPortfolio.uuid());
// match key
- assertThat(underTest.selectByQuery(dbSession, query.get().setNameOrKeyQuery(provisionedProject.getDbKey()).build(), 0, 10))
+ assertThat(underTest.selectByQuery(dbSession, query.get().setNameOrKeyQuery(provisionedProject.getKey()).build(), 0, 10))
.extracting(ComponentDto::uuid)
.containsExactly(provisionedProject.uuid());
assertThat(underTest.selectByQuery(dbSession, query.get().setNameOrKeyQuery("pROvisiONed.proJEcT").setPartialMatchOnKey(true).build(), 0, 10))
@@ -1188,7 +1163,7 @@ public class ComponentDaoTest {
ComponentDto file = db.components().insertComponent(newFileDto(subModule, directory));
ComponentDto removedFile = db.components().insertComponent(newFileDto(subModule, directory).setEnabled(false));
- assertThat(underTest.selectByProjectUuid(project.uuid(), dbSession))
+ assertThat(underTest.selectByBranchUuid(project.uuid(), dbSession))
.extracting(ComponentDto::uuid)
.containsExactlyInAnyOrder(project.uuid(), module.uuid(), removedModule.uuid(), subModule.uuid(), removedSubModule.uuid(), directory.uuid(), removedDirectory.uuid(),
file.uuid(),
@@ -1294,7 +1269,7 @@ public class ComponentDaoTest {
Map<String, Object> row1 = selectBColumnsForUuid("U1");
assertThat(row1.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
assertThat(row1)
- .containsEntry("bKey", dto1.getDbKey())
+ .containsEntry("bKey", dto1.getKey())
.containsEntry("bCopyComponentUuid", dto1.getCopyComponentUuid())
.containsEntry("bDescription", dto1.description());
assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
@@ -1311,7 +1286,7 @@ public class ComponentDaoTest {
Map<String, Object> row2 = selectBColumnsForUuid("U2");
assertThat(row2.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
assertThat(row2)
- .containsEntry("bKey", dto2.getDbKey())
+ .containsEntry("bKey", dto2.getKey())
.containsEntry("bCopyComponentUuid", dto2.getCopyComponentUuid())
.containsEntry("bDescription", dto2.description());
assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
@@ -1412,19 +1387,19 @@ public class ComponentDaoTest {
@Test
public void selectByQuery_key_with_special_characters() {
- db.components().insertProjectAndSnapshot(newPrivateProjectDto().setDbKey("project-_%-key"));
- db.components().insertProjectAndSnapshot(newPrivateProjectDto().setDbKey("project-key-that-does-not-match"));
+ db.components().insertProjectAndSnapshot(newPrivateProjectDto().setKey("project-_%-key"));
+ db.components().insertProjectAndSnapshot(newPrivateProjectDto().setKey("project-key-that-does-not-match"));
ComponentQuery query = ComponentQuery.builder().setNameOrKeyQuery("project-_%-key").setQualifiers(PROJECT).build();
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
assertThat(result).hasSize(1);
- assertThat(result.get(0).getDbKey()).isEqualTo("project-_%-key");
+ assertThat(result.get(0).getKey()).isEqualTo("project-_%-key");
}
@Test
public void selectByQuery_on_key_partial_match_case_insensitive() {
- db.components().insertProjectAndSnapshot(newPrivateProjectDto().setDbKey("project-key"));
+ db.components().insertProjectAndSnapshot(newPrivateProjectDto().setKey("project-key"));
ComponentQuery query = ComponentQuery.builder()
.setNameOrKeyQuery("JECT-K")
@@ -1433,7 +1408,7 @@ public class ComponentDaoTest {
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
assertThat(result).hasSize(1);
- assertThat(result.get(0).getDbKey()).isEqualTo("project-key");
+ assertThat(result.get(0).getKey()).isEqualTo("project-key");
}
@Test
@@ -1579,16 +1554,16 @@ public class ComponentDaoTest {
@Test
public void selectByQuery_filter_on_visibility() {
- db.components().insertComponent(newPrivateProjectDto().setDbKey("private-key"));
- db.components().insertComponent(ComponentTesting.newPublicProjectDto().setDbKey("public-key"));
+ db.components().insertComponent(newPrivateProjectDto().setKey("private-key"));
+ db.components().insertComponent(ComponentTesting.newPublicProjectDto().setKey("public-key"));
ComponentQuery privateProjectsQuery = ComponentQuery.builder().setPrivate(true).setQualifiers(PROJECT).build();
ComponentQuery publicProjectsQuery = ComponentQuery.builder().setPrivate(false).setQualifiers(PROJECT).build();
ComponentQuery allProjectsQuery = ComponentQuery.builder().setPrivate(null).setQualifiers(PROJECT).build();
- assertThat(underTest.selectByQuery(dbSession, privateProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsExactly("private-key");
- assertThat(underTest.selectByQuery(dbSession, publicProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsExactly("public-key");
- assertThat(underTest.selectByQuery(dbSession, allProjectsQuery, 0, 10)).extracting(ComponentDto::getDbKey).containsOnly("public-key", "private-key");
+ assertThat(underTest.selectByQuery(dbSession, privateProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsExactly("private-key");
+ assertThat(underTest.selectByQuery(dbSession, publicProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsExactly("public-key");
+ assertThat(underTest.selectByQuery(dbSession, allProjectsQuery, 0, 10)).extracting(ComponentDto::getKey).containsOnly("public-key", "private-key");
}
@Test
@@ -1609,13 +1584,13 @@ public class ComponentDaoTest {
ComponentDto jdk8 = db.components().insertComponent(newPrivateProjectDto());
ComponentDto cLang = db.components().insertComponent(newPrivateProjectDto());
ComponentQuery query = ComponentQuery.builder().setQualifiers(PROJECT)
- .setComponentKeys(newHashSet(sonarqube.getDbKey(), jdk8.getDbKey())).build();
+ .setComponentKeys(newHashSet(sonarqube.getKey(), jdk8.getKey())).build();
List<ComponentDto> result = underTest.selectByQuery(dbSession, query, 0, 10);
- assertThat(result).hasSize(2).extracting(ComponentDto::getDbKey)
- .containsExactlyInAnyOrder(sonarqube.getDbKey(), jdk8.getDbKey())
- .doesNotContain(cLang.getDbKey());
+ assertThat(result).hasSize(2).extracting(ComponentDto::getKey)
+ .containsExactlyInAnyOrder(sonarqube.getKey(), jdk8.getKey())
+ .doesNotContain(cLang.getKey());
}
@Test
@@ -1675,11 +1650,11 @@ public class ComponentDaoTest {
db.components().insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
db.components().insertComponent(module);
- ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One");
+ ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setKey("file-key-1").setName("File One");
db.components().insertComponent(fileInProject);
- ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two");
+ ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
db.components().insertComponent(file1InModule);
- ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three");
+ ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
db.components().insertComponent(file2InModule);
db.commit();
@@ -1703,11 +1678,11 @@ public class ComponentDaoTest {
db.components().insertProjectAndSnapshot(project);
ComponentDto module = newModuleDto(MODULE_UUID, project);
db.components().insertComponent(module);
- ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setDbKey("file-key-1").setName("File One");
+ ComponentDto fileInProject = newFileDto(project, null, FILE_1_UUID).setKey("file-key-1").setName("File One");
db.components().insertComponent(fileInProject);
- ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setDbKey("file-key-2").setName("File Two");
+ ComponentDto file1InModule = newFileDto(module, null, FILE_2_UUID).setKey("file-key-2").setName("File Two");
db.components().insertComponent(file1InModule);
- ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setDbKey("file-key-3").setName("File Three");
+ ComponentDto file2InModule = newFileDto(module, null, FILE_3_UUID).setKey("file-key-3").setName("File Three");
db.components().insertComponent(file2InModule);
db.commit();
@@ -1818,11 +1793,11 @@ public class ComponentDaoTest {
String uuid2 = "uuid2";
String[] uuids = {
- db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid1).setPrivate(true)).uuid(),
- db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid1).setPrivate(false)).uuid(),
- db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid2).setPrivate(true)).uuid(),
- db.components().insertComponent(newPrivateProjectDto().setProjectUuid(uuid2).setPrivate(false)).uuid(),
- db.components().insertComponent(newPrivateProjectDto().setRootUuid(uuid1).setProjectUuid("foo").setPrivate(false)).uuid(),
+ db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid1).setPrivate(true)).uuid(),
+ db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid1).setPrivate(false)).uuid(),
+ db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(true)).uuid(),
+ db.components().insertComponent(newPrivateProjectDto().setBranchUuid(uuid2).setPrivate(false)).uuid(),
+ db.components().insertComponent(newPrivateProjectDto().setRootUuid(uuid1).setBranchUuid("foo").setPrivate(false)).uuid(),
};
underTest.setPrivateForRootComponentUuidWithoutAudit(db.getSession(), uuid1, true);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java
index b59c8dee9e1..061dbac8515 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java
@@ -30,7 +30,7 @@ public class ComponentDtoTest {
@Test
public void setters_and_getters() {
ComponentDto componentDto = new ComponentDto()
- .setDbKey("org.struts:struts-core:src/org/struts/RequestContext.java")
+ .setKey("org.struts:struts-core:src/org/struts/RequestContext.java")
.setName("RequestContext.java")
.setLongName("org.struts.RequestContext")
.setQualifier("FIL")
@@ -41,7 +41,7 @@ public class ComponentDtoTest {
.setCopyComponentUuid("uuid_5")
.setRootUuid("uuid_3");
- assertThat(componentDto.getDbKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
+ assertThat(componentDto.getKey()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java");
assertThat(componentDto.getBranch()).isNull();
assertThat(componentDto.name()).isEqualTo("RequestContext.java");
assertThat(componentDto.longName()).isEqualTo("org.struts.RequestContext");
@@ -109,26 +109,4 @@ public class ComponentDtoTest {
ComponentDto nonRoot = new ComponentDto().setUuidPath(".12.34.56.");
assertThat(nonRoot.getUuidPathAsList()).containsExactly("12", "34", "56");
}
-
- @Test
- public void getKey_and_getBranch() {
- ComponentDto underTest = new ComponentDto().setDbKey("my_key:BRANCH:my_branch");
- assertThat(underTest.getKey()).isEqualTo("my_key");
- assertThat(underTest.getBranch()).isEqualTo("my_branch");
-
- underTest = new ComponentDto().setDbKey("my_key");
- assertThat(underTest.getKey()).isEqualTo("my_key");
- assertThat(underTest.getBranch()).isNull();
- }
-
- @Test
- public void getKey_and_getPullRequest() {
- ComponentDto underTest = new ComponentDto().setDbKey("my_key:PULL_REQUEST:pr-123");
- assertThat(underTest.getKey()).isEqualTo("my_key");
- assertThat(underTest.getPullRequest()).isEqualTo("pr-123");
-
- underTest = new ComponentDto().setDbKey("my_key");
- assertThat(underTest.getKey()).isEqualTo("my_key");
- assertThat(underTest.getPullRequest()).isNull();
- }
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
index 585f9708ddb..e77ed5dd4e9 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java
@@ -52,8 +52,7 @@ import static org.sonar.db.component.ComponentTesting.newModuleDto;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
public class ComponentKeyUpdaterDaoTest {
-
-
+
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
private AuditPersister auditPersister = mock(AuditPersister.class);
@@ -86,13 +85,13 @@ public class ComponentKeyUpdaterDaoTest {
public void updateKey_updates_disabled_components() {
ComponentDto project = db.components().insertComponent(
newPrivateProjectDto("A")
- .setDbKey("my_project"));
+ .setKey("my_project"));
ComponentDto directory = db.components().insertComponent(
newDirectory(project, "B")
- .setDbKey("my_project:directory"));
- db.components().insertComponent(newFileDto(project, directory).setDbKey("my_project:directory/file"));
- ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setDbKey("my_project:inactive_directory").setEnabled(false));
- db.components().insertComponent(newFileDto(project, inactiveDirectory).setDbKey("my_project:inactive_directory/file").setEnabled(false));
+ .setKey("my_project:directory"));
+ db.components().insertComponent(newFileDto(project, directory).setKey("my_project:directory/file"));
+ ComponentDto inactiveDirectory = db.components().insertComponent(newDirectory(project, "/inactive_directory").setKey("my_project:inactive_directory").setEnabled(false));
+ db.components().insertComponent(newFileDto(project, inactiveDirectory).setKey("my_project:inactive_directory/file").setEnabled(false));
underTest.updateKey(dbSession, "A", "your_project");
dbSession.commit();
@@ -100,7 +99,7 @@ public class ComponentKeyUpdaterDaoTest {
List<ComponentDto> result = dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, "your_project");
assertThat(result)
.hasSize(5)
- .extracting(ComponentDto::getDbKey)
+ .extracting(ComponentDto::getKey)
.containsOnlyOnce("your_project", "your_project:directory", "your_project:directory/file", "your_project:inactive_directory", "your_project:inactive_directory/file");
}
@@ -109,20 +108,20 @@ public class ComponentKeyUpdaterDaoTest {
ComponentDto app = db.components().insertPublicProject();
ComponentDto appBranch = db.components().insertProjectBranch(app);
ComponentDto appBranchProj1 = appBranch.copy()
- .setDbKey(appBranch.getDbKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj1:BRANCH:1").setUuid("appBranchProj1").setScope(Qualifiers.FILE);
+ .setKey(appBranch.getKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj1").setUuid("appBranchProj1").setScope(Qualifiers.FILE);
ComponentDto appBranchProj2 = appBranch.copy()
- .setDbKey(appBranch.getDbKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj2:BRANCH:2").setUuid("appBranchProj2").setScope(Qualifiers.FILE);
+ .setKey(appBranch.getKey().replace(BRANCH_KEY_SEPARATOR, "") + "appBranchProj2").setUuid("appBranchProj2").setScope(Qualifiers.FILE);
db.components().insertComponent(appBranchProj1);
db.components().insertComponent(appBranchProj2);
int branchComponentCount = 3;
- String oldBranchKey = appBranch.getDbKey();
+ String oldBranchKey = appBranch.getKey();
assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
String newBranchName = "newKey";
- String newAppBranchKey = ComponentDto.generateBranchKey(app.getDbKey(), newBranchName);
- String newAppBranchFragment = app.getDbKey() + newBranchName;
- underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getDbKey(), newBranchName);
+ String newAppBranchKey = ComponentDto.generateBranchKey(app.getKey(), newBranchName);
+ String newAppBranchFragment = app.getKey() + newBranchName;
+ underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getKey(), newBranchName);
assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).isEmpty();
@@ -140,9 +139,9 @@ public class ComponentKeyUpdaterDaoTest {
ComponentDto appBranch = db.components().insertProjectBranch(app);
db.components().insertProjectBranch(app, b -> b.setKey("newName"));
- assertThatThrownBy(() -> underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getDbKey(), "newName"))
+ assertThatThrownBy(() -> underTest.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getKey(), "newName"))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage(String.format("Impossible to update key: a component with key \"%s\" already exists.", generateBranchKey(app.getDbKey(), "newName")));
+ .hasMessage(String.format("Impossible to update key: a component with key \"%s\" already exists.", generateBranchKey(app.getKey(), "newName")));
}
@Test
@@ -151,7 +150,7 @@ public class ComponentKeyUpdaterDaoTest {
ComponentDto appBranch = db.components().insertProjectBranch(app);
db.components().insertProjectBranch(app, b -> b.setKey("newName"));
- underTestWithAuditPersister.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getDbKey(), "newName2");
+ underTestWithAuditPersister.updateApplicationBranchKey(dbSession, appBranch.uuid(), app.getKey(), "newName2");
verify(auditPersister, times(1))
.componentKeyBranchUpdate(any(DbSession.class), any(ComponentKeyNewValue.class), anyString());
@@ -168,7 +167,7 @@ public class ComponentKeyUpdaterDaoTest {
String oldProjectKey = project.getKey();
assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldProjectKey)).hasSize(1);
- String oldBranchKey = branch.getDbKey();
+ String oldBranchKey = branch.getKey();
assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
String newProjectKey = "newKey";
@@ -195,7 +194,7 @@ public class ComponentKeyUpdaterDaoTest {
String oldProjectKey = project.getKey();
assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldProjectKey)).hasSize(1);
- String oldBranchKey = pullRequest.getDbKey();
+ String oldBranchKey = pullRequest.getKey();
assertThat(dbClient.componentDao().selectAllComponentsFromProjectKey(dbSession, oldBranchKey)).hasSize(branchComponentCount);
String newProjectKey = "newKey";
@@ -212,7 +211,7 @@ public class ComponentKeyUpdaterDaoTest {
}
private ComponentDto prefixDbKeyWithKey(ComponentDto componentDto, String key) {
- return componentDto.setDbKey(key + ":" + componentDto.getDbKey());
+ return componentDto.setKey(key + ":" + componentDto.getKey());
}
@Test
@@ -226,9 +225,9 @@ public class ComponentKeyUpdaterDaoTest {
@Test
public void updateKey_throws_IAE_when_sub_component_key_is_too_long() {
- ComponentDto project = newPrivateProjectDto("project-uuid").setDbKey("old-project-key");
+ ComponentDto project = newPrivateProjectDto("project-uuid").setKey("old-project-key");
db.components().insertComponent(project);
- db.components().insertComponent(newFileDto(project, null).setDbKey("old-project-key:file"));
+ db.components().insertComponent(newFileDto(project, null).setKey("old-project-key:file"));
String newLongProjectKey = Strings.repeat("a", 400);
assertThatThrownBy(() -> underTest.updateKey(dbSession, project.uuid(), newLongProjectKey))
@@ -244,7 +243,7 @@ public class ComponentKeyUpdaterDaoTest {
@Test
public void updateKey_callsAuditPersister() {
- db.components().insertComponent(newPrivateProjectDto("A").setDbKey("my_project"));
+ db.components().insertComponent(newPrivateProjectDto("A").setKey("my_project"));
underTestWithAuditPersister.updateKey(dbSession, "A", "your_project");
@@ -258,13 +257,13 @@ public class ComponentKeyUpdaterDaoTest {
}
private void populateSomeData() {
- ComponentDto project1 = db.components().insertPrivateProject(t -> t.setDbKey("org.struts:struts").setUuid("A"));
- ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setDbKey("org.struts:struts-core").setUuid("B"));
+ ComponentDto project1 = db.components().insertPrivateProject(t -> t.setKey("org.struts:struts").setUuid("A"));
+ ComponentDto module1 = db.components().insertComponent(newModuleDto(project1).setKey("org.struts:struts-core").setUuid("B"));
ComponentDto directory1 = db.components().insertComponent(newDirectory(module1, "/src/org/struts").setUuid("C"));
- db.components().insertComponent(ComponentTesting.newFileDto(module1, directory1).setDbKey("org.struts:struts-core:/src/org/struts/RequestContext.java").setUuid("D"));
- ComponentDto module2 = db.components().insertComponent(newModuleDto(project1).setDbKey("org.struts:struts-ui").setUuid("E"));
+ db.components().insertComponent(ComponentTesting.newFileDto(module1, directory1).setKey("org.struts:struts-core:/src/org/struts/RequestContext.java").setUuid("D"));
+ ComponentDto module2 = db.components().insertComponent(newModuleDto(project1).setKey("org.struts:struts-ui").setUuid("E"));
ComponentDto directory2 = db.components().insertComponent(newDirectory(module2, "/src/org/struts").setUuid("F"));
- db.components().insertComponent(ComponentTesting.newFileDto(module2, directory2).setDbKey("org.struts:struts-ui:/src/org/struts/RequestContext.java").setUuid("G"));
- ComponentDto project2 = db.components().insertPublicProject(t -> t.setDbKey("foo:struts-core").setUuid("H"));
+ db.components().insertComponent(ComponentTesting.newFileDto(module2, directory2).setKey("org.struts:struts-ui:/src/org/struts/RequestContext.java").setUuid("G"));
+ ComponentDto project2 = db.components().insertPublicProject(t -> t.setKey("foo:struts-core").setUuid("H"));
}
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
index 615afb4141f..868fea8df95 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
@@ -125,7 +125,7 @@ public class ScrollForFileMoveComponentDaoTest {
List<ComponentAndSource> files = IntStream.range(0, 300 + random.nextInt(500))
.mapToObj(i -> {
String qualifier = random.nextBoolean() ? FILE : UNIT_TEST_FILE;
- ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project).setDbKey("f_" + i).setQualifier(qualifier));
+ ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project).setKey("f_" + i).setQualifier(qualifier));
FileSourceDto fileSource = db.fileSources().insertFileSource(file);
return new ComponentAndSource(file, fileSource);
})
@@ -233,7 +233,7 @@ public class ScrollForFileMoveComponentDaoTest {
private static void verifyFileMoveRowDto(RecordingResultHandler resultHander, ComponentAndSource componentAndSource) {
FileMoveRowDto dto = resultHander.getByUuid(componentAndSource.component.uuid()).get();
- assertThat(dto.getKey()).isEqualTo(componentAndSource.component.getDbKey());
+ assertThat(dto.getKey()).isEqualTo(componentAndSource.component.getKey());
assertThat(dto.getUuid()).isEqualTo(componentAndSource.component.uuid());
assertThat(dto.getPath()).isEqualTo(componentAndSource.component.path());
assertThat(dto.getLineCount()).isEqualTo(componentAndSource.source.getLineCount());
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
index 3ebd0e7d7dc..598248c39a7 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
@@ -639,7 +639,7 @@ public class IssueDaoTest {
// return module or dir only if has issue with status different from CLOSED
allModuleOrDirs
.forEach(moduleOrDir -> {
- String projectUuid = moduleOrDir.projectUuid();
+ String projectUuid = moduleOrDir.branchUuid();
// CLOSED issue => not returned
db.issues().insertIssue(t -> t.setProjectUuid(projectUuid).setComponent(moduleOrDir).setStatus(STATUS_CLOSED));
assertThat(underTest.selectModuleAndDirComponentUuidsOfOpenIssuesForProjectUuid(db.getSession(), projectUuid))
@@ -663,7 +663,7 @@ public class IssueDaoTest {
// never return project, view, subview, app or file, whatever the issue status
Stream.of(project1, file11, application, view, subview, project2, file21)
.forEach(neitherModuleNorDir -> {
- String projectUuid = neitherModuleNorDir.projectUuid();
+ String projectUuid = neitherModuleNorDir.branchUuid();
STATUSES
.forEach(status -> {
db.issues().insertIssue(t -> t.setProjectUuid(projectUuid).setComponent(neitherModuleNorDir).setStatus(status));
@@ -675,7 +675,7 @@ public class IssueDaoTest {
// never return whatever the component if it is disabled
allcomponents
.forEach(component -> {
- String projectUuid = component.projectUuid();
+ String projectUuid = component.branchUuid();
// issues for each status => returned if component is dir or module
STATUSES
@@ -808,8 +808,8 @@ public class IssueDaoTest {
private static IssueDto newIssueDto(String key) {
IssueDto dto = new IssueDto();
- dto.setComponent(new ComponentDto().setDbKey("struts:Action").setUuid("component-uuid"));
- dto.setProject(new ComponentDto().setDbKey("struts").setUuid("project-uuid"));
+ dto.setComponent(new ComponentDto().setKey("struts:Action").setUuid("component-uuid"));
+ dto.setProject(new ComponentDto().setKey("struts").setUuid("project-uuid"));
dto.setRule(RuleTesting.newRule(RuleKey.of("java", "S001")).setUuid("uuid-200"));
dto.setKee(key);
dto.setType(2);
@@ -834,8 +834,8 @@ public class IssueDaoTest {
private void prepareIssuesComponent() {
db.rules().insert(RULE.setIsExternal(true));
- ComponentDto projectDto = db.components().insertPrivateProject(t -> t.setUuid(PROJECT_UUID).setDbKey(PROJECT_KEY));
- db.components().insertComponent(newFileDto(projectDto).setUuid(FILE_UUID).setDbKey(FILE_KEY));
+ ComponentDto projectDto = db.components().insertPrivateProject(t -> t.setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
+ db.components().insertComponent(newFileDto(projectDto).setUuid(FILE_UUID).setKey(FILE_KEY));
}
private void prepareTables() {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java
index f756a75f13e..c296effa239 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java
@@ -486,7 +486,7 @@ public class IssueMapperTest {
.setRuleUuid(rule.getUuid())
.setType(rule.getType())
.setComponentUuid(component.uuid())
- .setProjectUuid(component.projectUuid())
+ .setProjectUuid(component.branchUuid())
.setStatus(Issue.STATUS_CLOSED)
.setIssueCloseTime(issueCloseTime);
Arrays.asList(consumers).forEach(c -> c.accept(res));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
index cfb9d3c6d13..ac04aa4b4ae 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
@@ -721,7 +721,7 @@ public class LiveMeasureDaoTest {
}
private ComponentDto addProjectWithMeasure(String projectKey, MetricDto metric, double metricValue) {
- ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey(projectKey));
+ ComponentDto project = db.components().insertPublicProject(p -> p.setKey(projectKey));
addMeasureToComponent(project, metric, metricValue,true);
return project;
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
index 84d9e502cd6..ce4bbe75132 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasuresIndexerIteratorTest.java
@@ -62,7 +62,7 @@ public class ProjectMeasuresIndexerIteratorTest {
@Test
public void return_project_measure() {
ComponentDto project = dbTester.components().insertPrivateProject(
- c -> c.setDbKey("Project-Key").setName("Project Name"),
+ c -> c.setKey("Project-Key").setName("Project Name"),
p -> p.setTags(newArrayList("platform", "java")));
SnapshotDto analysis = dbTester.components().insertSnapshot(project);
@@ -87,7 +87,7 @@ public class ProjectMeasuresIndexerIteratorTest {
@Test
public void return_application_measure() {
- ComponentDto project = dbTester.components().insertPrivateApplication(c -> c.setDbKey("App-Key").setName("App Name"));
+ ComponentDto project = dbTester.components().insertPrivateApplication(c -> c.setKey("App-Key").setName("App Name"));
SnapshotDto analysis = dbTester.components().insertSnapshot(project);
MetricDto metric1 = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("ncloc"));
@@ -110,7 +110,7 @@ public class ProjectMeasuresIndexerIteratorTest {
@Test
public void return_project_measure_having_leak() {
ComponentDto project = dbTester.components().insertPrivateProject(
- c -> c.setDbKey("Project-Key").setName("Project Name"),
+ c -> c.setKey("Project-Key").setName("Project Name"),
p -> p.setTagsString("platform,java"));
MetricDto metric = dbTester.measures().insertMetric(m -> m.setValueType(INT.name()).setKey("new_lines"));
dbTester.measures().insertLiveMeasure(project, metric, m -> m.setVariation(10d));
@@ -269,7 +269,7 @@ public class ProjectMeasuresIndexerIteratorTest {
ProjectMeasures doc = docsById.get(project1.uuid());
assertThat(doc).isNotNull();
assertThat(doc.getProject().getUuid()).isEqualTo(project1.uuid());
- assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project1.getDbKey());
+ assertThat(doc.getProject().getKey()).isNotNull().isEqualTo(project1.getKey());
assertThat(doc.getProject().getName()).isNotNull().isEqualTo(project1.name());
assertThat(doc.getProject().getAnalysisDate()).isNotNull().isEqualTo(analysis1.getCreatedAt());
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java
index 89f9450d68e..6c8fce59e49 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoWithPersisterTest.java
@@ -173,13 +173,13 @@ public class GroupPermissionDaoWithPersisterTest {
private void addGroupPermission() {
group = db.users().insertGroup(g -> g.setUuid("guuid").setName("gname"));
- project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setDbKey("cKey"));
+ project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setKey("cKey"));
dto = getGroupPermission(group, project);
underTest.insert(dbSession, dto, project, null);
}
private void addGroupPermissionWithoutGroup() {
- project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setDbKey("cKey"));
+ project = db.components().insertPrivateProject(c -> c.setUuid("cuuid").setName("cname").setKey("cKey"));
dto = getGroupPermission(project);
underTest.insert(dbSession, dto, project, null);
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
index 72b76e9c4bd..aa1c30d884c 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/portfolio/PortfolioDaoTest.java
@@ -224,7 +224,7 @@ public class PortfolioDaoTest {
db.components().insertPrivatePortfolioDto("portfolio1");
db.components().insertPrivatePortfolioDto("portfolio2");
db.components().insertPrivatePortfolioDto("portfolio3");
- ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+ ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
portfolioDao.addReference(session, "portfolio1", "portfolio2");
portfolioDao.addReference(session, "portfolio2", "portfolio3");
@@ -240,7 +240,7 @@ public class PortfolioDaoTest {
db.components().insertPrivatePortfolioDto("portfolio1");
db.components().insertPrivatePortfolioDto("portfolio2");
db.components().insertPrivatePortfolioDto("portfolio3");
- ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+ ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
portfolioDao.addReference(session, "portfolio1", "portfolio2");
portfolioDao.addReference(session, "portfolio2", "portfolio3");
@@ -259,9 +259,9 @@ public class PortfolioDaoTest {
var p1 = db.components().insertPrivatePortfolioDto("portfolio1");
var p2 = db.components().insertPrivatePortfolioDto("portfolio2", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
var p3 = db.components().insertPrivatePortfolioDto("portfolio3", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
- ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
- ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
- ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app3"));
+ ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
+ ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
+ ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setKey("app3"));
portfolioDao.addReference(session, "portfolio1", app1.getUuid());
portfolioDao.addReference(session, "portfolio2", app2.getUuid());
@@ -282,9 +282,9 @@ public class PortfolioDaoTest {
var p1 = db.components().insertPrivatePortfolioDto("portfolio1");
var p2 = db.components().insertPrivatePortfolioDto("portfolio2", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
var p3 = db.components().insertPrivatePortfolioDto("portfolio3", p -> p.setRootUuid(p1.getUuid()).setParentUuid(p1.getUuid()));
- ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
- ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
- ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app3"));
+ ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
+ ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
+ ProjectDto app3 = db.components().insertPrivateApplicationDto(p -> p.setKey("app3"));
portfolioDao.addReference(session, "portfolio1", app1.getUuid());
portfolioDao.addReference(session, "portfolio2", app2.getUuid());
@@ -316,10 +316,10 @@ public class PortfolioDaoTest {
@Test
public void selectAllApplicationProjectsBelongToTheSamePortfolio() {
var portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
- var app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
- var app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
- var project1 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:one").setName("Projet Un"));
- var project2 = db.components().insertPrivateProjectDto(p -> p.setDbKey("project:two").setName("Projet Deux"));
+ var app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
+ var app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
+ var project1 = db.components().insertPrivateProjectDto(p -> p.setKey("project:one").setName("Projet Un"));
+ var project2 = db.components().insertPrivateProjectDto(p -> p.setKey("project:two").setName("Projet Deux"));
db.components().addApplicationProject(app1, project1);
db.components().addApplicationProject(app2, project2);
@@ -353,7 +353,7 @@ public class PortfolioDaoTest {
@Test
public void select_reference_to_app_by_key() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
- ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+ ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
db.components().addPortfolioReference(portfolio, app1.getUuid());
assertThat(portfolioDao.selectReferenceToApp(db.getSession(), portfolio.getUuid(), app1.getKey()))
@@ -371,7 +371,7 @@ public class PortfolioDaoTest {
@Test
public void select_reference_to_app_with_branches() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
- ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
+ ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setKey("app").setName("app"));
BranchDto branch1 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
BranchDto branch2 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
@@ -391,7 +391,7 @@ public class PortfolioDaoTest {
@Test
public void select_root_reference_to_app_main_branch() {
PortfolioDto portfolio1 = db.components().insertPrivatePortfolioDto("portfolio1");
- ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app1"));
+ ProjectDto app1 = db.components().insertPrivateApplicationDto(p -> p.setKey("app1"));
db.components().addPortfolioReference(portfolio1, app1.getUuid());
assertThat(portfolioDao.selectRootOfReferencersToMainBranch(db.getSession(), app1.getUuid()))
@@ -399,7 +399,7 @@ public class PortfolioDaoTest {
.containsExactly(portfolio1.getKey());
PortfolioDto portfolio2 = db.components().insertPrivatePortfolioDto("portfolio2");
- ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app2"));
+ ProjectDto app2 = db.components().insertPrivateApplicationDto(p -> p.setKey("app2"));
db.components().addPortfolioApplicationBranch(portfolio2.getUuid(), app2.getUuid(), app2.getUuid());
assertThat(portfolioDao.selectRootOfReferencersToMainBranch(db.getSession(), app2.getUuid()))
@@ -410,7 +410,7 @@ public class PortfolioDaoTest {
@Test
public void select_root_reference_to_app_with_branches() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
- ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
+ ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setKey("app").setName("app"));
BranchDto branch = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
db.components().addPortfolioApplicationBranch(portfolio.getUuid(), app.getUuid(), branch.getUuid());
@@ -530,7 +530,7 @@ public class PortfolioDaoTest {
@Test
public void deleteReferenceBranch() {
PortfolioDto portfolio = db.components().insertPrivatePortfolioDto("portfolio1");
- ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setDbKey("app").setName("app"));
+ ProjectDto app = db.components().insertPrivateApplicationDto(p -> p.setKey("app").setName("app"));
BranchDto branch1 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
BranchDto branch2 = db.components().insertProjectBranch(app, b -> b.setExcludeFromPurge(true));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java
index e0ec8ed5a57..dd53c201b97 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertiesDaoTest.java
@@ -176,7 +176,7 @@ public class InternalComponentPropertiesDaoTest {
underTest.insertOrUpdate(dbSession, portfolio2.uuid(), SOME_KEY, "bar");
underTest.insertOrUpdate(dbSession, portfolio3.uuid(), "foo", SOME_VALUE);
- assertThat(underTest.selectDbKeys(dbSession, SOME_KEY, SOME_VALUE)).containsOnly(portfolio1.getDbKey());
+ assertThat(underTest.selectDbKeys(dbSession, SOME_KEY, SOME_VALUE)).containsOnly(portfolio1.getKey());
}
private InternalComponentPropertyDto saveDto() {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
index 8f812c2f8ba..40cf19f892a 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertiesDaoTest.java
@@ -529,7 +529,7 @@ public class PropertiesDaoTest {
insertProperty("project.one", "Pone", projectUuid, null, null, projectDto.getKey(), projectDto.name());
insertProperty("project.two", "Ptwo", projectUuid, null, null, projectDto.getKey(), projectDto.name());
- List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getDbKey());
+ List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getKey());
assertThat(dtos)
.hasSize(2);
assertThat(findByKey(dtos, "project.one"))
@@ -547,7 +547,7 @@ public class PropertiesDaoTest {
ComponentDto projectDto = insertPrivateProject("A");
insertProperty("project.one", dbValue, projectDto.uuid(), null, null, projectDto.getKey(), projectDto.name());
- List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getDbKey());
+ List<PropertyDto> dtos = underTest.selectProjectProperties(projectDto.getKey());
assertThat(dtos).hasSize(1);
assertThat(dtos.iterator().next())
@@ -1316,7 +1316,7 @@ public class PropertiesDaoTest {
}
private ComponentDto insertPrivateProject(String projectKey) {
- return db.components().insertPrivateProject(t -> t.setDbKey(projectKey));
+ return db.components().insertPrivateProject(t -> t.setKey(projectKey));
}
private static Consumer<UserDto> withEmail(String login) {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
index 5700ff9b356..3be16525ec8 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
@@ -210,7 +210,7 @@ public class PurgeCommandsTest {
@Test
public void deleteProjects() {
ComponentDto project = dbTester.components().insertPrivateProject();
- ProjectDto projectDto = dbTester.getDbClient().projectDao().selectProjectByKey(dbTester.getSession(), project.getDbKey()).get();
+ ProjectDto projectDto = dbTester.getDbClient().projectDao().selectProjectByKey(dbTester.getSession(), project.getKey()).get();
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
SnapshotDto analysis = dbTester.components().insertSnapshot(project);
dbTester.events().insertEvent(analysis);
@@ -754,7 +754,7 @@ public class PurgeCommandsTest {
}
private int countComponentOfRoot(ComponentDto projectOrView) {
- return dbTester.countSql("select count(1) from components where project_uuid='" + projectOrView.uuid() + "'");
+ return dbTester.countSql("select count(1) from components where branch_uuid='" + projectOrView.uuid() + "'");
}
private void insertDuplication(ComponentDto project, SnapshotDto analysis) {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index a8bbfc379c6..00826d4dbb5 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -1165,7 +1165,7 @@ public class PurgeDaoTest {
newConfigurationWith30Days(System2.INSTANCE, project.uuid(), project.uuid(), disabledComponentUuids),
purgeListener, new PurgeProfiler());
- assertThat(db.getDbClient().componentDao().selectByProjectUuid(project.uuid(), dbSession))
+ assertThat(db.getDbClient().componentDao().selectByBranchUuid(project.uuid(), dbSession))
.extracting("uuid")
.containsOnly(project.uuid(), enabledFileWithIssues.uuid(), disabledFileWithIssues.uuid(),
enabledFileWithoutIssues.uuid());
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java
index bdd73a6f3ee..89f6b619d5e 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java
@@ -65,9 +65,9 @@ public class ProjectQgateAssociationDaoTest {
@Test
public void select_all_projects_by_query_should_have_deterministic_order() {
QualityGateDto qualityGate1 = db.qualityGates().insertQualityGate();
- ComponentDto project1 = db.components().insertPrivateProject(d -> d.setName("p1").setDbKey("key1"));
- ComponentDto project2 = db.components().insertPrivateProject(d -> d.setName("p1").setDbKey("key2"));
- ComponentDto project3 = db.components().insertPrivateProject(d -> d.setName("p2").setDbKey("key3"));
+ ComponentDto project1 = db.components().insertPrivateProject(d -> d.setName("p1").setKey("key1"));
+ ComponentDto project2 = db.components().insertPrivateProject(d -> d.setName("p1").setKey("key2"));
+ ComponentDto project3 = db.components().insertPrivateProject(d -> d.setName("p2").setKey("key3"));
db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project1), qualityGate1);
db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project2), qualityGate1);
db.qualityGates().associateProjectToQualityGate(db.components().getProjectDto(project3), qualityGate1);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
index dee8e09339f..0631c5d3fc3 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java
@@ -771,8 +771,8 @@ public class QualityProfileDaoTest {
assertThat(underTest.selectSelectedProjects(dbSession, profile1, null))
.extracting("projectUuid", "projectKey", "projectName", "profileKey")
.containsOnly(
- tuple(project1.uuid(), project1.getDbKey(), project1.name(), profile1.getKee()),
- tuple(project2.uuid(), project2.getDbKey(), project2.name(), profile1.getKee()));
+ tuple(project1.uuid(), project1.getKey(), project1.name(), profile1.getKee()),
+ tuple(project2.uuid(), project2.getKey(), project2.name(), profile1.getKee()));
assertThat(underTest.selectSelectedProjects(dbSession, profile1, "ect1")).hasSize(1);
assertThat(underTest.selectSelectedProjects(dbSession, profile3, null)).isEmpty();
@@ -796,8 +796,8 @@ public class QualityProfileDaoTest {
assertThat(underTest.selectDeselectedProjects(dbSession, profile1, null))
.extracting("projectUuid", "projectKey", "projectName", "profileKey")
.containsExactly(
- tuple(project2.uuid(), project2.getDbKey(), project2.name(), null),
- tuple(project3.uuid(), project3.getDbKey(), project3.name(), null));
+ tuple(project2.uuid(), project2.getKey(), project2.name(), null),
+ tuple(project3.uuid(), project3.getKey(), project3.name(), null));
assertThat(underTest.selectDeselectedProjects(dbSession, profile1, "ect2")).hasSize(1);
assertThat(underTest.selectDeselectedProjects(dbSession, profile3, null)).hasSize(3);
@@ -822,9 +822,9 @@ public class QualityProfileDaoTest {
assertThat(underTest.selectProjectAssociations(dbSession, profile1, null))
.extracting("projectUuid", "projectKey", "projectName", "profileKey")
.containsOnly(
- tuple(project1.uuid(), project1.getDbKey(), project1.name(), profile1.getKee()),
- tuple(project2.uuid(), project2.getDbKey(), project2.name(), null),
- tuple(project3.uuid(), project3.getDbKey(), project3.name(), null));
+ tuple(project1.uuid(), project1.getKey(), project1.name(), profile1.getKee()),
+ tuple(project2.uuid(), project2.getKey(), project2.name(), null),
+ tuple(project3.uuid(), project3.getKey(), project3.name(), null));
assertThat(underTest.selectProjectAssociations(dbSession, profile1, "ect2")).hasSize(1);
assertThat(underTest.selectProjectAssociations(dbSession, profile3, null)).hasSize(3);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/report/RegulatoryReportDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/report/RegulatoryReportDaoTest.java
index 30b3152793f..5a04f76f638 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/report/RegulatoryReportDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/report/RegulatoryReportDaoTest.java
@@ -56,8 +56,8 @@ public class RegulatoryReportDaoTest {
public void prepare() {
rule = db.rules().insertRule();
hotspotRule = db.rules().insertHotspotRule();
- project = db.components().insertPrivateProject(t -> t.setProjectUuid(PROJECT_UUID).setUuid(PROJECT_UUID).setDbKey(PROJECT_KEY));
- file = db.components().insertComponent(newFileDto(project).setUuid(FILE_UUID).setDbKey(FILE_KEY));
+ project = db.components().insertPrivateProject(t -> t.setBranchUuid(PROJECT_UUID).setUuid(PROJECT_UUID).setKey(PROJECT_KEY));
+ file = db.components().insertComponent(newFileDto(project).setUuid(FILE_UUID).setKey(FILE_KEY));
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
index 885ed6d3bde..e1b6f37fb6e 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java
@@ -245,7 +245,7 @@ public class FileSourceDaoTest {
.collect(Collectors.toList());
Map<String, FileHashesDto> fileSourcesByUuid = new HashMap<>();
- underTest.scrollFileHashesByProjectUuid(dbSession, project.projectUuid(), result -> fileSourcesByUuid.put(result.getResultObject().getFileUuid(), result.getResultObject()));
+ underTest.scrollFileHashesByProjectUuid(dbSession, project.branchUuid(), result -> fileSourcesByUuid.put(result.getResultObject().getFileUuid(), result.getResultObject()));
assertThat(fileSourcesByUuid).hasSize(files.size());
files.forEach(t -> assertThat(fileSourcesByUuid).containsKey(t.uuid()));
@@ -258,7 +258,7 @@ public class FileSourceDaoTest {
FileSourceDto inserted = dbTester.fileSources().insertFileSource(file);
List<FileHashesDto> fileSources = new ArrayList<>(1);
- underTest.scrollFileHashesByProjectUuid(dbSession, project.projectUuid(), result -> fileSources.add(result.getResultObject()));
+ underTest.scrollFileHashesByProjectUuid(dbSession, project.branchUuid(), result -> fileSources.add(result.getResultObject()));
assertThat(fileSources).hasSize(1);
FileHashesDto fileSource = fileSources.iterator().next();
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
index de5d12ba329..78d4bec46a4 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
@@ -69,7 +69,7 @@ public class UserTokenDaoTest {
@Test
public void insert_project_analysis_token() {
UserTokenDto projectAnalysisToken = newProjectAnalysisToken();
- ComponentDto project = db.components().insertPublicProject(p -> p.setDbKey(projectAnalysisToken.getProjectKey()));
+ ComponentDto project = db.components().insertPublicProject(p -> p.setKey(projectAnalysisToken.getProjectKey()));
underTest.insert(db.getSession(), projectAnalysisToken, "login");
UserTokenDto projectAnalysisTokenFromDb = underTest.selectByTokenHash(db.getSession(), projectAnalysisToken.getTokenHash());
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoWithPersisterTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoWithPersisterTest.java
index 16145d36850..527ed614192 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoWithPersisterTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDaoWithPersisterTest.java
@@ -159,7 +159,7 @@ public class WebhookDaoWithPersisterTest {
@Test
public void deleteProjectWebhooksIsPersisted() {
ProjectDto projectDto = componentDbTester.insertPrivateProjectDto(p ->
- p.setUuid("puuid").setName("pname").setDbKey("pkey"));
+ p.setUuid("puuid").setName("pname").setKey("pkey"));
webhookDbTester.insertWebhook(projectDto);
underTest.deleteByProject(dbSession, projectDto);
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
index db56cf6c597..be729322f02 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
@@ -478,7 +478,7 @@ public class ComponentDbTester {
@SafeVarargs
public final ComponentDto insertProjectBranch(ComponentDto project, Consumer<BranchDto>... dtoPopulators) {
// MainBranchProjectUuid will be null if it's a main branch
- BranchDto branchDto = ComponentTesting.newBranchDto(firstNonNull(project.getMainBranchProjectUuid(), project.projectUuid()), BRANCH);
+ BranchDto branchDto = ComponentTesting.newBranchDto(firstNonNull(project.getMainBranchProjectUuid(), project.branchUuid()), BRANCH);
Arrays.stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(branchDto));
return insertProjectBranch(project, branchDto);
}
@@ -502,7 +502,7 @@ public class ComponentDbTester {
public final ComponentDto insertProjectBranch(ComponentDto project, BranchDto branchDto) {
// MainBranchProjectUuid will be null if it's a main branch
- checkArgument(branchDto.getProjectUuid().equals(firstNonNull(project.getMainBranchProjectUuid(), project.projectUuid())));
+ checkArgument(branchDto.getProjectUuid().equals(firstNonNull(project.getMainBranchProjectUuid(), project.branchUuid())));
ComponentDto branch = ComponentTesting.newBranchComponent(project, branchDto);
insertComponent(branch);
dbClient.branchDao().insert(dbSession, branchDto);
@@ -518,7 +518,7 @@ public class ComponentDbTester {
public static ProjectDto toProjectDto(ComponentDto componentDto, long createTime) {
return new ProjectDto()
.setUuid(componentDto.uuid())
- .setKey(componentDto.getDbKey())
+ .setKey(componentDto.getKey())
.setQualifier(componentDto.qualifier() != null ? componentDto.qualifier() : Qualifiers.PROJECT)
.setCreatedAt(createTime)
.setUpdatedAt(createTime)
@@ -530,8 +530,8 @@ public class ComponentDbTester {
public static PortfolioDto toPortfolioDto(ComponentDto componentDto, long createTime) {
return new PortfolioDto()
.setUuid(componentDto.uuid())
- .setKey(componentDto.getDbKey())
- .setRootUuid(componentDto.projectUuid())
+ .setKey(componentDto.getKey())
+ .setRootUuid(componentDto.branchUuid())
.setSelectionMode(NONE.name())
.setCreatedAt(createTime)
.setUpdatedAt(createTime)
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
index 741fe1ed192..b32970caf9a 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
@@ -34,8 +34,6 @@ import static org.sonar.db.component.ComponentDto.PULL_REQUEST_SEPARATOR;
import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
import static org.sonar.db.component.ComponentDto.formatUuidPathFromParent;
-import static org.sonar.db.component.ComponentDto.generateBranchKey;
-import static org.sonar.db.component.ComponentDto.generatePullRequestKey;
public class ComponentTesting {
@@ -51,7 +49,7 @@ public class ComponentTesting {
String filename = "NAME_" + fileUuid;
String path = directory != null ? directory.path() + "/" + filename : module.path() + "/" + filename;
return newChildComponent(fileUuid, module, directory == null ? module : directory)
- .setDbKey(generateKey("FILE_KEY_" + fileUuid, module))
+ .setKey("FILE_KEY_" + fileUuid)
.setName(filename)
.setLongName(path)
.setScope(Scopes.FILE)
@@ -68,7 +66,7 @@ public class ComponentTesting {
public static ComponentDto newDirectory(ComponentDto module, String uuid, String path) {
String key = !path.equals("/") ? module.getKey() + ":" + path : module.getKey() + ":/";
return newChildComponent(uuid, module, module)
- .setDbKey(generateKey(key, module))
+ .setKey(key)
.setName(path)
.setLongName(path)
.setPath(path)
@@ -78,7 +76,7 @@ public class ComponentTesting {
public static ComponentDto newSubPortfolio(ComponentDto portfolioOrSubPortfolio, String uuid, String key) {
return newModuleDto(uuid, portfolioOrSubPortfolio)
- .setDbKey(key)
+ .setKey(key)
.setName(key)
.setLongName(key)
.setScope(Scopes.PROJECT)
@@ -94,7 +92,7 @@ public class ComponentTesting {
public static ComponentDto newModuleDto(String uuid, ComponentDto parentModuleOrProject) {
return newChildComponent(uuid, parentModuleOrProject, parentModuleOrProject)
.setModuleUuidPath(parentModuleOrProject.moduleUuidPath() + uuid + UUID_PATH_SEPARATOR)
- .setDbKey(generateKey("MODULE_KEY_" + uuid, parentModuleOrProject))
+ .setKey("MODULE_KEY_" + uuid)
.setName("NAME_" + uuid)
.setLongName("LONG_NAME_" + uuid)
.setPath("module")
@@ -103,19 +101,6 @@ public class ComponentTesting {
.setLanguage(null);
}
- private static String generateKey(String key, ComponentDto parentModuleOrProject) {
- String branch = parentModuleOrProject.getBranch();
- if (branch != null) {
- return generateBranchKey(key, branch);
- }
- String pullRequest = parentModuleOrProject.getPullRequest();
- if (pullRequest != null) {
- return generatePullRequestKey(key, pullRequest);
- }
-
- return key;
- }
-
public static ComponentDto newModuleDto(ComponentDto subProjectOrProject) {
return newModuleDto(Uuids.createFast(), subProjectOrProject);
}
@@ -140,10 +125,10 @@ public class ComponentTesting {
return new ComponentDto()
.setUuid(uuid)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setProjectUuid(uuid)
+ .setBranchUuid(uuid)
.setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
.setRootUuid(uuid)
- .setDbKey("KEY_" + uuid)
+ .setKey("KEY_" + uuid)
.setName("NAME_" + uuid)
.setLongName("LONG_NAME_" + uuid)
.setDescription("DESCRIPTION_" + uuid)
@@ -177,7 +162,7 @@ public class ComponentTesting {
public static ComponentDto newProjectCopy(String uuid, ComponentDto project, ComponentDto view) {
return newChildComponent(uuid, view, view)
- .setDbKey(view.getDbKey() + project.getDbKey())
+ .setKey(view.getKey() + project.getKey())
.setName(project.name())
.setLongName(project.longName())
.setCopyComponentUuid(project.uuid())
@@ -194,8 +179,8 @@ public class ComponentTesting {
return new ComponentDto()
.setUuid(uuid)
.setUuidPath(formatUuidPathFromParent(parent))
- .setDbKey(uuid)
- .setProjectUuid(moduleOrProject.projectUuid())
+ .setKey(uuid)
+ .setBranchUuid(moduleOrProject.branchUuid())
.setRootUuid(moduleOrProject.uuid())
.setModuleUuid(moduleOrProject.uuid())
.setModuleUuidPath(moduleOrProject.moduleUuidPath())
@@ -216,7 +201,7 @@ public class ComponentTesting {
}
public static BranchDto newBranchDto(ComponentDto project) {
- return newBranchDto(project.projectUuid(), BranchType.BRANCH);
+ return newBranchDto(project.branchUuid(), BranchType.BRANCH);
}
public static BranchDto newBranchDto(ComponentDto branchComponent, BranchType branchType) {
@@ -238,11 +223,11 @@ public class ComponentTesting {
return new ComponentDto()
.setUuid(uuid)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setProjectUuid(uuid)
+ .setBranchUuid(uuid)
.setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
.setRootUuid(uuid)
// name of the branch is not mandatory on the main branch
- .setDbKey(branchName != null ? project.getKey() + branchSeparator + branchName : project.getKey())
+ .setKey(branchName != null ? project.getKey() + branchSeparator + branchName : project.getKey())
.setMainBranchProjectUuid(project.getUuid())
.setName(project.getName())
.setLongName(project.getName())
@@ -259,16 +244,14 @@ public class ComponentTesting {
checkArgument(project.qualifier().equals(Qualifiers.PROJECT) || project.qualifier().equals(Qualifiers.APP));
checkArgument(project.getMainBranchProjectUuid() == null);
String branchName = branchDto.getKey();
- String branchSeparator = branchDto.getBranchType() == PULL_REQUEST ? PULL_REQUEST_SEPARATOR : BRANCH_KEY_SEPARATOR;
String uuid = branchDto.getUuid();
return new ComponentDto()
.setUuid(uuid)
.setUuidPath(UUID_PATH_OF_ROOT)
- .setProjectUuid(uuid)
+ .setBranchUuid(uuid)
.setModuleUuidPath(UUID_PATH_SEPARATOR + uuid + UUID_PATH_SEPARATOR)
.setRootUuid(uuid)
- // name of the branch is not mandatory on the main branch
- .setDbKey(branchName != null ? project.getDbKey() + branchSeparator + branchName : project.getKey())
+ .setKey(project.getKey())
.setMainBranchProjectUuid(project.uuid())
.setName(project.name())
.setLongName(project.longName())
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/SnapshotTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/SnapshotTesting.java
index ae451bacac6..5de13132e63 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/SnapshotTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/SnapshotTesting.java
@@ -32,7 +32,7 @@ public class SnapshotTesting {
public static SnapshotDto newAnalysis(ComponentDto rootComponent) {
checkNotNull(rootComponent.uuid(), "Project UUID must be set");
- checkArgument(rootComponent.uuid().equals(rootComponent.projectUuid()), "Component is not a tree root");
+ checkArgument(rootComponent.uuid().equals(rootComponent.branchUuid()), "Component is not a tree root");
return newAnalysis(rootComponent.uuid());
}
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java
index a39dee2a830..330f6cbb9e8 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/measure/MeasureTesting.java
@@ -70,7 +70,7 @@ public class MeasureTesting {
return new LiveMeasureDto()
.setMetricUuid(metric.getUuid())
.setComponentUuid(component.uuid())
- .setProjectUuid(component.projectUuid())
+ .setProjectUuid(component.branchUuid())
.setData(String.valueOf(cursor++))
.setValue((double) cursor++)
.setVariation((double) cursor++);
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java
index 4206dfdfce0..9175c4ab8f1 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java
@@ -45,7 +45,7 @@ public class FileSourceTester {
public final FileSourceDto insertFileSource(ComponentDto file, Consumer<FileSourceDto>... dtoPopulators) {
FileSourceDto dto = new FileSourceDto()
.setUuid(Uuids.createFast())
- .setProjectUuid(file.projectUuid())
+ .setProjectUuid(file.branchUuid())
.setFileUuid(file.uuid())
.setSrcHash(randomAlphanumeric(50))
.setDataHash(randomAlphanumeric(50))
@@ -65,7 +65,7 @@ public class FileSourceTester {
public final FileSourceDto insertFileSource(ComponentDto file, int numLines, Consumer<FileSourceDto>... dtoPopulators) {
FileSourceDto dto = new FileSourceDto()
.setUuid(Uuids.createFast())
- .setProjectUuid(file.projectUuid())
+ .setProjectUuid(file.branchUuid())
.setFileUuid(file.uuid())
.setSrcHash(randomAlphanumeric(50))
.setDataHash(randomAlphanumeric(50))