aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce/src/it
diff options
context:
space:
mode:
authorLéo Geoffroy <leo.geoffroy@sonarsource.com>2023-04-03 09:35:11 +0200
committersonartech <sonartech@sonarsource.com>2023-04-04 20:03:16 +0000
commit3195a1ad95466c1e722f42348a1e12ba908b36f7 (patch)
tree67e964bc07e2cba95414081a0f8749d675b35f2d /server/sonar-ce/src/it
parent3f602a70548d285d61d0295b704aa18a3b8314b8 (diff)
downloadsonarqube-3195a1ad95466c1e722f42348a1e12ba908b36f7.tar.gz
sonarqube-3195a1ad95466c1e722f42348a1e12ba908b36f7.zip
SONAR-18850 remove usage main branch project UUID in ce task
Diffstat (limited to 'server/sonar-ce/src/it')
-rw-r--r--server/sonar-ce/src/it/java/org/sonar/ce/queue/InternalCeQueueImplIT.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/server/sonar-ce/src/it/java/org/sonar/ce/queue/InternalCeQueueImplIT.java b/server/sonar-ce/src/it/java/org/sonar/ce/queue/InternalCeQueueImplIT.java
index fdf5b58d390..01d31b78804 100644
--- a/server/sonar-ce/src/it/java/org/sonar/ce/queue/InternalCeQueueImplIT.java
+++ b/server/sonar-ce/src/it/java/org/sonar/ce/queue/InternalCeQueueImplIT.java
@@ -96,7 +96,8 @@ public class InternalCeQueueImplIT {
@Test
public void submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row() {
- CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"), "rob");
+ ComponentDto project1 = newProjectDto("PROJECT_1");
+ CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, project1, project1, "rob");
CeTask task = underTest.submit(taskSubmit);
UserDto userDto = db.getDbClient().userDao().selectByUuid(db.getSession(), taskSubmit.getSubmitterUuid());
verifyCeTask(taskSubmit, task, null, userDto);
@@ -106,7 +107,7 @@ public class InternalCeQueueImplIT {
@Test
public void submit_populates_component_name_and_key_of_CeTask_if_component_exists() {
ComponentDto componentDto = insertComponent(newProjectDto("PROJECT_1"));
- CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, componentDto, null);
+ CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, componentDto, componentDto, null);
CeTask task = underTest.submit(taskSubmit);
@@ -124,7 +125,8 @@ public class InternalCeQueueImplIT {
@Test
public void massSubmit_returns_tasks_for_each_CeTaskSubmit_populated_from_CeTaskSubmit_and_creates_CeQueue_row_for_each() {
- CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, newProjectDto("PROJECT_1"), "rob");
+ ComponentDto project1 = newProjectDto("PROJECT_1");
+ CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, project1, project1, "rob");
CeTaskSubmit taskSubmit2 = createTaskSubmit("some type");
List<CeTask> tasks = underTest.massSubmit(asList(taskSubmit1, taskSubmit2));
@@ -140,8 +142,9 @@ public class InternalCeQueueImplIT {
@Test
public void massSubmit_populates_component_name_and_key_of_CeTask_if_component_exists() {
ComponentDto componentDto1 = insertComponent(newProjectDto("PROJECT_1"));
- CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, componentDto1, null);
- CeTaskSubmit taskSubmit2 = createTaskSubmit("something", newProjectDto("non existing component uuid"), null);
+ CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, componentDto1, componentDto1, null);
+ ComponentDto nonExistingComponent = newProjectDto("non existing component uuid");
+ CeTaskSubmit taskSubmit2 = createTaskSubmit("something", nonExistingComponent, nonExistingComponent, null);
List<CeTask> tasks = underTest.massSubmit(asList(taskSubmit1, taskSubmit2));
@@ -384,7 +387,7 @@ public class InternalCeQueueImplIT {
public void peek_populates_name_and_key_for_existing_component_and_main_component() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project);
- CeTask task = submit(CeTaskTypes.REPORT, branch);
+ CeTask task = submit(CeTaskTypes.REPORT, project, branch);
Optional<CeTask> peek = underTest.peek(WORKER_UUID_1, true);
assertThat(peek).isPresent();
@@ -686,21 +689,26 @@ public class InternalCeQueueImplIT {
return ComponentTesting.newPublicProjectDto(uuid).setName("name_" + uuid).setKey("key_" + uuid);
}
- private CeTask submit(String reportType, ComponentDto componentDto) {
- return underTest.submit(createTaskSubmit(reportType, componentDto, null));
+ private CeTask submit(String reportType, ComponentDto mainBranchComponent) {
+ return underTest.submit(createTaskSubmit(reportType, mainBranchComponent, mainBranchComponent, null));
+ }
+
+ private CeTask submit(String reportType, ComponentDto mainBranchComponent, ComponentDto branchComponent) {
+ return underTest.submit(createTaskSubmit(reportType, mainBranchComponent, branchComponent, null));
}
private CeTaskSubmit createTaskSubmit(String type) {
- return createTaskSubmit(type, null, null);
+ return createTaskSubmit(type, null, null, null);
}
- private CeTaskSubmit createTaskSubmit(String type, @Nullable ComponentDto componentDto, @Nullable String submitterUuid) {
+ private CeTaskSubmit createTaskSubmit(String type, @Nullable ComponentDto mainBranchComponentDto, @Nullable ComponentDto componentDto,
+ @Nullable String submitterUuid) {
CeTaskSubmit.Builder builder = underTest.prepareSubmit()
.setType(type)
.setSubmitterUuid(submitterUuid)
.setCharacteristics(emptyMap());
- if (componentDto != null) {
- builder.setComponent(CeTaskSubmit.Component.fromDto(componentDto));
+ if (componentDto != null && mainBranchComponentDto != null) {
+ builder.setComponent(CeTaskSubmit.Component.fromDto(componentDto.uuid(), mainBranchComponentDto.uuid()));
}
return builder.build();
}