aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-es
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-webserver-es
parentbcfb1cac55137b838da7a93385b20e0e5ed47abb (diff)
downloadsonarqube-566094fc629ab1e92afb0cdf191a0e2c685b5c35.tar.gz
sonarqube-566094fc629ab1e92afb0cdf191a0e2c685b5c35.zip
SONAR-17352 Refactor component keys to not include branch suffix
Diffstat (limited to 'server/sonar-webserver-es')
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java6
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java6
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java4
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java12
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java6
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchWindowExceededTest.java2
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java6
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java6
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java2
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java2
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java10
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java50
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java40
13 files changed, 76 insertions, 76 deletions
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
index 7c8e6d0743e..e1f6d21285e 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java
@@ -100,7 +100,7 @@ public class IssueQueryFactory {
.filter(t -> t != RuleType.SECURITY_HOTSPOT)
.map(Enum::name)
.collect(MoreCollectors.toSet(RuleType.values().length - 1));
- private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setProjectUuid(UNKNOWN);
+ private static final ComponentDto UNKNOWN_COMPONENT = new ComponentDto().setUuid(UNKNOWN).setBranchUuid(UNKNOWN);
private static final Set<String> QUALIFIERS_WITHOUT_LEAK_PERIOD = new HashSet<>(Arrays.asList(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW));
private final DbClient dbClient;
private final Clock clock;
@@ -443,11 +443,11 @@ public class IssueQueryFactory {
private static String toProjectUuid(ComponentDto componentDto) {
String mainBranchProjectUuid = componentDto.getMainBranchProjectUuid();
- return mainBranchProjectUuid == null ? componentDto.projectUuid() : mainBranchProjectUuid;
+ return mainBranchProjectUuid == null ? componentDto.branchUuid() : mainBranchProjectUuid;
}
private static void setBranch(IssueQuery.Builder builder, ComponentDto component, @Nullable String branch, @Nullable String pullRequest) {
- builder.branchUuid(branch == null && pullRequest == null ? null : component.projectUuid());
+ builder.branchUuid(branch == null && pullRequest == null ? null : component.branchUuid());
builder.mainBranch(UNKNOWN_COMPONENT.equals(component)
|| (branch == null && pullRequest == null)
|| (branch != null && !branch.equals(component.getBranch()))
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java
index 7b9a964a8ee..cff63f8fc1a 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureFavoriteTest.java
@@ -46,14 +46,14 @@ public class ComponentIndexFeatureFavoriteTest extends ComponentIndexTest {
SuggestionQuery query1 = SuggestionQuery.builder()
.setQuery("SonarQube")
.setQualifiers(singletonList(PROJECT))
- .setFavoriteKeys(of(project1.getDbKey()))
+ .setFavoriteKeys(of(project1.getKey()))
.build();
assertSearch(query1).containsExactly(uuids(project1, project2));
SuggestionQuery query2 = SuggestionQuery.builder()
.setQuery("SonarQube")
.setQualifiers(singletonList(PROJECT))
- .setFavoriteKeys(of(project2.getDbKey()))
+ .setFavoriteKeys(of(project2.getKey()))
.build();
assertSearch(query2).containsExactly(uuids(project2, project1));
}
@@ -66,7 +66,7 @@ public class ComponentIndexFeatureFavoriteTest extends ComponentIndexTest {
SuggestionQuery query1 = SuggestionQuery.builder()
.setQuery("bar")
.setQualifiers(singletonList(PROJECT))
- .setFavoriteKeys(of(project1.getDbKey()))
+ .setFavoriteKeys(of(project1.getKey()))
.build();
assertSearch(query1).isEmpty();
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java
index d83901560b6..40567a496b2 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexFeatureRecentlyBrowsedTest.java
@@ -44,14 +44,14 @@ public class ComponentIndexFeatureRecentlyBrowsedTest extends ComponentIndexTest
SuggestionQuery query1 = SuggestionQuery.builder()
.setQuery("SonarQube")
.setQualifiers(Collections.singletonList(PROJECT))
- .setRecentlyBrowsedKeys(of(project1.getDbKey()))
+ .setRecentlyBrowsedKeys(of(project1.getKey()))
.build();
assertSearch(query1).containsExactly(uuids(project1, project2));
SuggestionQuery query2 = SuggestionQuery.builder()
.setQuery("SonarQube")
.setQualifiers(Collections.singletonList(PROJECT))
- .setRecentlyBrowsedKeys(of(project2.getDbKey()))
+ .setRecentlyBrowsedKeys(of(project2.getKey()))
.build();
assertSearch(query2).containsExactly(uuids(project2, project1));
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java
index 3fbf4f34622..145a4eab0c4 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexScoreTest.java
@@ -122,15 +122,15 @@ public class ComponentIndexScoreTest extends ComponentIndexTest {
assertSearch(SuggestionQuery.builder()
.setQuery("File")
.setQualifiers(asList(PROJECT, MODULE, FILE))
- .setRecentlyBrowsedKeys(ImmutableSet.of(file1.getDbKey()))
- .setFavoriteKeys(ImmutableSet.of(file2.getDbKey()))
+ .setRecentlyBrowsedKeys(ImmutableSet.of(file1.getKey()))
+ .setFavoriteKeys(ImmutableSet.of(file2.getKey()))
.build()).containsExactly(uuids(file2, file1));
assertSearch(SuggestionQuery.builder()
.setQuery("File")
.setQualifiers(asList(PROJECT, MODULE, FILE))
- .setRecentlyBrowsedKeys(ImmutableSet.of(file2.getDbKey()))
- .setFavoriteKeys(ImmutableSet.of(file1.getDbKey()))
+ .setRecentlyBrowsedKeys(ImmutableSet.of(file2.getKey()))
+ .setFavoriteKeys(ImmutableSet.of(file1.getKey()))
.build()).containsExactly(uuids(file1, file2));
}
@@ -161,12 +161,12 @@ public class ComponentIndexScoreTest extends ComponentIndexTest {
index(ComponentTesting.newFileDto(project)
.setName("DbTester.java")
- .setDbKey("java/org/example/DbTester.java")
+ .setKey("java/org/example/DbTester.java")
.setUuid("UUID-DbTester"));
index(ComponentTesting.newFileDto(project)
.setName("WebhookDbTesting.java")
- .setDbKey("java/org/example/WebhookDbTesting.java")
+ .setKey("java/org/example/WebhookDbTesting.java")
.setUuid("UUID-WebhookDbTesting"));
assertSearch("dbt").containsExactly(
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
index 9d15fe3a156..97ff35bad87 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchTest.java
@@ -67,9 +67,9 @@ public class ComponentIndexSearchTest {
@Test
public void filter_by_key_with_exact_match() {
- ComponentDto ignoredProject = db.components().insertPrivateProject(p -> p.setDbKey("ignored-project"));
- ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("shiny-project"));
- db.components().insertPrivateProject(p -> p.setDbKey("another-shiny-project"));
+ ComponentDto ignoredProject = db.components().insertPrivateProject(p -> p.setKey("ignored-project"));
+ ComponentDto project = db.components().insertPrivateProject(p -> p.setKey("shiny-project"));
+ db.components().insertPrivateProject(p -> p.setKey("another-shiny-project"));
index(ignoredProject, project);
SearchIdResult<String> result = underTest.search(ComponentQuery.builder().setQuery("shiny-project").build(), new SearchOptions());
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchWindowExceededTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchWindowExceededTest.java
index a1fac9fd574..15681c4da4b 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchWindowExceededTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexSearchWindowExceededTest.java
@@ -65,7 +65,7 @@ public class ComponentIndexSearchWindowExceededTest {
.setId(componentDoc.uuid())
.setKey(componentDoc.getKey())
.setName(componentDoc.name())
- .setProjectUuid(componentDoc.projectUuid())
+ .setProjectUuid(componentDoc.branchUuid())
.setQualifier(componentDoc.qualifier());
}
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
index c9ab8e5a55c..06d683bd1b5 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/component/index/ComponentIndexTest.java
@@ -114,13 +114,13 @@ public abstract class ComponentIndexTest {
protected ComponentDto indexProject(String key, String name) {
return index(
ComponentTesting.newPrivateProjectDto("UUID_" + key)
- .setDbKey(key)
+ .setKey(key)
.setName(name));
}
protected ComponentDto newProject(String key, String name) {
return ComponentTesting.newPrivateProjectDto("UUID_" + key)
- .setDbKey(key)
+ .setKey(key)
.setName(name);
}
@@ -132,7 +132,7 @@ public abstract class ComponentIndexTest {
protected ComponentDto indexFile(ComponentDto project, String fileKey, String fileName) {
return index(
ComponentTesting.newFileDto(project)
- .setDbKey(fileKey)
+ .setKey(fileKey)
.setName(fileName));
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java
index 9ec67e24fb9..0a2f76b18c5 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexFiltersTest.java
@@ -330,14 +330,14 @@ public class IssueIndexFiltersTest extends IssueIndexTestCommon {
@Test
public void filter_by_application_branch_having_project_branches() {
- ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app"));
+ ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app"));
ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
- ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
+ ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1"));
ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
- ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
+ ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2"));
indexView(applicationBranch1.uuid(), asList(project1Branch1.uuid(), project2.uuid()));
indexView(applicationBranch2.uuid(), singletonList(project1Branch2.uuid()));
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
index 1bbc1bcc053..aa60a57c2b9 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
@@ -262,7 +262,7 @@ public class IssueIndexSyncProgressCheckerTest {
ComponentDto subview = db.components().insertSubView(view);
DbSession session = db.getSession();
- List<String> appViewOrSubviewKeys = Arrays.asList(projectDto1.getKey(), app.getDbKey(), view.getDbKey(), subview.getDbKey());
+ List<String> appViewOrSubviewKeys = Arrays.asList(projectDto1.getKey(), app.getKey(), view.getKey(), subview.getKey());
// throws if flag set to TRUE
assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session,
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
index e62a4b63528..4d26ed316be 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java
@@ -218,7 +218,7 @@ public class IssueIndexTest extends IssueIndexTestCommon {
userSessionRule.logIn(user1);
assertThatSearchReturnsOnly(IssueQuery.builder(), "I1");
- assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project3.getDbKey())));
+ assertThatSearchReturnsEmpty(IssueQuery.builder().projectUuids(singletonList(project3.getKey())));
userSessionRule.logIn(user2);
assertThatSearchReturnsOnly(IssueQuery.builder(), "I2");
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
index 772d49480d1..3bb7a74ca8a 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
@@ -92,7 +92,7 @@ public class IssueQueryFactoryTest {
.setStatuses(asList("CLOSED"))
.setResolutions(asList("FALSE-POSITIVE"))
.setResolved(true)
- .setProjects(asList(project.getDbKey()))
+ .setProjects(asList(project.getKey()))
.setDirectories(asList("aDirPath"))
.setFiles(asList(file.uuid()))
.setAssigneesUuid(asList(user.getUuid()))
@@ -479,7 +479,7 @@ public class IssueQueryFactoryTest {
public void onComponentOnly_restricts_search_to_specified_componentKeys() {
ComponentDto project = db.components().insertPrivateProject();
SearchRequest request = new SearchRequest()
- .setComponents(asList(project.getDbKey()))
+ .setComponents(asList(project.getKey()))
.setOnComponentOnly(true);
IssueQuery query = underTest.create(request);
@@ -633,14 +633,14 @@ public class IssueQueryFactoryTest {
@Test
public void search_by_application_key_and_branch() {
- ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app"));
+ ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setKey("app"));
ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
- ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
+ ComponentDto project1 = db.components().insertPrivateProject(p -> p.setKey("prj1"));
ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
- ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
+ ComponentDto project2 = db.components().insertPrivateProject(p -> p.setKey("prj2"));
db.components().insertComponents(newProjectCopy(project1Branch1, applicationBranch1));
db.components().insertComponents(newProjectCopy(project2, applicationBranch1));
db.components().insertComponents(newProjectCopy(project1Branch2, applicationBranch2));
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
index 29c231ab8a3..cc5497e54ab 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
@@ -93,12 +93,12 @@ public class ProjectMeasuresIndexTest {
private static final String NEW_LINES = "new_lines";
private static final String LANGUAGES = "languages";
- private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto().setUuid("Project-1").setName("Project 1").setDbKey("key-1");
- private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto().setUuid("Project-2").setName("Project 2").setDbKey("key-2");
- private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto().setUuid("Project-3").setName("Project 3").setDbKey("key-3");
- private static final ComponentDto APP1 = ComponentTesting.newApplication().setUuid("App-1").setName("App 1").setDbKey("app-key-1");
- private static final ComponentDto APP2 = ComponentTesting.newApplication().setUuid("App-2").setName("App 2").setDbKey("app-key-2");
- private static final ComponentDto APP3 = ComponentTesting.newApplication().setUuid("App-3").setName("App 3").setDbKey("app-key-3");
+ private static final ComponentDto PROJECT1 = ComponentTesting.newPrivateProjectDto().setUuid("Project-1").setName("Project 1").setKey("key-1");
+ private static final ComponentDto PROJECT2 = ComponentTesting.newPrivateProjectDto().setUuid("Project-2").setName("Project 2").setKey("key-2");
+ private static final ComponentDto PROJECT3 = ComponentTesting.newPrivateProjectDto().setUuid("Project-3").setName("Project 3").setKey("key-3");
+ private static final ComponentDto APP1 = ComponentTesting.newApplication().setUuid("App-1").setName("App 1").setKey("app-key-1");
+ private static final ComponentDto APP2 = ComponentTesting.newApplication().setUuid("App-2").setName("App 2").setKey("app-key-2");
+ private static final ComponentDto APP3 = ComponentTesting.newApplication().setUuid("App-3").setName("App 3").setKey("app-key-3");
private static final UserDto USER1 = newUserDto();
private static final UserDto USER2 = newUserDto();
private static final GroupDto GROUP1 = newGroupDto();
@@ -126,10 +126,10 @@ public class ProjectMeasuresIndexTest {
@Test
public void default_sort_is_by_ascending_case_insensitive_name_then_by_key() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
assertResults(new ProjectMeasuresQuery(), apache1, apache2, apachee, windows);
@@ -159,10 +159,10 @@ public class ProjectMeasuresIndexTest {
@Test
public void sort_by_a_metric_then_by_name_then_by_key() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
index(
newDoc(windows, NCLOC, 10_000d),
newDoc(apachee, NCLOC, 5_000d),
@@ -175,7 +175,7 @@ public class ProjectMeasuresIndexTest {
@Test
public void sort_by_quality_gate_status() {
- ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setDbKey("key-4");
+ ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setKey("key-4");
index(
newDoc(PROJECT1).setQualityGateStatus(OK.name()),
newDoc(PROJECT2).setQualityGateStatus(ERROR.name()),
@@ -187,10 +187,10 @@ public class ProjectMeasuresIndexTest {
@Test
public void sort_by_quality_gate_status_then_by_name_then_by_key() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
index(
newDoc(windows).setQualityGateStatus(ERROR.name()),
newDoc(apachee).setQualityGateStatus(OK.name()),
@@ -422,7 +422,7 @@ public class ProjectMeasuresIndexTest {
@Test
public void filter_on_languages() {
- ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setDbKey("key-4");
+ ComponentDto project4 = ComponentTesting.newPrivateProjectDto().setUuid("Project-4").setName("Project 4").setKey("key-4");
index(
newDoc(PROJECT1).setLanguages(singletonList("java")),
newDoc(PROJECT2).setLanguages(singletonList("xoo")),
@@ -436,10 +436,10 @@ public class ProjectMeasuresIndexTest {
@Test
public void filter_on_query_text() {
- ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setDbKey("project1");
- ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setDbKey("project2");
- ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setDbKey("project3");
- ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setDbKey("project4");
+ ComponentDto windows = ComponentTesting.newPrivateProjectDto().setUuid("windows").setName("Windows").setKey("project1");
+ ComponentDto apachee = ComponentTesting.newPrivateProjectDto().setUuid("apachee").setName("apachee").setKey("project2");
+ ComponentDto apache1 = ComponentTesting.newPrivateProjectDto().setUuid("apache-1").setName("Apache").setKey("project3");
+ ComponentDto apache2 = ComponentTesting.newPrivateProjectDto().setUuid("apache-2").setName("Apache").setKey("project4");
index(newDoc(windows), newDoc(apachee), newDoc(apache1), newDoc(apache2));
assertResults(new ProjectMeasuresQuery().setQueryText("windows"), windows);
@@ -1736,7 +1736,7 @@ public class ProjectMeasuresIndexTest {
private static ProjectMeasuresDoc newDoc(ComponentDto project) {
return new ProjectMeasuresDoc()
.setId(project.uuid())
- .setKey(project.getDbKey())
+ .setKey(project.getKey())
.setName(project.name())
.setQualifier(project.qualifier());
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
index 56d1732dec6..b8885dcf6d1 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTextSearchTest.java
@@ -63,8 +63,8 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void search_partial_text_from_project_key() {
index(
- newDoc(newPrivateProjectDto().setUuid("struts").setName("Apache Struts").setDbKey("org.apache.commons.structs")),
- newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonar.sonarqube")));
+ newDoc(newPrivateProjectDto().setUuid("struts").setName("Apache Struts").setKey("org.apache.commons.structs")),
+ newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org.sonar.sonarqube")));
assertTextQueryResults("apache", "struts");
assertTextQueryResults("apache.comm", "struts");
@@ -196,8 +196,8 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void match_exact_case_insensitive_key() {
index(
- newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setDbKey("project1")),
- newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setDbKey("project2")));
+ newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setKey("project1")),
+ newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setKey("project2")));
assertTextQueryResults("project1", "project1");
assertTextQueryResults("PROJECT1", "project1");
@@ -207,8 +207,8 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void match_key_with_dot() {
index(
- newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonarqube")),
- newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setDbKey("sonarqube")));
+ newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org.sonarqube")),
+ newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setKey("sonarqube")));
assertTextQueryResults("org.sonarqube", "sonarqube");
assertNoResults("orgsonarqube");
@@ -220,8 +220,8 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void match_key_with_dash() {
index(
- newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org-sonarqube")),
- newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setDbKey("sonarqube")));
+ newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org-sonarqube")),
+ newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setKey("sonarqube")));
assertTextQueryResults("org-sonarqube", "sonarqube");
assertNoResults("orgsonarqube");
@@ -233,8 +233,8 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void match_key_with_colon() {
index(
- newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org:sonarqube")),
- newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setDbKey("sonarqube")));
+ newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org:sonarqube")),
+ newDoc(newPrivateProjectDto().setUuid("sq").setName("SQ").setKey("sonarqube")));
assertTextQueryResults("org:sonarqube", "sonarqube");
assertNoResults("orgsonarqube");
@@ -245,7 +245,7 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void match_key_having_all_special_characters() {
- index(newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setDbKey("org.sonarqube:sonar-sérvèr_ç")));
+ index(newDoc(newPrivateProjectDto().setUuid("sonarqube").setName("SonarQube").setKey("org.sonarqube:sonar-sérvèr_ç")));
assertTextQueryResults("org.sonarqube:sonar-sérvèr_ç", "sonarqube");
}
@@ -254,12 +254,12 @@ public class ProjectMeasuresIndexTextSearchTest {
public void facets_take_into_account_text_search() {
index(
// docs with ncloc<1K
- newDoc(newPrivateProjectDto().setName("Windows").setDbKey("project1"), NCLOC, 0d),
- newDoc(newPrivateProjectDto().setName("apachee").setDbKey("project2"), NCLOC, 999d),
+ newDoc(newPrivateProjectDto().setName("Windows").setKey("project1"), NCLOC, 0d),
+ newDoc(newPrivateProjectDto().setName("apachee").setKey("project2"), NCLOC, 999d),
// docs with ncloc>=1K and ncloc<10K
- newDoc(newPrivateProjectDto().setName("Apache").setDbKey("project3"), NCLOC, 1_000d),
+ newDoc(newPrivateProjectDto().setName("Apache").setKey("project3"), NCLOC, 1_000d),
// docs with ncloc>=100K and ncloc<500K
- newDoc(newPrivateProjectDto().setName("Apache Foundation").setDbKey("project4"), NCLOC, 100_000d));
+ newDoc(newPrivateProjectDto().setName("Apache Foundation").setKey("project4"), NCLOC, 100_000d));
assertNclocFacet(new ProjectMeasuresQuery().setQueryText("apache"), 1L, 1L, 0L, 1L, 0L);
assertNclocFacet(new ProjectMeasuresQuery().setQueryText("PAch"), 1L, 1L, 0L, 1L, 0L);
@@ -271,10 +271,10 @@ public class ProjectMeasuresIndexTextSearchTest {
@Test
public void filter_by_metric_take_into_account_text_search() {
index(
- newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setDbKey("project1"), NCLOC, 30_000d),
- newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setDbKey("project2"), NCLOC, 40_000d),
- newDoc(newPrivateProjectDto().setUuid("project3").setName("Apache").setDbKey("project3"), NCLOC, 50_000d),
- newDoc(newPrivateProjectDto().setUuid("project4").setName("Apache").setDbKey("project4"), NCLOC, 60_000d));
+ newDoc(newPrivateProjectDto().setUuid("project1").setName("Windows").setKey("project1"), NCLOC, 30_000d),
+ newDoc(newPrivateProjectDto().setUuid("project2").setName("apachee").setKey("project2"), NCLOC, 40_000d),
+ newDoc(newPrivateProjectDto().setUuid("project3").setName("Apache").setKey("project3"), NCLOC, 50_000d),
+ newDoc(newPrivateProjectDto().setUuid("project4").setName("Apache").setKey("project4"), NCLOC, 60_000d));
assertResults(new ProjectMeasuresQuery().setQueryText("apache").addMetricCriterion(MetricCriterion.create(NCLOC, GT, 20_000d)), "project3", "project4", "project2");
assertResults(new ProjectMeasuresQuery().setQueryText("apache").addMetricCriterion(MetricCriterion.create(NCLOC, LT, 55_000d)), "project3", "project2");
@@ -291,7 +291,7 @@ public class ProjectMeasuresIndexTextSearchTest {
private static ProjectMeasuresDoc newDoc(ComponentDto project) {
return new ProjectMeasuresDoc()
.setId(project.uuid())
- .setKey(project.getDbKey())
+ .setKey(project.getKey())
.setName(project.name())
.setQualifier(project.qualifier());
}