use of org.sonar.ce.queue.CeTaskSubmit in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row.
@Test
public void submit_returns_task_populated_from_CeTaskSubmit_and_creates_CeQueue_row() {
CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, "PROJECT_1", "rob");
CeTask task = underTest.submit(taskSubmit);
verifyCeTask(taskSubmit, task, null);
verifyCeQueueDtoForTaskSubmit(taskSubmit);
}
use of org.sonar.ce.queue.CeTaskSubmit in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method submit_populates_component_name_and_key_of_CeTask_if_component_exists.
@Test
public void submit_populates_component_name_and_key_of_CeTask_if_component_exists() {
ComponentDto componentDto = insertComponent(newComponentDto("PROJECT_1"));
CeTaskSubmit taskSubmit = createTaskSubmit(CeTaskTypes.REPORT, componentDto.uuid(), null);
CeTask task = underTest.submit(taskSubmit);
verifyCeTask(taskSubmit, task, componentDto);
}
use of org.sonar.ce.queue.CeTaskSubmit in project sonarqube by SonarSource.
the class InternalCeQueueImplTest method massSubmit_returns_tasks_for_each_CeTaskSubmit_populated_from_CeTaskSubmit_and_creates_CeQueue_row_for_each.
@Test
public void massSubmit_returns_tasks_for_each_CeTaskSubmit_populated_from_CeTaskSubmit_and_creates_CeQueue_row_for_each() {
CeTaskSubmit taskSubmit1 = createTaskSubmit(CeTaskTypes.REPORT, "PROJECT_1", "rob");
CeTaskSubmit taskSubmit2 = createTaskSubmit("some type");
List<CeTask> tasks = underTest.massSubmit(asList(taskSubmit1, taskSubmit2));
assertThat(tasks).hasSize(2);
verifyCeTask(taskSubmit1, tasks.get(0), null);
verifyCeTask(taskSubmit2, tasks.get(1), null);
verifyCeQueueDtoForTaskSubmit(taskSubmit1);
verifyCeQueueDtoForTaskSubmit(taskSubmit2);
}
use of org.sonar.ce.queue.CeTaskSubmit in project sonarqube by SonarSource.
the class AsyncIssueIndexingImplTest method characteristics_are_defined.
@Test
public void characteristics_are_defined() {
BranchDto dto = new BranchDto().setBranchType(BRANCH).setKey("branch_1").setUuid("branch_uuid1").setProjectUuid("project_uuid1");
dbClient.branchDao().insert(dbTester.getSession(), dto);
dbTester.commit();
insertSnapshot("analysis_1", "project_uuid1", 1);
BranchDto dto2 = new BranchDto().setBranchType(PULL_REQUEST).setKey("pr_1").setUuid("pr_uuid_1").setProjectUuid("project_uuid2");
dbClient.branchDao().insert(dbTester.getSession(), dto2);
dbTester.commit();
insertSnapshot("analysis_2", "project_uuid2", 2);
underTest.triggerOnIndexCreation();
ArgumentCaptor<Collection<CeTaskSubmit>> captor = ArgumentCaptor.forClass(Collection.class);
verify(ceQueue, times(1)).massSubmit(captor.capture());
List<Collection<CeTaskSubmit>> captures = captor.getAllValues();
assertThat(captures).hasSize(1);
Collection<CeTaskSubmit> tasks = captures.get(0);
assertThat(tasks).hasSize(2);
assertThat(tasks).extracting(p -> p.getCharacteristics().get(BRANCH_TYPE_KEY), p -> p.getCharacteristics().get(CeTaskCharacteristicDto.BRANCH_KEY), p -> p.getCharacteristics().get(CeTaskCharacteristicDto.PULL_REQUEST)).containsExactlyInAnyOrder(tuple("BRANCH", "branch_1", null), tuple("PULL_REQUEST", null, "pr_1"));
}
use of org.sonar.ce.queue.CeTaskSubmit in project sonarqube by SonarSource.
the class ExportSubmitterImpl method submitProjectExport.
@Override
public CeTask submitProjectExport(String projectKey, @Nullable String submitterUuid) {
requireNonNull(projectKey, "Project key can not be null");
try (DbSession dbSession = dbClient.openSession(false)) {
Optional<ComponentDto> project = dbClient.componentDao().selectByKey(dbSession, projectKey);
checkArgument(project.isPresent(), "Project with key [%s] does not exist", projectKey);
CeTaskSubmit submit = ceQueue.prepareSubmit().setComponent(fromDto(project.get())).setType(CeTaskTypes.PROJECT_EXPORT).setSubmitterUuid(submitterUuid).setCharacteristics(emptyMap()).build();
return ceQueue.submit(submit);
}
}
Aggregations