aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao/src/test
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-09-30 16:34:23 +0200
committersonartech <sonartech@sonarsource.com>2022-10-12 20:03:44 +0000
commitc85e433a567b8580a1fd5e185b4f5bc73b6e53e6 (patch)
treef79a436253a656aa5aa49027a51b9fc5fd1b8506 /server/sonar-db-dao/src/test
parentcdec0dad5c29a109ad724477bdb1a517e1834046 (diff)
downloadsonarqube-c85e433a567b8580a1fd5e185b4f5bc73b6e53e6.tar.gz
sonarqube-c85e433a567b8580a1fd5e185b4f5bc73b6e53e6.zip
SONAR-17352 Refactor component keys to not include branch suffix
Diffstat (limited to 'server/sonar-db-dao/src/test')
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java1
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentKeyUpdaterDaoTest.java11
2 files changed, 5 insertions, 7 deletions
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 061dbac8515..3cea2b59323 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
@@ -42,7 +42,6 @@ public class ComponentDtoTest {
.setRootUuid("uuid_3");
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");
assertThat(componentDto.qualifier()).isEqualTo("FIL");
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 790e937b628..963b007a7e8 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
@@ -22,8 +22,6 @@ package org.sonar.db.component;
import com.google.common.base.Strings;
import java.util.List;
import java.util.Map;
-import java.util.function.Predicate;
-import org.apache.commons.lang.RandomStringUtils;
import org.assertj.core.groups.Tuple;
import org.junit.Rule;
import org.junit.Test;
@@ -35,6 +33,7 @@ import org.sonar.db.DbTester;
import org.sonar.db.audit.AuditPersister;
import org.sonar.db.audit.model.ComponentKeyNewValue;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
@@ -159,8 +158,8 @@ public class ComponentKeyUpdaterDaoTest {
@Test
public void updateKey_updates_branches_too() {
ComponentDto project = db.components().insertPublicProject();
- String branchKey = RandomStringUtils.randomAlphanumeric(100);
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchKey));
+ String branchName = randomAlphanumeric(248);
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(branchName));
db.components().insertComponent(newFileDto(branch));
db.components().insertComponent(newFileDto(branch));
int prComponentCount = 3;
@@ -174,7 +173,7 @@ public class ComponentKeyUpdaterDaoTest {
assertThat(dbClient.componentDao().selectByKey(dbSession, oldProjectKey)).isEmpty();
assertThat(dbClient.componentDao().selectByKey(dbSession, newProjectKey)).isPresent();
- assertThat(dbClient.componentDao().selectByKeyAndBranch(dbSession, newProjectKey, branchKey)).isPresent();
+ assertThat(dbClient.componentDao().selectByKeyAndBranch(dbSession, newProjectKey, branchName)).isPresent();
assertThat(dbClient.componentDao().selectByBranchUuid(project.uuid(), dbSession)).hasSize(1);
assertThat(dbClient.componentDao().selectByBranchUuid(branch.uuid(), dbSession)).hasSize(prComponentCount);
@@ -185,7 +184,7 @@ public class ComponentKeyUpdaterDaoTest {
@Test
public void updateKey_updates_pull_requests_too() {
ComponentDto project = db.components().insertPublicProject();
- String pullRequestKey1 = RandomStringUtils.randomAlphanumeric(100);
+ String pullRequestKey1 = randomAlphanumeric(100);
ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST).setKey(pullRequestKey1));
db.components().insertComponent(newFileDto(pullRequest));
db.components().insertComponent(newFileDto(pullRequest));